Skip to content

fix(security): per-org webhook secrets and tenant binding (Fixes #61) - #189

Merged
OkiriGabriel merged 1 commit into
mainfrom
fix/per-org-webhook-secrets-61
Nov 25, 2026
Merged

OkiriGabriel merged 1 commit into
mainfrom
fix/per-org-webhook-secrets-61

Conversation

@OkiriGabriel

Copy link
Copy Markdown
Collaborator

Fixes #61.

The problem

All tenants share one WEBHOOK_SECRET, and the org is picked from the unauthenticated X-Org-ID header, the body, or an alert's org_id label. 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

Case Result
Org has its own WEBHOOK_SECRET and the request is signed with it (HMAC, bearer or GitLab token) + X-Org-ID ✅ bound to that org
Same org, platform secret 401
Request authenticated with acme's secret claims another org 401 (header wins over body and labels)
Platform secret, but an alert's org_id label points at an org with its own secret 403, and nothing in the batch is queued
Org without its own secret, platform secret ✅ unchanged
REQUIRE_ORG_WEBHOOK_SECRET=true, platform secret, org ≠ ORG_ID 403
Org config storage unavailable 503 (fail closed)
/slack/action for an org with its own SLACK_SIGNING_SECRET must be signed with that secret; the platform secret gets 401
  • WEBHOOK_SECRET is added to ORG_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.
  • One check, _authorize_webhook_org, runs on every enqueue path: GitHub, GitLab, Bitbucket, manual, Alertmanager and Grafana.
  • Additive to the fail-closed work in [SECURITY] Fail-closed webhook defaults and rate limiting for credential endpoints #64, which changes the no-secret default. Nothing here conflicts with that plan.

Docs

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

…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]>
@OkiriGabriel
OkiriGabriel merged commit a6bd1a8 into main Nov 25, 2026
16 checks passed
@OkiriGabriel
OkiriGabriel deleted the fix/per-org-webhook-secrets-61 branch November 26, 2026 10:13
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.

[SECURITY] Per-org webhook secrets and tenant binding for multi-API-key deployments

1 participant