JWT Access Tokens Need Issuer, Audience, and Type Checks at Every Resource Server
RFC 9068 defines a common JWT profile for OAuth 2.0 access tokens. It gives authorization servers and resource servers a shared format for claims such as issuer, subject, audience, expiry and scope. The profile makes tokens easier to inspect and validate across vendors. It also makes validation mistakes easier to see because a resource server can no longer treat every signed JWT as a valid API credential.
The most important header is typ. RFC 9068 requires an access token to identify itself as an access token in the JWT header, normally with at+jwt. A resource server should reject a token whose type is missing or is an ID token type. ID tokens are designed for client authentication and user identity. They are not a general API authorization grant.
The aud claim is equally important. A token issued for the billing service should not be accepted by the administrative console. A token issued for one tenant should not be accepted by another tenant's API. Audience validation should happen before authorization logic, because a token from the wrong service may contain a scope string that the target service also uses.
Validate the issuer and the key
The resource server should accept a small, configured set of issuers and retrieve keys through a trusted discovery process. It should verify the signature algorithm, key identifier, issuer, expiry and not-before time. It should not let an attacker choose an algorithm through the token header. It should not fetch an arbitrary JWKS URL from an untrusted issuer merely because the token contains one.
Issuer validation should include the exact issuer value, including scheme and path. A service that accepts a prefix can be vulnerable to an attacker-controlled domain that reuses the prefix. Key rotation should be supported without accepting keys from unrelated issuers. Cached metadata should have a bounded lifetime and a safe behavior when the discovery endpoint is unavailable.
The scope claim is a string of space-delimited values in OAuth. It is not automatically an authorization policy. The resource server still has to map scope to operation, resource and tenant. If the token says reports:read, the server must decide whether that scope allows reading every report or only a report owned by the subject. The claim cannot answer that question by itself.
Keep token data out of logs
A JWT is often copied into proxy logs, application traces and support tickets because it is visible in the Authorization header. That turns a short-lived credential into a long-lived evidence problem. Log a stable token identifier, a hash or the jti claim if the issuer provides one. Do not log the full token or the private key used to sign it.
Resource servers should also record validation failures with the exact reason: unknown issuer, wrong audience, expired token, bad signature, missing type or unsupported algorithm. A generic 401 is useful to the client but not to the responder. Error logs should be rate limited so that token probing does not become a denial-of-service vector.
Test the path, not just the library
Unit tests should include a valid token, an ID token with the same signature, a token with a modified audience, a token for another issuer, a token with an unexpected algorithm and an expired token. The production gateway, the application framework and the downstream service should all use the same validation profile. A common failure is a gateway that validates correctly while a service behind it accepts a raw JWT from an internal header.
RFC 9068 provides the interoperability rules. It does not decide which subject may perform which action. Teams should connect the token profile to a resource authorization model, then verify that the model survives client changes, tenant changes and key rotation. The result is a token that carries clear identity and audience, not just a signature that looks familiar.
Top comments (0)