testing-jwt-token-security
Assessing JSON Web Token implementations for cryptographic weaknesses, algorithm confusion attacks, and authorization bypass vulnerabilities during security engagements.
By mukul975 · 459 installs
npx skills add mukul975/anthropic-cybersecurity-skills --skill testing-jwt-token-security
Source repository · Upstream listing
Testing JWT Token Security
When to Use
During authorized penetration tests when the application uses JWT for authentication or authorization
When assessing API security where JWTs are passed as Bearer tokens or in cookies
For evaluating SSO implementations that use JWT/JWS/JWE tokens
When testing OAuth 2.0 or OpenID Connect flows that issue JWTs
During security audits of microservice architectures using JWT for inter service authentication
Prerequisites
Authorization : Written penetration testing agreement for the target
jwt tool : JWT attack toolkit ( pip install jwt tool or git clone https://github.com/ticarpi/jwt tool.git )
Burp Suite Professional : With JSON Web Token extension from BApp Store
Python PyJWT : For scripting custom JWT attacks ( pip install pyjwt )
Hashcat : For brute forcing HMAC secrets ( apt install hashcat )
jq : For JSON processing
Target JWT : A valid JWT token from the application
Workflow
Step 1: Decode and Analyze the JWT Structure
Extract and examine the header, payload, and signature components.
Step 2: Test Algorithm None Attack
Attempt to forge tokens by setting the algorithm to "none".
Step 3: Test Algorithm Confusion (RS256 to HS256)
If the server uses RS256, try switching to HS256 and signing with the public key.
Step 4: Brute Force HMAC Secret
If HS256 is used, attempt to crack the signing secret.
Step 5: Test JWT Claim Manipulation and Injection
Modify JWT claims to escalate privileges or bypass authorization.
Step 6: Test Token Lifetime and Revocation
Assess token expiration enforcement and revocation capabilities.
Key Concepts
Concept Description
Algorithm None Attack Removing signature verification by setting alg to none
Algorithm Confusion Switching from RS256 to HS256 and signing with the public key as HMAC secret
HMAC Brute Force Cracking weak HS256 signing secrets using wordlists or brute force
JKU/x5u Injection Pointing JWT header URLs to attacker controlled key servers
KID Injection Exploiting SQL injection or path traversal in the Key ID header parameter
Claim Tampering Modifying payload claims (role, sub, permissions) after compromising the signing key
Token Revocation The ability (or inability) to invalidate tokens before their expiration
JWE vs JWS JSON Web Encryption (confidentiality) vs JSON Web Signature (integrity)
Tools & Systems
Tool Purpose
jwt tool Comprehensive JWT testing toolkit with automated attack modules
Burp JWT Editor Burp Suite extension for real time JWT manipulation
Hashcat GPU accelerated HMAC secret brute forcing (mode 16500)
John the Ripper CPU based JWT secret cracking
PyJWT Python library for programmatic JWT creation and manipulation
jwt.io Online JWT decoder for quick analysis (do not paste production tokens)
Common Scenarios
Scenario 1: Algorithm None Bypass
The JWT library accepts "alg":"none" tokens, allowing any user to forge admin tokens by simply removing the signature and changing the algorithm header.
Scenario 2: Weak HMAC Secret
The application uses HS256 with a dictionary word as the signing secret. Hashcat cracks the secret in minutes, enabling complete token forgery and admin impersonation.
Scenario 3: Algorithm Confusion on SSO
An SSO provider uses RS256 but the consumer application also accepts HS256. The attacker signs a forged token with the publicly available RSA public key using HS256.
Scenario 4: KID SQL Injection
The kid header parameter is used in a SQL query to look up signing keys. Injecting ' UNION SELECT 'attacker secret' allows the attacker to control the signing key.
Output Format