Every backend engineer has been there: an API returns 401 Unauthorized, so you grab the Authorization: Bearer token from DevTools to inspect exp, aud, and scope.
The problem is that a signed JWS token (RFC 7515) is Base64URL-encoded plaintext, not encrypted ciphertext—and until exp passes, it is a live bearer credential. Pasting staging or production JWTs (or an HMAC test secret) into a remote site with analytics or server logging exposes both claims and active API access.
Modern browsers already ship everything needed to decode and cryptographically verify JWTs locally via the W3C Web Crypto API (crypto.subtle)—with zero npm dependencies and zero network traffic.
1. The Subtle Detail That Makes Web Crypto Ideal for ES256
OpenSSL encodes ECDSA signatures as variable-length ASN.1 DER (SEQUENCE { r INTEGER, s INTEGER }), whereas JWS (RFC 7515) mandates fixed-width IEEE P1363 raw concatenation (r || s, 64 bytes for P-256 ES256, 96 bytes for P-384 ES384).
Browser crypto.subtle.verify({ name: "ECDSA", hash: "SHA-256" }, publicKey, sigBytes, signingInput) natively expects IEEE P1363 raw format. That means you can import a public JWK ({ kty: "EC", crv: "P-256", x, y }) or PEM SPKI public key and verify ES256, ES384, RS256, PS256, or HS256/384/512 directly in ~50 lines of vanilla JavaScript:
const key = await crypto.subtle.importKey( "jwk", publicJwk, { name: "ECDSA", namedCurve: "P-256" }, false, ["verify"] ); const valid = await crypto.subtle.verify( { name: "ECDSA", hash: "SHA-256" }, key, signatureBytes, new TextEncoder().encode(`${headerB64Url}.${payloadB64Url}`) ); 2. Five RFC 8725 JWT & OAuth Bugs Worth Auditing Automatically
Signature verification alone does not catch broken server-side validation logic:
| Vulnerability Class | Header / Claim Pattern | Hardened Fix (RFC 8725 / RFC 9700) |
|---|---|---|
alg: "none" & Algorithm Confusion | "alg": "none" or switching RS256 -> HS256 | Pin an explicit server-side algorithm allowlist per key type; never trust header.alg |
kid Injection | "kid": "../../etc/passwd" or SQL metacharacters | Validate kid against ^[A-Za-z0-9._-]{1,64}$ and map only against an in-memory JWKS dictionary |
jku / x5u SSRF & Embedded jwk | Untrusted key URLs inside the token header | Ignore caller-supplied key URLs; fetch keys exclusively from your pinned IdP JWKS endpoint |
Missing aud / iss Replay | Valid signature from shared IdP, wrong API target | Enforce exact iss, aud, and RFC 9068 typ: "at+jwt" checks on every resource server |
| Over-Long TTL & Broad OAuth Scopes | Missing exp, multi-day TTL, offline_access / * | Keep access tokens 5–15 min, rotate refresh tokens with reuse detection, and prefer DPoP (RFC 9449) or mTLS (RFC 8705) binding |
3. Try the Zero-Upload JWT & OAuth Security Inspector
I built a lightweight (~7.0 KB gzipped), zero-backend client-side inspector that decodes JWS/JWE structures, verifies HS256/384/512, RS256/384/512, PS256/384/512, and ES256/384 via native Web Crypto, includes a 1-click Generate Live ES256 Keypair + Token test button, and audits alg:none, kid, jku, clock skew, TTL, and high-privilege OAuth scopes with JSON/CSV report export:
Launch the offline tool & full RFC 8725 guide: Offline JWT, Session Token & OAuth Claims Security Inspector
Building automation around authentication, TLS, or local inference? Query our open CC-BY-4.0 JSON datasets (CORS: *):
- OpenSSH Algorithm & PQC KEX Matrix (
/api/v1/ssh-algorithm-matrix.json) - Post-Quantum TLS 1.3 Wire Sizes (
/api/v1/pqc-tls-wire-sizes.json) - Local LLM VRAM Matrix (
/api/v1/llm-vram-matrix.json)
Written and prepared by Kshitij Gupta. Originally published at The Infosiast.
