Skip to main content
Module 4 · Lesson 4 of 415/42 in the course~16 min
Module lessons (4/4)

Verifying & Signing JWTs with Web Crypto

Lesson preview6 hands-on exercises readyApplication & Web Security · Module 4 — Authentication, Sessions, JWT & Access Control

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.sign enforcing minimum secret length and server-controlled iat / exp lifetimes.

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

  1. 11. Real HS256 Signing & Constant-Time Verification in Web Crypto
  2. 22. Interactive Explorer: Signature Verification & Expiry
  3. 33. Progressive Labs: Warm-Up → Attack → Defend → Harden
  4. 44. Checkpoints & Code Review
Pro Lesson · Module 4 — Authentication, Sessions, JWT & Access Control

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.