Repository navigation
Fix webhook signature validation crashes on malformed headers - #1245
Open
knowprasad wants to merge 1 commit into
Open
knowprasad wants to merge 1 commit into
knowprasad wants to merge 1 commit into
Conversation
Signed-off-by: prsdx <prsdx.dev@gmail.com>
knowprasad
requested review from
canihavesomecoffee and
thealphadollar
as code owners
October 24, 2026 17:16
|
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
In
utility.py,is_valid_signature(x_hub_signature, data, private_key)previously unpackedx_hub_signature.split('=', 1)and accessedhashlib.__dict__.get(hash_algorithm)without input and type guards.If a webhook request arrives with a missing signature header, a header lacking
=, an unknown hash algorithm, or a non-callable attribute,is_valid_signaturewould crash with unhandled exceptions (AttributeError,ValueError,TypeError), causing a 500 server error instead of returningFalsefor the caller to abort gracefully.Changes
x_hub_signaturestring type and presence of=before splitting.hash_algorithm in hashlib.algorithms_availableand verifiedcallable(getattr(hashlib, hash_algorithm, None)).dataandprivate_key.hmac.newin try-except for(ValueError, TypeError)as a fallback guard.tests/test_utility.pycovering valid signatures, digest mismatches, missing/empty headers, malformed signatures without=, unknown algorithms, and non-callable attribute names.