Skip to content

account_id override: wire the 7 audited endpoints + shared fragment (follow-up to #1974) #1989

Open

Description

@sweetmantech

Tracking issue for wiring the account_id act-on-behalf override into the 7 endpoints the chat#1974 audit classified as unwired-candidates, plus the DRY helper that keeps the class closed. Follow-up to chat#1974 (both confirmed prod instances fixed there: api#845, api#846); filed as one batch tracker rather than seven micro-issues because the candidates share one pattern, one fix shape, and one shared helper.

Goal

An org key or RECOUP admin that can already list a member account's resources can also read/mutate the specific resources internal tooling needs, through the same centrally-authorized validateAuthContext(request, { accountId }) path — and new endpoints can't silently ignore an account_id param again.

Explicitly rejected (audit finding, 2026-08-21): central auto-read of ?account_id= inside validateAuthContext. account_id is not always an override — DELETE /api/organizations/members (member being removed), POST /api/organizations/members (member being added), and GET /api/artists (filter) give it other meanings; a blanket auto-read would turn the org-members routes into a privilege-escalation path. Per-endpoint threading through a shared fragment stays the design.

PRs

PR Item State
api#TBD Shared accountIdOverrideParam zod fragment + helper (one-line wiring for GETs, identical semantics) + a validators-directory convention test: any schema containing an override-intent account_id must thread it to validateAuthContext ⏳ not started
api#TBD Wire the 4 fix-now endpoints through the fragment: GET /api/runs, DELETE /api/tasks, GET /api/catalogs/songs, GET /api/sandboxes/file (TDD per endpoint; docs rows in the same cycle) ⏳ not started
docs#TBD Document account_id on the 4 wired ops ⏳ not started

Merge sequencing: docs → api (contract first). The docs PR can cover all four ops in one page-set change.

Open — in priority order

  • GET /api/runs — asymmetric with POST /api/valuation since api#846: a run started for a member account can't be polled by the operator who started it. Done when: admin/org caller with ?account_id= sees the member's runs; non-privileged foreign account_id → 403; no-param unchanged.
  • DELETE /api/tasks — read side honors account_id, delete 403s; blocks the zombie-task sweeps (gap known since 2026-07). Done when: admin can delete a member's task by id with body account_id; rejection + no-param cases pinned.
  • GET /api/catalogs/songs — authorizeCatalogAccess expands only the caller's own orgs; admin acting for a member 403s (the exact chat#1974 class). Done when: override read returns the member catalog's songs; rejection pinned.
  • GET /api/sandboxes/file — buildGetSandboxesParams already supports target_account_id; sibling GET /api/sandboxes is wired. One-line inconsistency. Done when: file read works with ?account_id= exactly like the list op.
  • Shared fragment + convention test (lands with the first api PR). Done when: the four endpoints above use it, and the test fails on any validator that declares an override-style account_id without threading it.
  • Conditional (wire only when the need materializes; re-classify then): POST /api/research/measurement-jobs (admin backfills currently bill the operator), POST /api/sandboxes/files (write into a member repo), POST /api/research/snapshots (legacy, superseded — confirm it still has callers before touching).

Source references

  • The audit: classification comment on chat#1974 (counts: 14 wired / ~54 not-applicable / 7 candidates over 98 call sites at api ac145227).
  • Reference implementations: api#845 (query-param override, GET .../measurements), api#846 (body override with effective-account side-effect scoping, POST /api/valuation).
  • Authorization core: validateAccountIdOverride → canAccessAccount (RECOUP_ORG universal branch + shared-org branch), verified live on both branches 2026-08-20 (403→404 differential on api#845).

Activity

  1. sidneyswift commented on Nov 6, 2026

    @sidneyswift
    Collaborator

    GET /api/sandboxes/file now accepts account_id through the shared access policy (recoupable/api#1131).

    Left: GET /api/runs, DELETE /api/tasks and GET /api/catalogs/songs still ignore an override. The shared fragment and convention test haven't been built.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions