You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG]: WebhookSignatureValidator.validate raises TypeError for a non-ASCII v1 instead of InvalidWebhookSignatureErrorΒ #160
validate compares the hashes with hmac.compare_digest(computed, received_hash) on two str values (mercadopago/webhook/validator.py). compare_digest only accepts ASCII strings, so a v1 value with a non-ASCII character raises TypeError: comparing strings with non-ASCII characters is not supported instead of InvalidWebhookSignatureError. Anyone can POST to the webhook URL, so a handler that catches InvalidWebhookSignatureError as in docs/webhooks.md returns a 500 instead of rejecting the request. It still fails closed. The Node SDK had the same problem with a RangeError (#459 there), fixed in its #463.
β Expected Behavior
InvalidWebhookSignatureError with SignatureMismatch, like any other wrong signature.
β Actual Behavior
TypeError: comparing strings with non-ASCII characters is not supported.
A possible fix is to compare bytes (hmac.compare_digest(computed.encode(), received_hash.encode("utf-8"))) or to reject a non-hex v1 before comparing, with a test.
β Checklist
I have verified that I am using the latest SDK version
I have searched existing issues and this bug has not been reported
I have included a minimal code example to reproduce the problem
I have removed all sensitive information (tokens, credentials, real data)
Activity
dansonofbass commentedon Nov 19, 2026
Hi! I've completed the fix for this issue and pushed it to my fork.
The change prevents non-ASCII webhook signatures from raising an unexpected
TypeError, while preserving the existing HMAC validation behavior.All 205 tests passed locally, along with pylint and isort checks.
I tried opening a PR, but GitHub says pull requests are restricted to repository collaborators.
Here's my branch:
https://github.com/dansonofbass/sdk-python/tree/fix/160-non-ascii-webhook-signature
Would it be possible to enable PR submissions for external contributors, or is there another preferred way to submit the fix?
Thanks!