Module lessons (4/4)
Verifying & Signing JWTs with Web Crypto
Demonstrate signature invalidation on payload tampering and implement asynchronous HMAC-SHA256 JWT verification with Web Crypto.
What you'll learn in this lesson
- Observe cryptographic integrity failure the moment a single bit of a signed JWT payload changes.
- Verify HMAC-SHA256 JWT signatures end-to-end in the browser and Node using Web Crypto (
crypto.subtle). - Issue server-signed HS256 JWTs with
crypto.subtle.signenforcing minimum secret length and server-controllediat/explifetimes.
Overview
Structural header validation stops alg: 'none', yet an attacker can still change 'role': 'member' to 'role': 'admin' and attach arbitrary signature bytes unless the backend cryptographically verifies the HMAC tag over encodedHeader + '.' + encodedPayload.
Study the full sign-and-verify lifecycle with Web Crypto:
Sections covered in this lesson
- 11. Real HS256 Signing & Constant-Time Verification in Web Crypto
- 22. Interactive Explorer: Signature Verification & Expiry
- 33. Progressive Labs: Warm-Up → Attack → Defend → Harden
- 44. Checkpoints & Code Review
Unlock "Verifying & Signing JWTs with Web Crypto" and the full Application & Web Security curriculum
Demonstrate signature invalidation on payload tampering and implement asynchronous HMAC-SHA256 JWT verification with Web Crypto.
Unlock all 6 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.
- Instant access to all advanced modules in Application & Web Security plus 17 more courses
- Hands-on browser exercises with automated test suites and solutions
- 14-day money-back guarantee processed via Paddle.com
14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.