Repository navigation
fix: use constant-time comparison for webhook HMAC signatures - #360
Merged
Merged
Conversation
validate_webhook compared the computed and provided signatures with ==, which can leak timing information. Use OpenSSL.secure_compare, with a constant-time byte fallback for Ruby 2.7, whose bundled openssl does not have it.
There was a problem hiding this comment.
🟡 Changes recommended
The Ruby 2.7 compatibility path lacks a same-length mismatch test, leaving regressions in its bytewise XOR comparison undetected.
1 open issue
What changed in this PR
Updates webhook HMAC validation to use constant-time signature comparison, including Ruby 2.7 compatibility, and releases version 7.8.3.
Changes:
- Added secure comparison with a constant-time fallback.
- Updated version and changelog entries.
| File | Description |
|---|---|
| VERSION | Bumps the library version to 7.8.3. |
| lib/easypost/util.rb | Secures webhook signature validation. |
| CHANGELOG.md | Documents the security fix. |
Review effort: Lite
Stephen Watkins (stephenjwatkins)
approved these changes
Dec 4, 2026
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.

Description
validate_webhookcompared signatures with==, which can leak timing information. It now uses a privatesecure_comparehelper that callsOpenSSL.secure_compare, or falls back to a constant-time byte compare on Ruby 2.7, whose bundled openssl (2.1.x) doesn't have it. ATODO:marks the fallback for removal once we only support Ruby 3.0+.The other six libs already use constant-time compares. Bumps the version to 7.8.3 with a dated changelog header.
Closes #359
Testing
just lintpasses, and the full spec suite passes (212 examples, 0 failures).TODO:to remove it along with the fallback. Ruby 2.7 isn't installed locally, so CI's 2.7 job covers the fallback natively.Pull Request Type