"Should I use OAuth or JWT?" is a common question, but it mixes two different categories. None of the three IETF documents used in this text (RFC 7519, RFC 8725 and RFC 9700) compares OAuth with JWT as alternatives. They describe things of a different nature:

  • OAuth 2.0 is an authorization protocol: it defines who asks for what, from whom, and how a token is issued.
  • JWT is a token format. RFC 7519 defines it as a format for representing claims, always serialized as a JWS or a JWE.

The relationship between the two is one-way. RFC 8725 says, in section 1, that JWTs are used, among other cases, for "OAuth 2.0 [RFC6749] access tokens and refresh tokens". RFC 9700, in turn, only says that the aud claim (defined in RFC 9068) can be used to restrict the audience of access tokens. Nothing requires an OAuth access token to be a JWT. The useful question is a different one: which protocol do I use to issue credentials, and in what format do they travel?

What JWT is, and what it is not

RFC 7519 defines each part of the token as carrying "a base64url-encoded value". Base64url is an encoding, not encryption. A JWS (signed token) guarantees integrity; confidentiality would require a JWE (encrypted token). In other words, anyone who receives a signed JWS can read the claims. What they cannot do is alter them without invalidating the signature, as long as validation is done correctly.

That condition is the fragile point, and RFC 8725 (JWT Best Current Practices, February 2020, by Y. Sheffer, D. Hardt and M. Jones) exists because of it.

Where JWT goes wrong: validation

RFC 8725 describes two classic attacks in section 2.1:

  1. The none algorithm. According to the text, "The algorithm can be changed to 'none' by an attacker, and some libraries would trust this value and 'validate' the JWT without checking any signature". RFC 7519 itself defines the Unsecured JWT as a JWS whose alg is none and whose signature is empty.
  2. RS256 → HS256 confusion. An attacker changes the alg from RS256 to HS256, and the library may try to validate the signature "using HMAC-SHA256 and using the RSA public key as the HMAC shared secret".

RFC 8725's recommendations for libraries and applications (sections 3.1 and 3.2) are straightforward:

  • The library "MUST enable the caller to specify a supported set of algorithms" and must not use any other.
  • Each key "MUST be used with exactly one algorithm", and this must be verified in the cryptographic operation.
  • The application should only allow cryptographically current algorithms.
  • Libraries should not generate or consume none tokens unless the caller explicitly asks for it.

In practice: pin the list of accepted algorithms in your application code instead of trusting the token header.

RFC 8725 also does not mention "session" anywhere in its text. Using JWT as a replacement for a session cookie is an architecture decision of your own, not a recommendation of the standard.

Revocation: the cost of a stateless token

OWASP Top 10:2025, in A01 (Broken Access Control), offers guidance on this in the "How to prevent" section:

  • "Stateful session identifiers should be invalidated on the server after logout."
  • "Stateless JWT tokens should be short-lived to minimize the window of opportunity for an attacker."
  • "For longer-lived JWTs, consider using refresh tokens and following OAuth standards to revoke access."

In A07 (Authentication Failures), OWASP adds that, for JWTs, it is necessary to verify "aud, iss claims and scopes", and recommends "use a premade, well-trusted system to handle authentication, identity, and session management".

What this means: a self-contained token cannot be "switched off" on the server unless some state is kept (a revocation list, for example). That is why OWASP's recommendation is to combine a short lifetime with a revocable refresh token.

What OAuth 2.0 requires today (RFC 9700)

RFC 9700 (BCP 240, January 2025; authors T. Lodderstedt, J. Bradley, A. Labunets and D. Fett) updates RFCs 6749, 6750 and 6819 and consolidates what has changed in security. Points verified in the text:

TopicWhat the RFC saysSection
PKCE"Public clients MUST use PKCE"; for confidential clients it is "RECOMMENDED"; authorization servers "MUST support PKCE"2.1.1
PKCE methodS256 is the only method that does not expose the verifier in the authorization request2.1.1
Implicit grantClients "SHOULD NOT use the implicit grant"; they should use the code response type2.1.2
Redirect URIExact string comparison, except for the port in localhost redirects of native apps2.1
Refresh token (public client)"MUST be sender-constrained or use refresh token rotation"2.2.2
Access token"SHOULD" be sender-constrained2.2.1
Password grant"MUST NOT be used"2.4

A note: the RFC does not call plain insecure (nor does it mention it); it only says that S256 is the only method that does not expose the verifier.

How to decide (reasoning, not data)

Given the facts above, the decision can be organized as follows. This is a suggestion by the author, not a recommendation of any standard:

  1. Do you need to delegate login to an external provider (Google, GitHub, the company's IdP)? That is OAuth 2.0 (and, for identity, usually OpenID Connect on top of it). Use the code flow with PKCE and follow RFC 9700.
  2. Do you only need a session for your own site? OWASP itself accepts random session identifiers kept in a tightly controlled store ("Storing random session tokens verbatim can be acceptable in a tightly controlled session store", Session Management Cheat Sheet). The cheat sheet adds the caveat that, if the store can be read by third parties, it is worth storing a one-way verifier instead of the token. In that case logout invalidates the session on the server and you do not need a JWT.
  3. Do you need several services to validate the token without querying a central database? That is where JWT makes sense. Pin the algorithms, validate iss, aud and expiration, use a short lifetime and have a revocation plan.

If cookies are used for the session identifier, the OWASP Session Management Cheat Sheet describes Secure as the attribute that makes the browser send the cookie only over HTTPS ("mandatory to prevent the disclosure of the session ID through MitM"), and HttpOnly as the one that prevents scripts from reading the cookie.

Context: why this matters

In the Verizon DBIR 2026 (dataset from October 2024 to November 2025, according to the executive summary; n = 19,905 in figure 4), credential abuse fell to 13% of known initial access vectors and is no longer the leader, a position that passed to vulnerability exploitation, at 31%. In other words, credentials are still a relevant vector, but no longer the main one. In OWASP Top 10:2025, "Authentication Failures" (A07) remains in seventh position, with 36 mapped CWEs, an average incidence of 2.92%, 1,120,673 occurrences and 7,147 CVEs.

Summary

  • OAuth 2.0 is a protocol; JWT is a format. They may or may not coexist.
  • The biggest JWT risk is in validation (alg), described in RFC 8725.
  • Stateless tokens require a short lifetime and a revocation plan (OWASP A01).
  • If you implement OAuth today, the reference is RFC 9700: PKCE for public clients, code instead of implicit, exact redirect URI.

Sources