Repository navigation
fix(api): accept X-Hub-Signature for Bitbucket webhooks - #105
Merged
OkiriGabriel merged 1 commit intoOct 20, 2026
Merged
OkiriGabriel merged 1 commit into
OkiriGabriel merged 1 commit into
Conversation
Preserve existing signature headers and precedence, test acceptance and rejection paths, and document webhook secret setup. Co-Authored-By: GPT-6.1 Sol <[email protected]>
OkiriGabriel
approved these changes
Oct 20, 2026
OkiriGabriel
left a comment
Collaborator
There was a problem hiding this comment.
Thanks @Nitjsefnie, this fixes #94 correctly. Bitbucket's X-Hub-Signature is now accepted after X-Hub-Signature-256 and X-Webhook-Signature. The precedence is preserved (a present-but-invalid preferred header doesn't fall through), and an empty header correctly allows the fallback. The tests cover every header with every invalid form, which is more than I'd have asked for. The setup steps in the docs are a nice addition. Approving and merging.
11 of 30 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The Bitbucket webhook handler authenticated deliveries against the
X-Hub-Signature-256header, but Bitbucket Cloud sends the HMAC in theX-Hub-Signatureheader with asha256=<hex>value (per Bitbucket's webhook documentation). Signed Bitbucket webhooks were therefore rejected with 401.The handler now also accepts
X-Hub-Signatureas a fallback. The existingX-Hub-Signature-256andX-Webhook-Signatureheaders keep working with their current precedence, and all malformed signature values (missing, empty, wrong digest, missing/unknown algorithm prefix, non-hex) keep failing closed for every header.Fixes #94
Type of Change
Platform/Component
Testing
tests/test_security.pycover acceptance per header, missing/empty/wrong-digest/malformed rejections, header precedence in both directions, and empty-header fallbackdda52c939b45cd984ee5aa0eefe20ae790d21b4eTest Configuration
Locally:
python3 -m pytest tests/test_security.py -q→ 63 passed;bandit -r . -ll→ clean (0 medium/high).Checklist
Breaking Changes
None. Existing senders using
X-Hub-Signature-256orX-Webhook-Signatureare unaffected;X-Hub-Signatureis accepted only additionally, after both existing headers in the selection order.Additional Notes
The
X-Hub-Signature/X-Webhook-Signatureselection shape also appears in the Alertmanager, Grafana, GitLab and Manual handlers; those were left unchanged here since this issue concerns Bitbucket, whose documented header isX-Hub-Signature.Generated by GPT-6.1 Sol (implementation, task review), GPT-6 Astra (final review), GLM-5.3-Flash (brief, coordination)