Skip to content

dashboard-api: restrict callers to onboarded accounts - #1605

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/sec-dashboard-api-entitlement
Nov 12, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/sec-dashboard-api-entitlement

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Restricts dashboard-api callers to onboarded or allow-listed accounts.

Authentication (STS GetCallerIdentity on the caller's credentials, or API Gateway's IAM identity) shows who a caller is. It doesn't show that the caller is a customer. Every authenticated route now also requires an entitled account (lambda/dashboard-api/entitlement.go):

  • the account has a row in the portal registry spore-portal-accounts (GetItem on accountId, projecting only accountId and status), and that row is not offboarded; or
  • the account is listed in the function's new DASHBOARD_ALLOWED_ACCOUNTS (comma-separated 12-digit IDs; malformed entries are logged and entitle nothing).

spawn-user-accounts is deliberately not a source, because this Lambda writes that table itself on a caller's first request.

What the check covers

  • The credentials-header path checks the verified caller account first, before the spore-portal-launch shortcut, the user-account cache read, and any cache write. So that role name is honoured only inside an entitled account.
  • The API Gateway / Cognito path checks the caller's account and the account of the scope it resolves to (cached row or email-linked CLI ARN), before writing a cache row.
  • Every route behind authentication is covered: teams, team members, instances, sweeps, cost, watches, ws-token, and POST /api/strata/resolve. GET /api/strata/catalog stays anonymous, as before.
  • Fails closed. A non-entitled account gets 403. An unreadable registry gets 503, and the failure is not cached. If no account can be determined, the request is refused. There is no audit mode. Positive answers are cached for 5 min and refusals for 1 min.

Deploy checklist impact (manual, ordered)

  1. IAM first. Run lambda/dashboard-api/scripts/setup-dashboard-lambda-role.sh <profile>. It adds dynamodb:GetItem on table/spore-portal-accounts to SpawnDashboardLambdaPolicy. It also writes SpawnDashboardLambdaPolicyPortalRegistryKMS: kms:Decrypt on the table's own CMK (read with describe-table), conditioned on kms:ViaService=dynamodb.us-east-1.amazonaws.com and kms:EncryptionContext:aws:dynamodb:tableName=spore-portal-accounts. Both are inline on the existing role and are removed with it (or aws iam delete-role-policy …). No new resource.
  2. Environment second. Set DASHBOARD_ALLOWED_ACCOUNTS on spawn-dashboard-api, merged into the existing map, because --environment replaces the whole map. Until this is set, and while the registry has no rows, every caller gets 403. Optional: DASHBOARD_ACCOUNTS_TABLE (default spore-portal-accounts).
  3. Code last. Run lambda/dashboard-api/deploy.sh <profile> (this is code plus a manual config step).

Tests

Fakes only. They cover the allow list, active/dormant/no-status rows, offboarded rows, strangers, malformed entries, caching, an unreadable registry (fails closed, not cached), every named account having to pass, and parsing the scope's account. Through handler() with a fake STS: a stranger's IAM user and a stranger assuming spore-portal-launch get 403 on POST /teams, POST /teams/{id}/members, POST /api/strata/resolve and GET /api/instances, and cause no other AWS call. The same role in an onboarded account reaches the route. An unreadable registry returns 503. Removing the check makes the gate fail. make check is green. semgrep scan --config=auto --error on the changed paths is clean.

Not changed: POST /teams/{id}/members still accepts a member ARN from any account. An invitee may not be onboarded yet, so I left that as a product decision.

@codecov

codecov Bot commented Nov 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Every authenticated route now requires the caller's account to be in
the portal registry (spore-portal-accounts, not offboarded) or in the
new DASHBOARD_ALLOWED_ACCOUNTS, checked before the portal-role
shortcut and before any user-account row is written. Fails closed:
403 when not entitled, 503 when the registry cannot be read. The role
script grants GetItem on the registry and kms:Decrypt on its key via
DynamoDB.
@scttfrdmn
scttfrdmn force-pushed the fix/sec-dashboard-api-entitlement branch from 1f5ed45 to 377472f Compare November 12, 2026 20:07
@scttfrdmn
scttfrdmn marked this pull request as ready for review November 12, 2026 20:07
@scttfrdmn
scttfrdmn merged commit f9497f4 into main Nov 12, 2026
9 checks passed
@scttfrdmn
scttfrdmn deleted the fix/sec-dashboard-api-entitlement branch November 12, 2026 20:30
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