Skip to content

fix(pipelines): add auth middleware and remove x-tenant-id header trust#38

Merged
grndlvl merged 2 commits intomainfrom
fix/pipeline-auth-and-tenant-resolution
Mar 21, 2026
Merged

fix(pipelines): add auth middleware and remove x-tenant-id header trust#38
grndlvl merged 2 commits intomainfrom
fix/pipeline-auth-and-tenant-resolution

Conversation

@grndlvl
Copy link
Copy Markdown
Member

@grndlvl grndlvl commented Mar 20, 2026

Summary

Fixes two security issues from grndlvl's review on PR #28 (Finding 1a/1b):

  • Pipeline routes exposed without auth: All CRUD/execution/review endpoints at /api/pipelines/* were accessible without authentication. Added requireBearerToken middleware to the route mount in index.ts.
  • Tenant identity was client-controlled: getTenantId() trusted the x-tenant-id request header, allowing any caller to impersonate any tenant. Replaced with auth-derived identity (req.mcpUser.id from Bearer token), matching the existing pattern in tools/executor.ts.

Files changed (3)

File Change
src/index.ts Add requireBearerToken to pipeline route mount
src/pipelines/routes.ts Replace getTenantId() — remove header trust, use mcpUser.id
tests/pipelines/routes.test.ts Update test helper to use mcpUser instead of x-tenant-id header

Context

Test plan

  • vitest run tests/pipelines/routes.test.ts — 13/13 pass
  • tsc --noEmit — 0 new errors (pre-existing inngest type errors only)
  • Full suite: 314/314 tests pass; 5 pre-existing failures from missing inngest package
  • Reviewer: verify x-tenant-id header no longer appears in pipeline route logic

🤖 Generated with Claude Code

grndlvl and others added 2 commits March 20, 2026 08:39
Pipeline routes were mounted without requireBearerToken, exposing all
CRUD/execution endpoints to unauthenticated callers. getTenantId()
trusted the x-tenant-id header, allowing any caller to impersonate
any tenant.

- Add requireBearerToken middleware to pipeline route mount (index.ts)
- Replace header-based tenant resolution with auth-derived identity
  (mcpUser.id from Bearer token, matching tools/executor.ts pattern)
- Update route tests to use mcpUser instead of x-tenant-id header

Ref: PR #28 review findings 1a/1b (grndlvl), issue #37

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…tenant finding

- Document that exports module is the only place supporting multi-tenant per user
- Record PR #38 fixes (auth middleware, x-tenant-id header removal)
- Add tracking references to issue #37 and PR #33

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@grndlvl grndlvl merged commit d24f8db into main Mar 21, 2026
1 of 2 checks passed
@grndlvl grndlvl deleted the fix/pipeline-auth-and-tenant-resolution branch March 21, 2026 12:53
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.

1 participant