Timing side-channel in HMAC verification via memcmp() in crypto_hmac.cc leads to potential MAC forgery
HMAC verification in Node.js used a non-constant-time comparison, potentially leaking timing information proportional to matching bytes. Under certain threat models, this could serve as a timing oracle to infer HMAC values.
- Triaged in 22 hours
- Fixed in 51 days
- Disclosed after 57 days
Summary by the program
A flaw in Node.js HMAC verification uses a non-constant-time comparison when validating user-provided signatures, potentially leaking timing information proportional to the number of matching bytes. Under certain threat models where high-resolution timing measurements are possible, this behavior could be exploited as a timing oracle to infer HMAC values.
Node.js already provides timing-safe comparison primitives used elsewhere in the codebase, indicating this is an oversight rather than an intentional design decision.
This vulnerability affects 20.x, 22.x, 24.x, and 25.x.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the HMAC verification used a standard memory comparison that returns early on the first mismatched byte instead of a constant-time comparison.
Impact
Under certain threat models where high-resolution timing measurements are possible, this could be exploited as a timing oracle to infer HMAC values, though the text does not demonstrate a practical forgery.
What the attacker needed
High-resolution timing measurements
The fix
The comparison should be replaced with a constant-time comparison primitive, which Node.js already provides elsewhere in the codebase.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
An HMAC checks a message has not been tampered with using a secret key. The check compared values in a way that was not constant-time, potentially leaking timing information proportional to matching bytes. An attacker who can measure time precisely might use that to infer HMAC values.
What is Crypto?
Encryption, signatures, randomness or certificate checks that do not protect what they claim to.