Defensive Audit

JWT Security Checker (Defensive Audit)

Run a defensive static inspection of any JWT header and payload locally in your browser without providing a secret key. Detect risky settings like alg: none, jku/x5u/jwk header parameters, kid path-traversal patterns, missing exp/iss/aud claims, exposed secrets, and oversized tokens.

How It Works

Many high-severity JWT vulnerabilities stem from token configuration and header parsing flaws rather than weak encryption math. This defensive security checker decodes only the Base64URL header and payload inside your browser—requiring no shared secret or private key—and scores common RFC 7515/7519 misconfigurations without performing brute force, cracking, or exploit-token generation.

The static analyzer audits dangerous header parameters (alg: "none", missing alg, empty signature segments, untrusted jku/x5u remote URLs, inline jwk/x5c key material, and kid path-traversal or SQL/shell injection characters), checks essential time and scope claims (exp, nbf, iss, aud, sub, jti, future iat, and excessive lifetimes), flags sensitive credentials or PII stored in plaintext Base64URL payloads, and warns when total token byte length exceeds 4 KB cookie or 8 KB HTTP header limits.

Step-by-Step Guide & Real Example

Inspect any sample or staging token in four steps to spot structural weaknesses and follow actionable remediation links.

1. Paste a JWT or load the built-in samples

Drop any compact three-part JWT into the textarea or compare the prebuilt risky and well-configured test tokens to observe score behavior.

2. Review severity counts and defensive score

Check critical and high findings first, such as unsecured alg: "none", empty signatures, or dynamic jku/x5u/jwk key headers.

3. Audit kid hygiene, claim completeness, and PII

Confirm exp, iss, aud, and sub are present and verify that passwords, API keys, or personal data are absent from unencrypted JWS payloads.

4. Apply each targeted fix and re-verify

Follow remediation links straight to the JWT Signature Verifier, RSA/EC Key Pair Generator, or Timestamp Converter to validate your updated token.

Worked Example: Detecting Header & Payload Misconfigurations

Decoded Header & Payload Snippet:Header: {"alg":"none","kid":"../../etc/passwd","jku":"https://untrusted.example/jwks.json"} | Payload: {"sub":"user-42","password":"demo-only-plaintext-secret"}
Flagged Security Findings:Critical Risk · 3 Critical/High findings: alg: "none" (Critical), kid path traversal (Critical), jku header (High), missing exp/aud/iss, sensitive "password" claim (High).

Remember: JWS payloads are Base64URL encoded, NOT encrypted. Every intermediate proxy, browser log, and user can decode payload fields instantly.

Common Mistakes & Security Notes

Passing header.kid straight into file paths or SQL queries

An unvalidated kid containing ../ or quotes lets attackers read arbitrary files as HMAC secrets or inject SQL. Always constrain kid to an allowlisted lookup map or regex ^[a-zA-Z0-9_-]+$.

Dereferencing untrusted jku or x5u URLs from unverified headers

Allowing verifiers to fetch arbitrary remote JWK URLs invites Server-Side Request Forgery (SSRF) and attacker-hosted key substitution.

Treating Base64URL JWT payloads as confidential storage

Standard signed JWS tokens hide nothing. Never place passwords, client secrets, API keys, or sensitive PII inside unencrypted JWT claims.

Issuing non-expiring or bloated multi-kilobyte tokens

Omitting exp prevents natural credential expiration, while giant role arrays push Cookie headers past 4,096 bytes or trigger HTTP 431 errors at 8 KB proxies.

JWT Decoder vs Security Checker vs Signature Verifier

CapabilityJWT DecoderJWT Security CheckerJWT Signature Verifier
Reads header & payload JSONYesYesYes
Requires secret or public keyNoNoYes
Audits jku/x5u/kid/PII/sizeBasic warningsFull scored checklistSignature & time claims
Proves cryptographic trustNo (decode only)No (static config audit)Yes (via WebCrypto)

Code Snippets (Node.js, Python, Java)

Enforce the same defensive header and claim invariants on your backend before trusting decoded token metadata:

Node.js (TypeScript)
export function assertSafeJwtPolicy(hdr: Record<string, unknown>, pay: Record<string, unknown>) {
  if (!hdr.alg || String(hdr.alg).toLowerCase() === 'none') throw new Error('alg none');
  if ('jku' in hdr || 'x5u' in hdr || 'jwk' in hdr) throw new Error('Dynamic key header');
  if (typeof hdr.kid === 'string' && !/^[a-zA-Z0-9_-]+$/.test(hdr.kid)) throw new Error('Bad kid');
  if (typeof pay.exp !== 'number' || typeof pay.aud !== 'string') throw new Error('Missing claims');
}
Python
import re

SAFE_KID = re.compile(r"^[A-Za-z0-9_-]+$")
def check_jwt_hygiene(hdr: dict, pay: dict) -> list[str]:
    issues = []
    if str(hdr.get("alg", "")).lower() in ("", "none"): issues.append("Unsafe alg")
    if any(k in hdr for k in ("jku", "x5u", "jwk")): issues.append("Header injection")
    if isinstance(hdr.get("kid"), str) and not SAFE_KID.match(hdr["kid"]): issues.append("Unsafe kid")
    if not all(c in pay for c in ("exp", "iss", "aud")): issues.append("Missing claims")
    return issues
Java
Pattern SAFE_KID = Pattern.compile("^[A-Za-z0-9_-]+$");
if (alg == null || "none".equalsIgnoreCase(alg)) throw new SecurityException("alg none");
if (hasJkuOrX5u) throw new SecurityException("Remote key header");
if (kid != null && !SAFE_KID.matcher(kid).matches()) throw new SecurityException("Bad kid");

Frequently Asked Questions

Does a score of 100/100 mean the token signature is authentic?

No! This defensive checker inspects structural configuration (headers, claims, key hygiene, and payload privacy) without checking cryptographic signatures. Always pair this check with server-side signature verification.

Why are jku, x5u, and inline jwk headers flagged as high risk?

Because they reside in the unverified token header. If a verifier fetches a key from an attacker-controlled jku URL or trusts an inline jwk, attackers can self-sign arbitrary tokens.

Can this tool crack my JWT secret or brute-force weak signatures?

Never. It is strictly a defensive static configuration checker—no dictionary attacks, brute force, or forged token generation exist anywhere in this tool.

Why does the checker warn about email or password fields in a JWT payload?

Standard JWS tokens only Base64URL-encode payloads without encryption. Credentials like passwords must never enter tokens, and minimizing PII prevents leaks across logs and proxies.

Why does token byte length matter for web applications?

Many browsers cap individual cookies near 4,096 bytes and reverse proxies such as Nginx reject total HTTP request headers exceeding 8,192 bytes with 400 or 431 errors.

Are inspected production or staging JWTs transmitted to any backend?

No. Parsing and rule checks execute 100% inside local browser memory with zero network calls.

About the author

Avada Labs builds free developer tools, including this site, with six years of experience in web development and online tools. Projects and source code are on GitHub.

JWT Security Checker – Audit Header & Claims Locally