Repository navigation
fix(security): per-org webhook secrets and tenant binding (Fixes #61) - #189
Merged
Merged
Conversation
…61) - WEBHOOK_SECRET is now an org credential key. When an org has its own, its webhooks (HMAC, bearer or GitLab token) must use it; the platform secret is refused for that org (401), and a request authenticated for one org can only queue work for that org (X-Org-ID wins over body/labels). - Platform-secret requests that would route into an org with its own secret (e.g. via an alert org_id label) get 403; alert batches are checked in full before anything is queued. - REQUIRE_ORG_WEBHOOK_SECRET=true refuses the platform secret for every org except the server's ORG_ID. - /slack/action verifies with the approval org's own SLACK_SIGNING_SECRET when set, refusing the platform secret for it. - Org config lookups fail closed (503) if storage is unavailable. - Docs: API reference section on multi-tenant webhook setup; .env.example. Fixes #61 Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Fixes #61.
The problem
All tenants share one
WEBHOOK_SECRET, and the org is picked from the unauthenticatedX-Org-IDheader, the body, or an alert'sorg_idlabel. Anyone holding the platform secret can therefore queue incidents for any org, and those incidents run with that org's stored credentials. Slack callbacks are checked only against the global signing secret.The change
WEBHOOK_SECRETand the request is signed with it (HMAC, bearer or GitLab token) +X-Org-IDorg_idlabel points at an org with its own secretREQUIRE_ORG_WEBHOOK_SECRET=true, platform secret, org ≠ORG_ID/slack/actionfor an org with its ownSLACK_SIGNING_SECRETWEBHOOK_SECRETis added toORG_CREDENTIAL_KEYS, so it's stored like the other bring-your-own keys (encrypted at rest when enabled). It's only read from the org's stored config, never from the process env._authorize_webhook_org, runs on every enqueue path: GitHub, GitLab, Bitbucket, manual, Alertmanager and Grafana.Docs
REQUIRE_ORG_WEBHOOK_SECRETadded to.env.example.PUT /orgs/{org}/configreplaces the org's whole credential set. Per-key updates are part of [SECURITY] Credential lifecycle: validation, rotation audit trail, and secure deletion #62.Tests
tests/test_org_webhook_binding.py(11 tests) covers each row of the table, a mixed alert batch, the GitLab token and the Slack per-org secret. Full suite: 1316 passed, 4 skipped. Flake8 (CI selection) and bandit are clean.🤖 Generated with Claude Code