Why Comparing Webhook HMAC Signatures with === Leaks Secrets
Developers verifying webhook signatures from services like Stripe or GitHub often compare HMAC-SHA256 digests using the === operator. Because standard string equality stops at the first mismatched byte, response timing differences can let an attacker guess a valid signature byte by byte. The article recommends constant-time comparison, such as Node's timingSafeEqual or a simple XOR accumulator that works in Web Crypto environments. It also advises hashing the raw request body rather than re-serialized JSON, and enforcing a timestamp window to block replay attacks.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in