Skip to content

Update Authentication Cheat Sheet: add Common JWT Implementation Mistakes section#2101

Open
franrob-projects wants to merge 1 commit intoOWASP:masterfrom
franrob-projects:update/authentication-jwt-implementation-mistakes
Open

Update Authentication Cheat Sheet: add Common JWT Implementation Mistakes section#2101
franrob-projects wants to merge 1 commit intoOWASP:masterfrom
franrob-projects:update/authentication-jwt-implementation-mistakes

Conversation

@franrob-projects
Copy link
Copy Markdown

What this PR addresses

Closes #1973

The Authentication Cheat Sheet covers OAuth 2.0 and OpenID Connect but does not address the common mistakes developers make specifically when implementing JWT-based authentication. Given how frequently JWTs appear in modern app stacks, this is a practical gap.

Changes

Adds a new ### Common JWT Implementation Mistakes subsection directly after the OpenID Connect section, covering five concrete mistakes with recommendations for each:

  1. Storing JWTs in browser-accessible storagelocalStorage/sessionStorage exposure via XSS; recommendation to use HttpOnly cookies for refresh tokens and in-memory storage for access tokens.

  2. Missing or insufficient token expiration — tokens without exp or with far-future expiry cannot be revoked; recommendation for short access token TTLs (15 min–1 hr) with refresh token rotation.

  3. Failing to validate iss, aud, sub, and signature claims — recommendation to always verify all four, and to never accept alg: none.

  4. Placing sensitive data in JWT payloads — payloads are Base64Url-encoded, not encrypted; recommendation to use JWE or opaque tokens when sensitive claims are required.

  5. Using JWTs where immediate revocation is needed — JWTs remain valid until exp; recommendation to use a jti denylist or opaque session tokens for high-security contexts.

Section closes with a link to the OWASP JSON Web Token Cheat Sheet for deeper coverage.

Checklist

  • All markdown files do not raise any validation policy violation
  • All markdown files follow the format rules
  • Any references to websites have been formatted as [TEXT](URL)
  • The contribution has been verified for accuracy

AI Tool Usage Disclosure

  • I have not used AI tools to generate the contents of this PR

…akes section

Closes OWASP#1973

Adds a new 'Common JWT Implementation Mistakes' subsection under the
OAuth 2.0 / OpenID Connect block, covering five practical mistakes
developers make when integrating JWTs into authentication flows:

- Storing JWTs in browser-accessible storage (localStorage/sessionStorage)
- Missing or insufficient token expiration (exp claim)
- Failing to validate iss, aud, sub, and signature claims
- Placing sensitive data in unencrypted JWT payloads
- Using JWTs in scenarios that require immediate revocation

Each mistake includes a concrete recommendation. Section links to the
OWASP JWT Cheat Sheet for deeper attack/defence detail.
franrob-projects added a commit to franrob-projects/portfolio that referenced this pull request Apr 21, 2026
- Add TeachYAR and GibTrain (Gibraltar Compliance) project cards.
  Extend Project interface with an optional live URL and a "Live site"
  button. GibTrain links to its GitHub Pages deployment.

- Add "Open-source contributions" subsection listing five docs PRs:
  graphprotocol/docs#1096, open-telemetry/opentelemetry.io#9711,
  redpanda-data/docs#1656, OWASP/CheatSheetSeries#2101 and #2100.
  Styled with repo code-tag, state pill, and PR number.

- Home page copy: "Tech writer" -> "All things docs",
  "My writer journey" -> "My journey".

- Expand the Ably entry with the docs re-engineering work
  (Textile -> Next.js + TypeScript + React) and link the two merged
  MDX conversion PRs: ably/docs#2911 (REST API) and #2913 (SSE).

- Expand docs/ably/index.md with a new "Re-engineering the docs site"
  section plus images across SSE, webhooks, pub/sub, troubleshooting,
  and architecture. Add a troubleshooting subsection linking
  ably/docs#2984 (HAR file guide) and #2818 (service disruptions).

- Rename static/img/ably/ably-troubleshooting/ (drop the trailing
  space in the directory name that was breaking image references).

- Remove em-dashes from site content (projects page, 3 blog post
  alt-texts) using contextual substitutions: colons for titles and
  list intros, commas/periods for mid-sentence pauses, parens for a
  parenthetical, pipe for the HTML page title.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mackowski
Copy link
Copy Markdown
Collaborator

@jmanico please take a look on this one


JWTs are designed for stateless, short-lived bearer credentials. They are a poor fit for scenarios that require immediate revocation (for example, after a security event such as a password change or account suspension), because the token remains cryptographically valid until its `exp` is reached.

**Recommendation:** For sessions that require instant revocation, supplement JWTs with a server-side denylist keyed on the `jti` (JWT ID) claim, or replace JWTs with opaque session tokens backed by a session store that can be invalidated on demand.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This advice is incomplete for distributed systems. I would add something like:
"the denylist must be shared across all service instances (e.g., in Redis or a database), not held in
memory per instance"

@jmanico
Copy link
Copy Markdown
Member

jmanico commented Apr 26, 2026

Folks we have an entire JWT cheatsheet...

https://cheatsheetseries.owasp.org/cheatsheets/JSON_Web_Token_for_Java_Cheat_Sheet.html

Can we add this work there instead and link to it?

Copy link
Copy Markdown
Member

@jmanico jmanico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update: Authentication Cheat Sheet

4 participants