SIGN IN SIGN UP

fix: guard HMAC comparison on decoded length in HmacValidator

The webhook validators compared the base64 *string* length before calling
timingSafeEqual, but timingSafeEqual requires equal *decoded buffer* length.
Two base64 strings of equal character length can decode to different byte
lengths (e.g. a 44-char unpadded signature decodes to 33 bytes while a real
SHA-256 HMAC decodes to 32), so a crafted signature made timingSafeEqual
throw an unhandled TypeError instead of the validators returning false.

Add a shared constant-time `secureCompare` that guards on the decoded buffer
length first, and use it in validateHMAC, validateHMACSignature and
validateBankingHMAC. Mirrors the earlier NexoCrypto length-guard fix (#1703).
C
Cedric Conday committed
98b5bb0e2a45c21e0170e609eba8782335fef732
Parent: f70cd7f
Committed by Beppe Catanese <1771700+gcatanese@users.noreply.github.com> on 7/13/2026, 10:35:20 AM