fix(security): use HMAC with SECRET_KEY for webhook hash#443
fix(security): use HMAC with SECRET_KEY for webhook hash#443onovy wants to merge 5 commits intoredimp:mainfrom
Conversation
|
Thanks for submitting this PR! I'm questioning whether a strong secret is truly needed here, given the limited attack surface. Perhaps I'm missing something? More importantly, this PR appears incomplete; it only covers the update of the hook validation and is missing to update to the generation of the hash in the admin interface. |
|
An attacker who knows (or guesses) the remote URL can compute the hash and trigger spurious pulls — but pulls only come from the already-configured remote, so the damage is limited to triggering unnecessary git operations.
Ad generation in admin: That's thing I was missing, "where is it generated for user?" :). Sorry for mistake, working on fix now. |
|
I thought about the DoS aspect of the pull webhook and discussed it briefly with @deseven. I'm not as much concerned about an attacker abusing the webhook than accidental calls to the webhook. So this could be improved by only allowing a webhook pull every 60s and returning a 429 else. |
|
in my POV rate limiting is just workaround. Problem is still there: (Almost) anyone, without authentication can trigger "git pull". Webhook secret (by definition and it's name :) should be secret. Current implementation is just security by obscurity, hash check is useless now. |
|
ad rate limit: This could break it more. For example two commits done to external repository in short period = two web hook trigger, second one fails => inconsistency. Another idea, let's make it backward compatible:
|
|
I would assume anything triggering the webhook url has a proper retry mechanism .. and a 429 is exactly made for this. It tells the client to retry. |
Could be handled more gracefully:
The generated link in the admin panel will no longer match the link used in previously configured setups, but the old links will still work. UPD: Ah, well, in that case it will be still possible to use the old route :D Maybe we just need to add a special property to the remotes that are using the new logic? Like |
|
Now it's completely backward compatible. |
| const hash = await generateWebhookHash(remoteUrl); | ||
| const webhookUrl = window.location.origin + '/-/api/v1/pull/' + hash; | ||
| webhookUrlInput.value = webhookUrl; | ||
| webhookUrlInput.value = '... save first to show new pull webhook URL ...'; |
There was a problem hiding this comment.
Not a fan of this personally, maybe better to hide the field completely and instead write a nicely looking note? We can also write here some warning when GIT_REMOTE_PULL_URL_SECURE is not true so the user will be aware that their current configuration needs to be updated.
There was a problem hiding this comment.
right, fixed in last commit
- Add 'Regenerate secure webhook URL' checkbox to admin panel that upgrades GIT_REMOTE_PULL_URL_SECURE to True on save without requiring the user to change the remote URL - Add warning alert when webhook uses legacy insecure hash - Hide webhook URL field (show note instead) when URL changes in JS - Add tests for checkbox upgrade behavior and warning visibility
|
Hey @onovy, thanks for the effort. Will review and check later this week. |
WARNING: This is breaking change and old tokens will stop to work!