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
WebhookSignature.verify_header raises TypeError for a non-ASCII v1 signature #1991
WebhookSignature.verify_header (and so Webhook.construct_event) raises TypeError: comparing strings with non-ASCII characters is not supported when a v1 value in the Stripe-Signature header contains a non-ASCII character, instead of SignatureVerificationError. secure_compare in _util.py passes both str values straight to hmac.compare_digest, which only accepts ASCII strings.
Since anyone can POST to a webhook endpoint, a request with a header like t=1,v1=é turns into an unhandled exception and a 500 in the usual handler that catches ValueError and SignatureVerificationError, instead of a 400. It still fails closed, so it's not a bypass.
Werkzeug and Django decode header bytes as latin-1, so a non-ASCII byte in the header reaches verify_header as a non-ASCII str. Comparing bytes (expected_sig.encode() against s.encode("utf-8")) or treating a non-ASCII signature as a mismatch would fix it. Happy to send a PR with a test.
Activity
chore(hark): add changefile for webhook non-ASCII signature fix (stri…