Skip to content

IAM coverage gaps found by the #254 gate: dashboard role script, batch-queue results upload, spored X-Ray, dashboard terminate #1344

Closed

Description

@scttfrdmn

The IAM coverage gate added for #254 (internal/iamcoverage) discovers every AWS SDK call each spore.host principal's code can reach (SSA call graph, RTA then VTA), maps it to its IAM action, and holds it to the policy spore.host provisions for that principal. On its first run it found the gaps below. The ones with an obvious, scoped fix were fixed in the #254 PR (sweep cross-account role, pipeline-orchestrator SNS + ec2:DescribeInstanceTypes, s3:AbortMultipartUpload beside every generated s3:PutObject). The rest need a decision, so they are recorded in the gate's knownGaps ledger with this issue as the reason. Deleting a ledger entry without fixing the gap fails the gate, and so does keeping an entry after the gap is fixed.

Evidence for each one is the gate's own output: the call site, and the call chain from the principal's entry point to it.

1. spored, X-Ray tracing: xray:PutTraceSegments (both instance-role variants)

  • Call: pkg/observability/tracing/exporters/xray.go:60 (XRayExporter.ExportSpans).
  • Chain: cmd/spored.runDaemon -> tracing.NewTracer -> otel BatchSpanProcessor -> exporter.
  • Granted by neither spored-baseline-policy nor spored-instance-role.
  • Severity: low today. Tracing is off by default (pkg/observability/config.go, Tracing.Enabled: false), and nothing in spawn launch turns it on. A spore that enables it through a local spored config exports into an AccessDenied.
  • Decide: grant xray:PutTraceSegments (and xray:PutTelemetryRecords) when tracing is enabled, or make the exporter report the denial once and stop.

2. spored run-queue (batch queue) on spored-instance-role: s3:PutObject, s3:AbortMultipartUpload

  • Call: pkg/agent/queue_runner.go:408 (QueueRunner.uploadFile, which uploads results and final state to config.ResultS3Bucket).
  • spawn launch --batch-queue with no --iam-role attaches the shared spored-instance-role (cmd/launch_batchqueue.go ~L228). That role grants no s3:PutObject on any user bucket. So a batch queue's results upload fails unless the user brings their own role, which is the hand-added IAM that Sizing: on a price tie, prefer the smallest type that fits (hpc7g cpu=16 → hpc7g.16xlarge) #610 says users should never need.
  • Decide: give batch queues a scoped spawn-instance-* role from the queue's ResultS3Bucket, the way spawn task run does (taskiam.TaskRunPolicyFor), or fail at launch with a clear message.

3. Dashboard Lambdas: SpawnDashboardLambdaRole (lambda/dashboard-api/scripts/setup-dashboard-lambda-role.sh) is far behind the code

dashboard-api, dashboard-websocket, dashboard-websocket-processor and cost-history-collector all run as this role. The script grants only ec2:Describe{Instances,Regions,Tags}, dynamodb:{GetItem,BatchGetItem,Query,Scan} on two tables, and dynamodb:UpdateItem on one. The code also calls the following.

Principal Action Example call site
dashboard-api dynamodb:PutItem lambda/dashboard-api/teams.go (handleCreateTeam), auth.go (createUserAccountWithIdentity), wstoken.go
dashboard-api dynamodb:DeleteItem sweeps.go:369, teams.go:317, teams.go:375
dashboard-api secretsmanager:GetSecretValue slack_secrets.go:66
dashboard-api s3:GetObject, s3:PutObject strata registry, via handleStrataResolve -> strata.Client.UploadLockfile -> registry.S3Client.PutLockfile (main.go says POST /api/strata/resolve "reaches S3 (s3://strata-registry) with this Lambda's credentials")
dashboard-api sts:AssumeRole sweeps.go:407 (terminateSweepInstancesCrossAccount, which assumes SpawnSweepCrossAccountRole with the Lambda's credentials). Also cross_account.go:75, but that one is made with the caller's credentials (#815). The gate's credential model cannot tell the two apart, so this entry covers both
dashboard-websocket dynamodb:PutItem, dynamodb:DeleteItem lambda/dashboard-websocket/main.go:108, :152
dashboard-websocket-processor dynamodb:DeleteItem, execute-api:ManageConnections lambda/dashboard-websocket-processor/main.go:279 (PostToConnection)
cost-history-collector dynamodb:PutItem lambda/cost-history-collector/main.go:232

The live role in the infra account is hand-managed and presumably carries these, since the dashboard works. The script is the only definition in the repo, and running it would not reproduce the role. Decide: replace the script with a template generated from the code, or record the live role's policy in the repo.

4. Dashboard cross-account read role (lambda/dashboard-api/scripts/setup-cross-account-role.sh)

  • It attaches only AWS-managed AmazonEC2ReadOnlyAccess and AmazonDynamoDBReadOnlyAccess. The gate does not model managed policies, and would not accept their wildcards anyway, so ec2:DescribeInstances is recorded as "granted by a managed wildcard".
  • handleTerminateInstance (lambda/dashboard-api/instances.go:287 then :310) builds its client with getEC2ClientForRegion, which assumes this read role, and then calls ec2:TerminateInstances and ec2:CancelSpotInstanceRequests. A read-only role cannot grant either, so terminating from the dashboard in a member account looks like it cannot work as written.
  • Decide: terminate as the caller directly, or as a role that can terminate (tag-scoped), and say which.

Not gaps, for the record

Limits of the gate (follow-ups, not filed separately)

  • Action names only, not resources. A grant on the wrong bucket still passes. spored-instance-role's s3:GetObject on spawn-* buckets "covers" the pipeline stage's s3:GetObject by name.
  • Implicit permissions are not inferred. It does not add iam:PassRole for RunInstances with a profile, ec2:CreateTags for tag specifications, or s3:PutObjectTagging for an upload with Tagging.
  • The task wrapper's aws s3 cp is shell, so it is invisible to an SDK scan.

Activity

  1. added this to the v0.147.0 milestone on Oct 26, 2026
  2. scttfrdmn commented on Oct 27, 2026

    @scttfrdmn
    ContributorAuthor

    Items 1 and 2 (the batch-queue results role and the dashboard role scripts matching the code) shipped in #1352. Items 3 and 4 (dashboard terminate and sweep cancel in a member account) moved to #1349, where the owner decided them on 2026-10-26. Closing this one.

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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions