Skip to content

[SECURITY] Fail-closed webhook defaults and rate limiting for credential endpoints #64

Open

Description

@OkiriGabriel

Problem

When WEBHOOK_SECRET or SLACK_SIGNING_SECRET are unset, verification is skipped and all requests are accepted (api/webhook_auth.py).

ARCHITECTURE.md and SECURITY_GUARANTEES.md describe rate limiting (slowapi) and IP whitelisting, but no middleware exists in api/server.py.

tests/test_api.py posts to webhooks without signatures, masking auth requirements in CI.

Impact

Production misconfiguration silently disables webhook auth. Credential and webhook endpoints are vulnerable to brute-force and abuse.

Proposed solution

  1. Require webhook secrets in production (fail or warn loudly at startup when missing)
  2. Add rate limiting on webhook and /orgs/{org_id}/config endpoints
  3. Optional IP allowlisting for webhook sources (ALLOWED_IPS)
  4. Align test_api.py with test_webhook_auth.py so CI enforces auth expectations

References

  • api/webhook_auth.py
  • api/server.py
  • tests/test_api.py, tests/test_webhook_auth.py
  • ARCHITECTURE.md, SECURITY_GUARANTEES.md

Activity

  1. added
    enhancement
    security
    ci
    on Aug 31, 2026
  2. OpeyemiAdeniji commented on Nov 21, 2026

    @OpeyemiAdeniji
    Contributor

    Hi @OkiriGabriel, #173 covered the rate limiting and IP allowlist parts of this. I'd like to pick up what's left, in small PRs like #18:

    1. Startup warning (non-breaking). Log a warning at startup when WEBHOOK_SECRET or SLACK_SIGNING_SECRET is unset, the same way API_AUTH_DISABLED is already flagged in lifespan.
    2. Test alignment. Make the webhook tests in tests/test_api.py set WEBHOOK_SECRET and sign requests by default, keeping one explicit test for the no-secret path. Update the integration-test job in ci.yml (test(ci): assert status codes and response shape for /webhook/manual in integration job #107/test(ci): assert status codes and response shape for the remaining /webhook/* routes #176) to sign its requests too.
    3. Fail closed (breaking). Reject webhook and Slack requests with 401/503 when no secret is configured, unless an explicit opt-out such as WEBHOOK_AUTH_DISABLED=true is set, mirroring API_AUTH_DISABLED.

    Questions before step 3:

    • Are you OK with fail-closed by default plus an opt-out, or would you rather keep fail-open and only warn?
    • If it fails closed: reject per request (the server still starts, /health still works), or refuse to start?
  3. OkiriGabriel commented on Nov 21, 2026

    @OkiriGabriel
    CollaboratorAuthor

    Thanks @OpeyemiAdeniji, and thanks for #176 and #177. Answers for step 3:

    1. Fail closed by default, with an explicit opt-out. With no WEBHOOK_SECRET / SLACK_SIGNING_SECRET, reject the request unless WEBHOOK_AUTH_DISABLED=true / SLACK_AUTH_DISABLED=true is set. Mirror API_AUTH_DISABLED: log a startup warning when an opt-out is active, and make sure a configured secret is always verified even if the opt-out is also set (the opt-out only applies while the secret is absent).
    2. Reject per request, don't refuse to start. The server should still start so /health, /metrics and the queue worker keep working. Return 503 with a message naming the env var to set ("not configured"), and keep 401 for a configured secret with a missing or bad signature. That's the same split the management API uses (fix: require bearer tokens for org config, docs and audit API routes (#59) #127).

    A few things to cover in that PR, since it's breaking:

    • docker-compose.yml: fail at docker compose up without the secret, e.g. WEBHOOK_SECRET=${WEBHOOK_SECRET:?set WEBHOOK_SECRET in .env}.
    • middleware/README.md: AGENT_WEBHOOK_SECRET becomes required (the middleware forwards signed requests).
    • Your step 2: the CI integration job should set WEBHOOK_SECRET and sign its requests (Alertmanager and Grafana can use Authorization: Bearer).
    • A "Breaking change" section in the PR and a line in .env.example.

    Assigning this to you; go ahead with steps 2 and 3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

cienhancementsecurity

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions