Enforce task run ownership across REST and MCP

Merged
SI
2mo ago
+306-56

A signed-in caller could retrieve another account's Trigger run by ID through REST or the API-key MCP tool. Both now use the same ownership check as OAuth before returning run data. Authorized account overrides are validated in retrieve mode as well as list mode; inaccessible and unattributed runs return not found.

The shared check uses server-returned payload ownership, a persisted scheduled-task owner, or unambiguous worker-issued legacy account tags. Contradictory payload owners are denied. OAuth keeps its restricted status-only response. Provider 404s are normalized and other provider error details are withheld from client responses.

Validation: 170 tests pass across task handlers, MCP task tools, OAuth adapters/catalog/routing and Trigger retrieval; repository lint and extension build pass. Full typecheck still fails on existing issues; comparison against untouched main with the same dependencies found no new error signatures. No live customer runs were read or changed.

Production impact: own runs remain readable. Foreign or unattributed legacy run links are withheld; no database migration or broad legacy bypass is introduced. Repository credential containment and browser execution credential binding are separate follow-up P0 work.


Summary by cubic

Stops signed-in callers from retrieving another account's Trigger run by ID through the REST endpoint or the API-key MCP tool. REST and MCP now share the same ownership check OAuth already used, and foreign or unattributed runs return not found instead of run data.

  • Run ownership comes from server-returned payload fields, the persisted scheduled-task owner (matched via run ID or schedule.externalId), or unambiguous worker-issued legacy account tags; contradictory owners and schedule IDs are denied.
  • Scheduled-task lookups and owner comparisons normalize UUID casing, and a matching tag can't substitute for a missing scheduled task.
  • account_id overrides are now validated in retrieve mode as well as list mode.
  • Provider 404s are normalized, and other provider error details are withheld from client responses.