Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check webhook signature before constructing Event from the payload #577

Closed
rfk opened this issue May 31, 2019 · 2 comments · Fixed by #578
Closed

Check webhook signature before constructing Event from the payload #577

rfk opened this issue May 31, 2019 · 2 comments · Fixed by #578

Comments

@rfk
Copy link

rfk commented May 31, 2019

Hi!

I happened to be poking around in the details of your webhook signature-checking code, and I noticed that it does some processing on the event payload before checking the signature, in particular calling stripe.Event.construct_from on the not-yet-authenticated data:

data = json.loads(payload)
event = stripe.Event.construct_from(data, api_key)
WebhookSignature.verify_header(payload, sig_header, secret, tolerance)

I don't have any reason to believe that this can be used to trigger bad behaviour, but Event.construct_from seems to do quite a lot of dynamic work to hydrate the data into live objects. Calling WebhookSignature.verify_header before doing that work could be a nice defense-in-depth measure against bugs elsewhere in the codebase.

Just a small suggestion that I wanted to pass along; thanks for providing this nice library, and for an API that seems to strongly encourage the webhook-handling code down the right path security-wise!

@ob-stripe
Copy link
Contributor

Hi @rfk! You are entirely correct, we've made a similar change to most of our client libraries for other languages, but it looks like we never updated stripe-python.

I'll open a PR and we'll release a fix promptly. Thanks for bringing this to our attention!

@ob-stripe
Copy link
Contributor

Fixed in 2.29.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants