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

webhook: fix non-matching webhook secrets not being rejected #601

Merged
merged 2 commits into from
May 15, 2024

Conversation

harryfinbow
Copy link
Contributor

Fixes an issue which allowed webhooks to be processed with an incorrect webhook secret.

This adds a case to return a 401 when the verify function returns false. The verify function also always returns false as it is being passed in JSON from a WorkflowJob webhook object instead of the request body (which is how GitHub generates it's signitures) meaning the signatures will never match (see https://github.com/yanyongyu/githubkit?tab=readme-ov-file#webhook-verification).

@harryfinbow harryfinbow requested a review from a team as a code owner May 15, 2024 15:38
@harryfinbow
Copy link
Contributor Author

I am not familiar with FastAPI at all so if there is a better way of getting the request body without having to add async that you know of I am happy to change it :)

@harryfinbow harryfinbow marked this pull request as draft May 15, 2024 15:41
@harryfinbow harryfinbow marked this pull request as ready for review May 15, 2024 15:50
Copy link
Contributor

@tcarmet tcarmet left a comment

Choose a reason for hiding this comment

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

Thanks for providing this very valuable fix!

I don't have enough knowledge as well into why we have to use async to make this code works, but given that you have provided the appropriate test case and it is covered, and I know that using async with FastAPI is usually the way to go so LGTM and thanks again ❤️ !

@tcarmet tcarmet merged commit 7273aa4 into scality:main May 15, 2024
9 of 11 checks passed
@harryfinbow harryfinbow deleted the webhook-secret branch May 20, 2024 09:44
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 this pull request may close these issues.

2 participants