appsec.fyi

JWT — A Practical Guide

A curated AppSec resource library covering XSS, SQLi, SSRF, IDOR, RCE, XXE, OSINT, and more.

JWT: A Practical Guide

Curated and synthesized by . Last updated 2026-11-01. Synthesized from 114 of 114 curated resources. Browse all 114 JWT resources →

Problem Framing: Why JWTs Still Matter (and Why They Get Attacked)

JSON Web Tokens (JWTs) have become a ubiquitous standard for securely transmitting information between parties, particularly in the realm of authentication and authorization. Their popularity stems from their stateless nature, allowing for scalable architectures where servers don't need to maintain persistent session state. However, this very statelessness and the self-contained nature of JWTs also present significant security challenges. When implemented improperly, JWTs can become a critical attack vector, leading to unauthorized access, privilege escalation, and complete system compromise.

At their core, JWTs are simply base64url-encoded JSON objects containing a header, a payload (claims), and a signature. While the header specifies metadata like the signing algorithm, and the payload carries verifiable statements about an entity (e.g., user ID, roles, expiration), it's the signature that is supposed to guarantee the integrity and authenticity of the token. The security of the entire system often hinges on the correct implementation of signature verification and the secure management of the underlying cryptographic keys. Unfortunately, common implementation oversights and misunderstandings of the JWT specification have led to a persistent stream of vulnerabilities.

This guide aims to provide a deep dive into the practical aspects of JWT security for experienced application security professionals. We'll explore the fundamental mechanics, common attack vectors, detection strategies, and robust prevention measures. Understanding these nuances is critical for building and securing systems that rely on JWTs for authentication and authorization.

Core Mechanics: Structure, Signing, and Verification

A JWT is fundamentally a string composed of three parts, separated by dots (.), each base64url-encoded:

  1. Header: Contains metadata about the token, most importantly the signing algorithm (alg) and token type (typ). For example: {"alg": "HS256", "typ": "JWT"} [1][2].
  2. Payload: Contains the claims, which are statements about an entity (typically the user) and additional data. These can be registered claims (like iss for issuer, exp for expiration, aud for audience), public claims, or private claims. For example: {"sub": "1234567890", "name": "John Doe", "admin": true} [3][2].
  3. Signature: Generated by taking the encoded header, the encoded payload, and a secret or private key, and applying the algorithm specified in the header. This signature ensures the token has not been tampered with and was issued by the expected party. The signature is also base64url-encoded [2][1].

The overall structure is base64UrlEncode(header) + "." + base64UrlEncode(payload) + "." + base64UrlEncode(signature).

Signing Process (Simplified):


signature = ALGORITHM.Sign( base64UrlEncode(header) + "." + base64UrlEncode(payload), secretOrPrivateKey )

[4][5]

Verification Process (Simplified):


# 1. Decode header and payload header = base64UrlDecode(token.split('.')[0]) payload = base64UrlDecode(token.split('.')[1])

# 2. Determine algorithm from header algorithm = header.get('alg')

# 3. Verify signature using the algorithm and the secret/public key is_valid = ALGORITHM.Verify( base64UrlEncode(header) + "." + base64UrlEncode(payload), token.split('.')[2], # The signature secretOrPublicKey, algorithm=algorithm # Crucially, THIS MUST BE TRUSTED AND PINNED )

# 4. If valid, trust the payload if is_valid: # Process payload claims (exp, aud, iss, etc.) process(payload)

[6][7][1]

The critical point of failure often lies in step 3, specifically in how the algorithm is determined and how the secretOrPublicKey is used. Vulnerabilities arise when the application blindly trusts the alg value from the header or improperly handles cryptographic keys.

Notable Techniques and Attack Vectors

JWT vulnerabilities exploit weaknesses in implementation, cryptographic choices, and trust assumptions. The most prevalent attack vectors target signature verification and algorithm handling.

1. Signature Verification Failures

This is arguably the most common and impactful category of JWT vulnerabilities. It occurs when the server fails to properly validate the signature on an incoming token.


# Example of crafting a 'none' algorithm token (manually or with a tool) # Original token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIn0.signature_here # Modified token: eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkFkbWluIn0.

2. Algorithm Confusion Attacks

These attacks exploit the server's trust in the alg parameter specified in the JWT header. Instead of enforcing a specific, expected algorithm server-side, the vulnerable server uses the algorithm provided in the token header to select the verification method.


# Example of crafting an HS256 token signed with an RSA public key # (Requires attacker to obtain the server's public key and use a tool like jwt_tool or custom script) # Original header: {"alg": "RS256", "typ": "JWT", "kid": "some-key-id"} # Modified header: {"alg": "HS256", "typ": "JWT", "kid": "some-key-id"} # Payload: {"sub": "attacker", "admin": true} # Signature: Generated using HMAC-SHA256 with the server's public key as the secret.

3. Weak Secrets and Key Management

For symmetric algorithms like HS256, HS384, and HS512, the security relies entirely on the secrecy and strength of the shared secret key. Weak or compromised keys are a direct path to token forgery.


# Example using jwt_tool to crack an HS256 token with a weak secret # python3 jwt_tool.py <JWT_TOKEN> -C -d /path/to/wordlist.txt

4. Header Parameter Injection and Manipulation

Certain JWT header parameters, if not properly validated by the server, can be manipulated to achieve various attacks.


# Example of kid path traversal to /dev/null # Original header: {"alg": "HS256", "typ": "JWT", "kid": "some_actual_key_id"} # Modified header: {"alg": "HS256", "typ": "JWT", "kid": "../../../../../../../proc/self/getPrototypeOf"}

5. Claim Tampering and Validation Issues

Even if the signature is valid, the claims within the payload must be correctly validated by the server.

6. Client-Side Storage Vulnerabilities

How JWTs are stored on the client-side significantly impacts security, particularly against Cross-Site Scripting (XSS) attacks.

7. Other Vulnerabilities

Detection and Prevention

Securing JWT implementations requires a multi-layered approach, focusing on robust validation, secure key management, and secure transmission/storage.

1. Rigorous Signature Verification

2. Secure Key Management

3. Comprehensive Claim Validation

4. Secure Transmission and Storage

5. Input Validation for Header Parameters

Tooling for JWT Security Analysis

A robust set of tools is essential for identifying and exploiting JWT vulnerabilities. Many of these tools automate common attack patterns and provide insights into token structures.

Recent Developments and Emerging Threats

The JWT security landscape is constantly evolving, with new vulnerabilities and attack techniques being discovered. Staying abreast of these developments is crucial for effective defense.

Where to Go Deeper

For continued learning and hands-on practice, the following resources are invaluable:

Sources cited in this guide

  1. JSON Web Token Attacks and Vulnerabilities — Acunetix — acunetix.com
  2. Can Snyk Detect JWT Security Issues? — snyk.io
  3. Two Ways To Mess Up Your JWT Safety Net In Your Own Lab. — infosecwriteups.com
  4. The Ultimate Guide to JWT Vulnerabilities and Attacks — pentesterlab.com
  5. JWT Security Guide: Best Practices & Implementation (Gupta Deepak) — guptadeepak.com
  6. JWT Authentication: Structure, Attacks, and Why Weak Signature Validation Gets You Pwned — kashifsec.medium.com
  7. I made a full JWT hacking tutorial + testing suite — hakluke.com
  8. Detecting JWT Security Issues — snyk.io
  9. OWASP WSTG: Testing JSON Web Tokens — owasp.org
  10. JWT attacks | Web Security Academy — portswigger.net
  11. Insecure JSON Web Tokens (The Hacker Recipes) — thehacker.recipes
  12. JWT Authentication Bypass Using alg:none - CTF Writeup — medium.com
  13. JWT Algorithm Confusion Attacks: CVE-2026-22817 Fix Guide — dev.to
  14. PortSwigger KB: JWT none algorithm supported — portswigger.net
  15. PayloadsAllTheThings: JSON Web Token — github.com
  16. These are the security issues with JWT — scip.ch
  17. Known Exploits and Attacks (jwt_tool Wiki) — github.com
  18. Intigriti: Exploiting JWT vulnerabilities — advanced exploitation guide — intigriti.com
  19. Revisiting JWT Token Forgery Attack on Recent Bounty Target — infosecwriteups.com
  20. Detecting CVE-2026-0265 at Scale: PAN-OS CAS Authentication Bypass — bishopfox.com
  21. CVE-2026-34950 fast-jwt: Incomplete Fix for CVE-2023-48223 — endorlabs.com
  22. CVE-2026-22817: JWT Algorithm Confusion in Hono — dev.to
  23. How JWT Libraries Block Algorithm Confusion: Code Review Lessons — pentesterlab.com
  24. JWT authentication bypass via algorithm confusion (siunam) — siunam321.github.io
  25. JWT Algorithm Confusion Attack: Two Active CVEs in 2026 — tools.pinusx.com
  26. JWT Algorithm Confusion: Turning RS256 Tokens into HS256 Disasters — medium.com
  27. JWT Vulnerabilities List: 2026 Security Risks & Mitigation Guide (Red Sentry) — redsentry.com
  28. CVE-2024-33663: Python-jose Algorithm Confusion — sentinelone.com
  29. JWT Signature Bypass via unvalidated jku parameter — invicti.com
  30. WorkOS: JWT algorithm confusion attacks explained — workos.com
  31. PentesterLab: Another JWT Algorithm Confusion Vulnerability (CVE-2024-54150) — pentesterlab.com
  32. ticarpi/jwt_tool: A toolkit for testing, tweaking and cracking JSON Web Tokens — github.com
  33. Algorithm confusion attacks | Web Security Academy — portswigger.net
  34. Python-JOSE Security Risk: CVE-2024-33663 Explained — ethicalhacking.uk
  35. CVE-2026-23993: JWT Authentication Bypass in HarbourJwt via Unknown alg — pentesterlab.com
  36. Top 3 security best practices for handling JWTs — snyk.io
  37. JWT Security Best Practices for 2025 (JWT.app) — jwt.app
  38. Hacker Tools: JWT_Tool — intigriti.com
  39. Cracking JWT Keys - Authentication Lab — authlab.digi.ninja
  40. Lab: JWT authentication bypass via weak signing key — portswigger.net
  41. brendan-rius/c-jwt-cracker: JWT brute-force cracker in C — github.com
  42. mazen160/jwt-pwn: Security testing scripts for JWT — github.com
  43. Introducing CookieMonster: a tool for breaking stateless authentication — ian.sh
  44. JWT Token Lifecycle: Expiration, Refresh, and Revocation — skycloak.io
  45. CVE-2025-45768: PyJWT Information Disclosure Vulnerability — sentinelone.com
  46. JWT Forgery via unvalidated jku parameter (Invicti) — invicti.com
  47. JWT authentication bypass via kid header path traversal (siunam) — siunam321.github.io
  48. JWT Header Parameter Injections — medium.com
  49. JWT Signature Bypass via kid Path Traversal — invicti.com
  50. JWT Signature Bypass via kid SQL injection — invicti.com
  51. tuhin1729 Bug Bounty Methodology: JWT — github.com
  52. HackTricks: JWT vulnerabilities — book.hacktricks.xyz
  53. Lab: JWT authentication bypass via jku header injection — portswigger.net
  54. KathanP19/HowToHunt: JWT — github.com
  55. DontPanicO/jwtXploiter: A tool to test the security of JSON Web Tokens — github.com
  56. PortSwigger jwt-editor: Burp Suite extension for editing and signing JWTs — github.com
  57. Is Your JWT Implementation Safe, or Are You Leaking Sessions? — medium.com
  58. draft-ietf-oauth-rfc8725bis: JSON Web Token Best Current Practices — datatracker.ietf.org
  59. CVE-2024-53861: PyJWT Issuer Field Partial Match — vulert.com
  60. JWT Security Best Practices (Phase Two) — phasetwo.io
  61. Top 3 security best practices for handling JWTs — snyk.io
  62. RFC 8725: JSON Web Token Best Current Practices — ietf.org
  63. HackerOne: Argo CD JWT audience claim not verified — hackerone.com
  64. JWT (Json Web Token) Audience aud versus Client_Id - What's the difference? — stackoverflow.com
  65. Understanding JWT Security and Common Vulnerabilities (secops) — secops.group
  66. Vaadata: JWT vulnerabilities, common attacks and security best practices — vaadata.com
  67. Curity: JWT Security Best Practices — curity.io
  68. Authentication Explained: When to Use Basic, Bearer, OAuth2, JWT & SSO | daily.dev — app.daily.dev
  69. Stolen Access Tokens: Stopping Someone Else From Using a Token — medium.com
  70. Stop Storing JWTs in localStorage: React Auth with Refresh Tokens and httpOnly Cookies — medium.com
  71. Where to Store the JSON Web Token (JWT)? — medium.com
  72. Proof of Concept for CVE-2026-29000 (pac4j-jwt) — github.com
  73. CVE-2026-29000: Authentication Bypass in pac4j-jwt — arcticwolf.com
  74. HackerOne: Critical vulnerability in JWE Specification — hackerone.com
  75. Smashing the token limit with overlapping fragments — portswigger.net
  76. jwt-hack: JSON Web Token Hack Toolkit (GitHub) — github.com
  77. Brute Forcing HS256 is Possible — auth0.com
  78. Attacking JWT authentication — sjoerdlangkemper.nl
  79. jwt_tool Attack Methodology wiki — github.com
  80. Working with JWTs in Burp Suite — portswigger.net
  81. JSON Web Token Attacker Burp extension — portswigger.net
  82. JWT Scanner Burp extension — portswigger.net
  83. dr34mhacks/jwtauditor: JWT Auditor – Analyze, break, and understand your tokens like a pro. — github.com
  84. CVE-2026-32597: PyJWT Information Disclosure Vulnerability — sentinelone.com
  85. python-jwt token forgery CVE-2022-39227 — github.com
  86. JWT Bomb in Python-JOSE CVE-2024-33664 — vicarius.io
  87. Severe Security Flaw Found in jsonwebtoken Library — thehackernews.com
  88. Auth0: Critical vulnerabilities in JSON Web Token libraries — auth0.com
  89. JWTweak v2.1: A Guided, Offline Toolkit for Modern JWT Attacks — infosecwriteups.com
  90. Analyzing Broken User Authentication Threats to JWTs — Akamai — akamai.com
  91. JWT Pentest Book (six2dez) — pentestbook.six2dez.com
  92. JWT Pentest Checklist (Cyber Frogy) — chintangurjar.com
  93. JWT Pentest Checklist v1.0 (Chintan Gurjar) — chintangurjar.com
  94. HackerOne #1210502: Jitsi Authentication Bypass (JWT) — hackerone.com
  95. HackerOne #2472798: Newspack Extended Access JWT bypass — hackerone.com
  96. JSON Web Token Vulnerabilities (0xn3va cheat sheet) — 0xn3va.gitbook.io
  97. Hacking JSON Web Tokens - Vickie Li — medium.com
  98. ctf-jwt-token: Vulnerability in early JWT node.js library (GitHub) — github.com
  99. HackerOne: Trint insecure client-side JWT generation — hackerone.com
  100. HackerOne: Linktree account takeover via improper JWT validation — hackerone.com
  101. JWT Attack Walk-Through - NCC Group — research.nccgroup.com
  102. A Practical Guide to Attacking JWT — redhuntlabs.com
  103. November CTF Challenge: Exploiting JWT vulnerabilities to achieve RCE — intigriti.com
  104. Golang JWT access restriction bypass vulnerability — snyk.io
  105. Stealing Microsoft Teams access tokens in 2025 — blog.randorisec.fr
  106. JWT vs PASETO: New Era of Token-Based Authentication — medium.com
  107. Securing OAuth 2.0 Token Exchange Flow with Keycloak — sgtm.medium.com
  108. All About Attacking JWT — medium.com
  109. JSON Web Tokens Vulnerabilities and Exploitation. — dk9510.medium.com
  110. JWT [JSON WEB TOKENS] [EXPLANATION & EXPLOITATION] (0x02) — medium.com
  111. The Wonderful World of Tokens and Claims: CWT — medium.com
📚 This guide is synthesized from the full text of resources curated in the JWT library, and refreshed as new material is added.