Skip to content

Add authentication and tenant scoping to webhook subscription endpoints #400

Description

@Wilfred007

What

Protect the webhook routes in backend/src/routes/webhook.routes.ts. All four endpoints currently mount with no auth or tenant middleware:

  • POST /subscribe
  • GET /subscriptions
  • DELETE /subscriptions/:id
  • POST /test-trigger (triggers a mock event)

Why

Every other data route in the app stacks authenticateJWT, syncTenantFromUser, and tenant-isolation middleware (see balanceRoutes.ts). The webhook routes have none, so any unauthenticated caller can register webhook subscriptions (a data-exfiltration / SSRF vector — the server will POST event data to an attacker URL), enumerate or delete other tenants' subscriptions by ID, and fire mock events in production.

Scope

In scope:

  • Apply authenticateJWT + syncTenantFromUser + tenant-isolation middleware to the subscription routes.
  • Scope list/delete to the caller's organization so IDs from other tenants are not accessible.
  • Restrict or remove POST /test-trigger outside non-production (guard by NODE_ENV/admin).
  • Consider validating/allowlisting subscription target URLs to reduce SSRF risk.

Out of scope:

  • Redesigning the webhook delivery pipeline.

Acceptance criteria

  • Unauthenticated requests to subscription routes are rejected (401).
  • A tenant cannot read or delete another tenant's subscription by ID.
  • test-trigger is not reachable by ordinary users in production.
  • Tests cover auth-required and cross-tenant-denied cases.

Technical context

  • Routes: backend/src/routes/webhook.routes.ts; controller: backend/src/controllers/webhook.controller.ts.
  • Middleware pattern to copy: backend/src/routes/balanceRoutes.ts (lines using authenticateJWT, syncTenantFromUser, strictTenantBoundary, logTenantAccess).

Activity

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

Metadata

Metadata

Assignees

Labels

Official Campaign | FWC26Campaign: Official Campaign | FWC26backendBackend developmenthardComplex taskssecurityIssues related to application security and audits

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions