본문으로 건너뛰기
cccskills
무료GitHub에 공개

jwt-misconfig

Use when testing JWT-based authentication for algorithm confusion, alg:none bypass, weak HMAC secrets, missing expiration, kid parameter injection, and token storage in localStorage. Trigger on: Authorization: Bearer tokens, JWTs in cookies, any base64url encoded header.payload.signature pattern, OAuth2 access tokens, API authentication tokens, SSO tokens, JWKS endpoints. Detects RS256→HS256 confusion, public key as HMAC secret, unverified kid values used in file reads or SQL queries, and JWT cracking with short secrets.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(1)

  • SKILL.md5.5 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

JWT Misconfiguration

What Is Broken and Why

JWTs that accept alg: none, trust the algorithm declared in the token header, or use guessable HMAC secrets allow attackers to forge arbitrary tokens — including admin-level claims — without knowing any signing key. Algorithm confusion attacks exploit servers that accept both RS256 (asymmetric) and HS256 (symmetric): the attacker signs with the public key (which is public) using HS256 and the server verifies it as a valid HMAC.

Key Signals

  • Authorization: Bearer <base64url>.<base64url>.<base64url> in requests
  • JWTs stored in cookies (check httpOnly, Secure, SameSite flags)
  • JWKS endpoint at /.well-known/jwks.json or /oauth/certs (exposes public key)
  • alg field in JWT header — watch for HS256, RS256, none
  • kid (Key ID) field in JWT header — check for path traversal or SQLi
  • Short or dictionary-based HMAC secret (crack with hashcat)

Methodology

  1. Decode the JWT header and payload (base64url decode each part).
  2. Note the alg value; attempt to change it to none and remove signature.
  3. If alg is RS256, fetch the public key from JWKS endpoint; re-sign with HS256 using the public key as the HMAC secret.
  4. If alg is HS256, attempt to crack the secret with hashcat or jwt_tool.
  5. Check kid value — test for path traversal (../../dev/null), SQLi, or SSRF.
  6. Modify exp claim to far-future timestamp; attempt to use expired tokens.
  7. Escalate claims: change role, admin, sub, userId in payload after forging.

Payloads & Tools

# jwt_tool — Swiss army knife for JWT attacks
pip install jwt_tool
jwt_tool TOKEN -X a           # alg:none attack
jwt_tool TOKEN -X s           # algorithm confusion (RS256→HS256)
jwt_tool TOKEN -C -d wordlist.txt  # crack HMAC secret

# hashcat JWT cracking
hashcat -a 0 -m 16500 TOKEN wordlist.txt

# Manual alg:none
# 1. Decode header: {"alg":"RS256","typ":"JWT"}
# 2. Change to:     {"alg":"none","typ":"JWT"}
# 3. Re-encode and append empty signature: header.payload.
# (trailing dot is required)

# kid SQLi
{"kid": "' UNION SELECT 'attacker_secret' --", "alg":"HS256"}
# Sign token with 'attacker_secret'

# kid path traversal (sign with empty string)
{"kid": "../../dev/null", "alg":"HS256"}
# /dev/null reads as empty → sign with empty string ""

Bypass Techniques

AttackTechnique
alg: noneChange header alg to none, drop signature, keep trailing dot
Algorithm confusionFetch RS256 public key; use it as HS256 HMAC secret
Weak secretCrack short/dictionary HMAC with hashcat -m 16500
kid path traversalPoint kid to /dev/null or known empty file; sign with ""
kid SQLiInject SQL into kid to return attacker-controlled key from DB
Missing expIf no expiry check, reuse old tokens indefinitely
jku/x5u injectionPoint to attacker-hosted JWKS to supply own public key
Embedded JWKInject jwk into header containing attacker's own public key

Exploitation Scenarios

Algorithm confusion to admin: Setup → API uses RS256; JWKS endpoint public at /.well-known/jwks.json. Trigger → Fetch public key → re-sign token with HS256 using public key as secret → set "role":"admin" in payload. Impact → Full admin access without any private key.

alg:none on misconfigured library: Setup → Old version of JWT library doesn't reject alg: none. Trigger → Set alg: none, modify sub to another user's ID, remove signature. Impact → Arbitrary account takeover.

kid path traversal to RCE: Setup → kid is used to load key from filesystem without sanitization. Trigger → kid: "../../proc/self/fd/0" with socket input; or ../../tmp/evil. Impact → Attacker controls signing key; full token forgery.

False Positives

  • alg: none rejected with 401 — library properly validates algorithm.
  • RS256 server that only accepts RS256 (not HS256) — algorithm confusion not applicable.
  • JWKS endpoint present but server uses pinned key in code — jku/x5u injection blocked.

Fix Patterns

// Always whitelist algorithm — never derive from token header
jwt.verify(token, secret, { algorithms: ['HS256'] });

// For RS256: pin the public key in code, don't trust jku/jwk headers
jwt.verify(token, publicKeyPem, { algorithms: ['RS256'] });

// Always validate exp
const decoded = jwt.verify(token, secret, {
  algorithms: ['HS256'],
  ignoreExpiration: false  // default false — make it explicit
});

Related Skills

JWT attacks are a class of [[auth-bypass]] specific to token-based systems. kid SQLi chains into [[sql-injection]]; kid path traversal chains into [[path-traversal]]. Weak session management after JWT compromise connects to [[cookie-attacks]] and [[session-fixation]].

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Exploit pervasive logical flaws in Multi-Factor Authentication (MFA/2FA) implementations to bypass the secondary authentication challenge entirely. Techniques include response manipulation, referal spoofing, token reuse, and predictable backup codes.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ShulkwiSEC/bb-huge232026년 7월 11일 업데이트

401/403 bypass playbook. Use when encountering access-denied responses on admin panels, API endpoints, or restricted paths. Covers path manipulation, HTTP method tampering, header injection, protocol downgrade, and automated bypass tools.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ShulkwiSEC/bb-huge232026년 7월 11일 업데이트

Complete PortSwigger deep-dive with exact payloads for every lab variant including zero-day techniques

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ShulkwiSEC/bb-huge232026년 7월 11일 업데이트

Active Directory ACL abuse playbook. Use when exploiting misconfigured AD permissions including GenericAll, WriteDACL, DCSync rights, shadow credentials, LAPS reading, GPO abuse, and BloodHound-guided attack paths.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ShulkwiSEC/bb-huge232026년 7월 11일 업데이트

Execute AS-REP Roasting to extract and crack the NTLM hashes of Active Directory user accounts that have the "Do not require Kerberos preauthentication" flag explicitly enabled. This attack generates a recoverable Ticket Granting Ticket (TGT) without requiring the attacker to authenticate first.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ShulkwiSEC/bb-huge232026년 7월 11일 업데이트

AD Certificate Services attack playbook. Use when targeting misconfigured AD CS for privilege escalation via ESC1-ESC13 template abuse, NTLM relay to enrollment, CA officer abuse, and certificate-based persistence.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ShulkwiSEC/bb-huge232026년 7월 11일 업데이트

ShulkwiSEC의 스킬 모두 보기

이 스킬의 문제 신고