Repository navigation
Description
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-policynorspored-instance-role. - Severity: low today. Tracing is off by default (
pkg/observability/config.go,Tracing.Enabled: false), and nothing inspawn launchturns it on. A spore that enables it through a local spored config exports into an AccessDenied. - Decide: grant
xray:PutTraceSegments(andxray: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 toconfig.ResultS3Bucket). spawn launch --batch-queuewith no--iam-roleattaches the sharedspored-instance-role(cmd/launch_batchqueue.go~L228). That role grants nos3:PutObjecton 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'sResultS3Bucket, the wayspawn task rundoes (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
AmazonEC2ReadOnlyAccessandAmazonDynamoDBReadOnlyAccess. The gate does not model managed policies, and would not accept their wildcards anyway, soec2:DescribeInstancesis recorded as "granted by a managed wildcard". handleTerminateInstance(lambda/dashboard-api/instances.go:287then:310) builds its client withgetEC2ClientForRegion, which assumes this read role, and then callsec2:TerminateInstancesandec2: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
- The TTL reaper is clean on all three of its target-account policies (cross-account role,
ScanSelfPolicyDocument, the SAM ScanSelf branch) and on its base role. The existingpkg/reaperiamgates had already closed it. - scheduler-handler and dns-updater (the
deploy-custom-dns.shrole) are clean. - Alert Lambdas: there are none in this repo any more (Two stranded artifacts: self-hosted-stack.yaml (354 lines, deployed nowhere) and lambda/alert-handler (builds in CI, runs nowhere) #783, The entire alerting subsystem has zero users: alert-evaluator has run hourly for 232 days against an empty table #794).
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'ss3:GetObjectonspawn-*buckets "covers" the pipeline stage'ss3:GetObjectby name. - Implicit permissions are not inferred. It does not add
iam:PassRoleforRunInstanceswith a profile,ec2:CreateTagsfor tag specifications, ors3:PutObjectTaggingfor an upload withTagging. - The task wrapper's
aws s3 cpis shell, so it is invisible to an SDK scan.
Activity
test(iam): one coverage gate for every spore.host principal's AWS cal…
test(iam): one coverage gate for every spore.host principal's AWS cal…
fix(iam): batch-queue results role, dashboard role scripts match the …
fix(iam): batch-queue results role, dashboard role scripts match the …
scttfrdmn commentedon Oct 27, 2026
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.