Repository navigation
Conversation
`isValidHmacSignature` now uses `crypto.timingSafeEqual`. It returns false when the signature is missing or its byte length differs, so malformed headers never throw. Refs INTER-2844
🦋 Changeset detectedLatest commit: 27a0008 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
🚀 Following releases will be created using changesets from this PR:@fingerprint/node-sdk@7.11.1Patch Changes
|
Contributor
Coverage report
Test suite run success142 tests passing in 32 suites. Report generated by 🧪jest coverage report action from 27a0008 Show full coverage report
|
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the constant-time webhook signature-validation change.
No open issues 🎉
What changed in this PR
Updates the Node SDK’s webhook signature validation to compare HMAC signatures in constant time while preserving existing acceptance behavior.
Changes:
- Uses
crypto.timingSafeEqualwith guards for undefined signatures and unequal byte lengths. - Adds regression tests for malformed signatures, multibyte input, multiple signatures, and constant-time comparison.
- Adds a patch-release changeset.
| File | Description |
|---|---|
tests/unit-tests/webhookTests.spec.ts |
Adds signature-validation and constant-time comparison regression tests. |
src/webhook.ts |
Replaces string equality with guarded constant-time comparison. |
.changeset/constant-time-webhook-signature.md |
Documents the webhook security fix for a patch release. |
Review effort: Balanced
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
INTER-2844 | go-sdk#123 (same fix in the Go SDK)
Why
isValidWebhookSignaturecompared HMAC signatures with===, which can return as soon as a byte differs; it now compares them in constant time.Things to note
é) has a longer buffer, andtimingSafeEqualwould throw on it.v1header entry without=gives anundefinedsignature, which now returnsfalseearly instead of throwing inBuffer.from.Verification
===.v1and multibyte tests fail if the length check uses string length or skips theundefinedguard.Change outline