Skip to content

sec(api): finish tenant-scoping sweep: inventory filter, RI-exchange quote, plans list (follow-ups to #374/#379) #384

Closed

Description

@cristim

Follow-ups from the reviews of #374 and #379 (tenant scoping)

  1. internal/api/handler_inventory.go:106-119 fetchCommitmentRecords still uses the "explicit account_id bypasses allowed scope" shape. It's safe today only because the callers post-filter (handler_inventory.go:47, :197, :235). Route it through intersectAccountFilterScope (added in sec(api): intersect explicit account filters with allowed_accounts on dashboard KPIs #374), as the dashboard now does, and keep the existing sentinel short-circuit. About 6 lines; the inventory tests already stub GetAllowedAccountsAPI.
  2. internal/api/handler_ri_exchange.go:1729 getExchangeQuote (POST /api/ri-exchange/quote, view:purchases) calls DescribeReservedInstances + GetReservedInstancesExchangeQuote for the ambient account with no reshapeCloudAccountInScope check, so a scoped user sees out-of-scope RI ids and quoted prices (read-only, no money moves). Add the same gate the sibling endpoints and executeExchange (fix(api): scope executeExchange to session's allowed_accounts #379) use.
  3. GET /api/plans (list) applies no allowed_accounts filtering; only the by-id routes use requirePlanAccess. Filter the list by allowed_accounts.
  4. Tests missing from fix(api): scope executeExchange to session's allowed_accounts #379: a restricted in-scope session (name-scoped allowed_accounts, the production shape) reaches HasPermissionForConstraintsAPI; a GetAllowedAccountsAPI error yields 500, not 403. Both behaviors are correct on main (verified with scratch tests), just not covered.

Each item needs a regression test that fails before the fix.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions