v0.14 is out: a mobile auth pack for Swift/iOS and Android, catching insecure token storage, cleartext traffic, and OAuth in embedded WebViews. Read more →
HIGH AI PREVALENCE: HIGH auth.php.jwt.manual-decode-no-verify

A JWT payload is read by hand (json_decode(base64_decode($parts[1])) on the second dot-segment of a token) without ever verifying the signature.

Why AI tools produce this: AI coding tools generate this anti-pattern by default, it appears in a large share of AI-written auth code.

Why this matters

The claims (user id, roles, scopes) are trusted straight from an attacker- controllable string, so anyone can forge a token with any identity and it will be accepted (CWE-347). This is a common AI-generated shortcut: the model "decodes" the token to read a claim and skips verification entirely.

Verify the signature with the library instead, pinning the algorithm and a key from configuration: use Firebase\JWT\JWT; use Firebase\JWT\Key; $claims = JWT::decode($jwt, new Key($_ENV['JWT_SECRET'], 'HS256'));

VULNERABLE
vulnerable.php
<?php

function claims_from_jwt(string $authHeader): array
{
    $jwtParts = explode('.', $authHeader);
    // ruleid: auth.php.jwt.manual-decode-no-verify
    return json_decode(base64_decode($jwtParts[1]), true);
}

function subject_from_bearer(string $bearer)
{
    $tokenSegments = explode('.', $bearer);
    // ruleid: auth.php.jwt.manual-decode-no-verify
    $payload = json_decode(base64_decode($tokenSegments[1]));
    return $payload->sub;
}
SAFE
safe.php
<?php

use Firebase\JWT\JWT;
use Firebase\JWT\Key;

function claims_verified(string $jwt): array
{
    // ok: signature verified with a pinned algorithm and a key from config
    return (array) JWT::decode($jwt, new Key($_ENV['JWT_SECRET'], 'HS256'));
}

function header_only(string $bearer)
{
    $jwtParts = explode('.', $bearer);
    // ok: decoding the header segment (index 0), not the trusted payload
    return json_decode(base64_decode($jwtParts[0]), true);
}

function decode_image(string $dataUri)
{
    $imageParts = explode(',', $dataUri);
    // ok: generic base64 of a data URI, not a token
    return json_decode(base64_decode($imageParts[1]), true);
}

Suppressing this rule

If a finding is a genuine false positive, scope the suppression to the exact line and leave a reason, never disable the rule project-wide. Disable directives are line-scoped by design.

// oauthlint-disable-next-line auth.php.jwt.manual-decode-no-verify -- <reason>

References

https://github.com/firebase/php-jwt ↗https://cwe.mitre.org/data/definitions/347.html ↗