Skip to content

fix: prevent timing attack in webhook signature verification#469

Open
vaibhavchopra-wq wants to merge 6 commits into
masterfrom
fix/timing-attack-vulnerability
Open

fix: prevent timing attack in webhook signature verification#469
vaibhavchopra-wq wants to merge 6 commits into
masterfrom
fix/timing-attack-vulnerability

Conversation

@vaibhavchopra-wq
Copy link
Copy Markdown

@vaibhavchopra-wq vaibhavchopra-wq commented Apr 22, 2026

Replace vulnerable string comparison (===) with crypto.timingSafeEqual() to prevent timing-based side-channel attacks on signature verification.

The === operator short-circuits on first mismatch, allowing attackers to measure response times and potentially guess signatures character by character. timingSafeEqual() always compares all bytes in constant time regardless of input.

Note :- Please follow the below points while attaching test cases document link below:

- If label Tested is added then test cases document URL is mandatory.

- Link added should be a valid URL and accessible throughout the org.

- If the branch name contains hotfix / revert by default the BVT workflow check will pass.

Test Case Document URL
https://docs.google.com/document/d/1RA9GcYqNGnUcQjIYAF0jxBa-DYw_iHRqMMMe-t_c3IE/edit?usp=sharing

Replace vulnerable string comparison (===) with crypto.timingSafeEqual()
to prevent timing-based side-channel attacks on signature verification.

The === operator short-circuits on first mismatch, allowing attackers
to measure response times and potentially guess signatures character
by character. timingSafeEqual() always compares all bytes in constant
time regardless of input.
- Compare raw HMAC bytes (32 bytes) instead of hex strings (64 chars)
- Decode incoming signature from hex to raw bytes
- Handle invalid hex input gracefully with try/catch
Buffer.from(str, 'hex') never throws - it returns empty/partial Buffer
on invalid hex input. The length check below catches this case.
@vaibhavchopra-wq vaibhavchopra-wq marked this pull request as ready for review April 29, 2026 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant