Skip to content

Conversation

@mdtro
Copy link
Contributor

@mdtro mdtro commented Nov 9, 2022

Update the Python example for the webhook signature comparison to follow best practices.

Using hmac.compare_digest() mitigates timing-based attacks on the signature verification.

I've also updated the line to pull the signature header value to use the .get() method in order to avoid a KeyError exception.

Update the Python example for the webhook signature comparison to follow best practices.

Using `hmac.compare_digest()` mitigates [timing-based attacks](https://en.wikipedia.org/wiki/Timing_attack) on the signature verification.

I've also a updated the line to pull the signature header value to use the `.get()` method in order to avoid a `KeyError` exception.
@vercel
Copy link

vercel bot commented Nov 9, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
sentry-docs ✅ Ready (Inspect) Visit Preview Nov 10, 2022 at 0:23AM (UTC)

Copy link
Member

@leeandher leeandher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

Separating the checks to provide more clarity
@mdtro mdtro merged commit 98303c8 into master Nov 10, 2022
@mdtro mdtro deleted the mdtro/best-practice-hmac-compare branch November 10, 2022 13:45
@github-actions github-actions bot locked and limited conversation to collaborators Nov 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants