fix(webhooks): raise ValueError for non-ASCII signature in Webhooks.verify - #290
Merged
dielduarte merged 4 commits intoOct 3, 2026
Merged
dielduarte merged 4 commits into
dielduarte merged 4 commits into
Conversation
…n-ascii-signature
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #290 +/- ##
===========================================
+ Coverage 82.66% 97.04% +14.37%
===========================================
Files 4 74 +70
Lines 75 4266 +4191
===========================================
+ Hits 62 4140 +4078
- Misses 13 126 +113 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
dielduarte
approved these changes
Oct 3, 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.
Summary
Webhooks.verifyraisesTypeErrorinstead ofValueErrorwhen thesvix-signatureheader contains a non-ASCII character, becausehmac.compare_digestrejects non-ASCIIstrarguments. The fix compares the UTF-8 encoded bytes, so a malformed signature falls through toValueError("no matching signature found"), the documented failure mode.Changes
hmac.compare_digestinresend/webhooks/_webhooks.py.test_verify_non_ascii_signaturetotests/webhooks_test.py.Testing
TypeError) and passes after.pytest tests: 700 passed.flake8 --max-line-length=130 resendis clean.Summary by cubic
Update
Webhooks.verifyso a non-ASCIIsvix-signatureheader raises the documentedValueError("no matching signature found")instead of aTypeError.hmac.compare_digestso malformed input falls through to the documented failure mode, covering both non-ASCII characters and unpaired surrogates that arrive viasurrogateescapedecoding.Written for commit e514de0. Summary will update on new commits.