Skip to content

fix(iamcoverage): count tag-on-create implied actions in the gate and inventory (#1377) - #1396

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/1377-implied-tag-actions
Oct 28, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/1377-implied-tag-actions

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #1377

internal/iamcoverage mapped each SDK call to one IAM action, so a create call that tags what it creates was inventoried without the tag action AWS also authorizes (e.g. sqs:CreateQueue + Tags -> sqs:TagQueue). Missing grants of that kind passed the coverage gate and then failed at runtime.

What changed

  • internal/iamcoverage/implied.go: a table of implied actions keyed by operation + input field. Every rule cites the Service Authorization Reference's "API operations" entry for its operation, plus the service's own page where that page states the "only when tags are passed" condition.
  • The analyser now finds each call's *<Op>Input argument and works out whether the field may be set. It counts a non-nil composite-literal field, an assignment, a phi, a nested field (CreateBucketConfiguration.Tags), and the arguments at every call site of an enclosing function's parameter, using the call graph. Anything it can't see (a method value, a helper's return value, an escaping pointer) counts as set, so it over-approximates rather than missing a grant.
  • If a rule names a field the SDK input type doesn't have, the call is reported as unmapped. That fails every gate, so the rule can't silently stop firing.
  • docs/reference/cli-iam-actions.md is regenerated, and its preamble no longer says tag permissions are left out.
  • The coverage gate's verdict is now a function (coverageErrors) so a fixture principal can be tested with it.

Rules

Each rule below was checked against the SAR operations table (servicereference.us-east-1.amazonaws.com/v1/<svc>/<svc>.json and list_<svc>.html#…-operation-<Op>). Where the service's own page states the condition in prose, that page is cited too.

  • sqs CreateQueue Tags -> sqs:TagQueue (API ref prose)
  • iam CreateRole / CreateInstanceProfile / CreatePolicy Tags -> iam:TagRole / TagInstanceProfile / TagPolicy (SAR only)
  • ec2 RunInstances, CreateSecurityGroup, CreateVolume, CreateImage, CopyImage, RegisterImage, CreateKeyPair, ImportKeyPair, AllocateAddress, CreatePlacementGroup, AuthorizeSecurityGroupIngress/Egress, PurchaseCapacityBlock TagSpecifications -> ec2:CreateTags (EC2 tag-on-create prose)
  • ebs StartSnapshot Tags -> ec2:CreateTags (SAR only)
  • dynamodb CreateTable Tags -> dynamodb:TagResource (SAR only)
  • lambda CreateFunction Tags -> lambda:TagResource (Lambda tags page)
  • events PutRule Tags -> events:TagResource (API ref prose)
  • sns CreateTopic Tags -> sns:TagResource (API ref prose)
  • fsx CreateFileSystem / CreateDataRepositoryAssociation Tags -> fsx:TagResource (FSx tagging prose)
  • efs CreateFileSystem / CreateAccessPoint Tags -> elasticfilesystem:TagResource (API ref prose)
  • imagebuilder CreateInfrastructureConfiguration / ImportDiskImage Tags -> imagebuilder:TagResource (SAR only)
  • sts AssumeRole Tags -> sts:TagSession (IAM session-tags prose)
  • s3 PutObject / CopyObject / CreateMultipartUpload Tagging, and transfermanager UploadObject Tagging -> s3:PutObjectTagging (PutObject API ref prose)
  • s3 CreateBucket CreateBucketConfiguration.Tags -> s3:TagResource. The CreateBucket API reference states this; the SAR's CreateBucket entry does not list it. spawn sets no bucket tags in-call, so this rule changes nothing today.

Left out: scheduler:CreateSchedule (takes no tags, and the SAR lists no tag action for it), fsx:DeleteFileSystem final-backup tags (spawn sets none), and iam:PassRole implied by a role field (a different kind of rule; not modelled here).

Newly documented user permissions

These calls already happened; they are now listed:

  • iam:TagRole, iam:TagInstanceProfile: every command that creates an instance role. iam:TagRole is also listed for notify register, onboard and reaper deploy.
  • ec2:CreateTags: now also listed for ami copy, ami create, create-ami, capacity-block purchase, snapshot create, snapshot mount
  • fsx:TagResource: launch, service, task run
  • s3:PutObjectTagging: launch, schedule create
  • dynamodb:TagResource: burst
  • sqs:TagQueue: pool create

Provisioned-principal grant (needs a live redeploy)

  • lambda/pipeline-orchestrator/template.yaml: sns:TagResource added to the spawn-pipeline-* SNS statement. The orchestrator creates its notification topic with a spawn:pipeline-id tag. The pipeline-orchestrator stack must be redeployed for this to take effect. Until then, per the SNS docs, a pipeline with a notification email can't create its topic (this is logged as a warning).

No other Lambda or provisioned principal turned up a new gap, and no knownGaps entries were added.

Gates (each watched failing against a compiling revert)

  • TestImpliedActionsFollowTheCallSite
    • Revert 1: applyImplied short-circuited. The tagged fixtures failed, including queueTagged: [sqs:CreateQueue], want [sqs:CreateQueue sqs:TagQueue].
    • Revert 2: the field always counted as set. The untagged fixtures failed, including queueUntagged: [... sqs:TagQueue], want [sqs:CreateQueue].
  • TestAnUngrantedImpliedActionFailsTheCoverageGate
    • Revert 1: no error for CreateQueue+Tags without a TagQueue grant.
    • Revert 2: a false error for the untagged call.
  • TestEveryImpliedRuleCitesItsSource: citations blanked, and it reported "no documentation cited".
  • TestARuleForAMissingFieldIsReportedNotSkipped: field check disabled, and the bogus field silently applied.
  • TestCLIActionInventoryIsCurrent: with revert 1 it reported the doc as stale.
  • TestEveryPrincipalCallIsGranted: failed on pipeline-orchestrator calls sns:TagResource before the template grant.

make check, make lint (0 issues, all 10 modules) and semgrep scan --config=auto --error . (0 findings) all pass.

@codecov

codecov Bot commented Oct 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.12422% with 32 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/iamcoverage/implied.go 78.66% 32 Missing ⚠️

📢 Thoughts on this report? Let us know!

… inventory (#1377)

internal/iamcoverage mapped each SDK call to one action, so CreateQueue
with Tags was listed without sqs:TagQueue. Add an implied-actions table,
each rule citing the Service Authorization Reference (and the service's
page where it states the condition), and trace each call's input to decide
whether the field may be set. Regenerate cli-iam-actions.md; grant
sns:TagResource to the pipeline orchestrator, which tags its topic.
@scttfrdmn
scttfrdmn force-pushed the fix/1377-implied-tag-actions branch from 44bd26d to 136af70 Compare October 28, 2026 20:47
@scttfrdmn
scttfrdmn merged commit 7ef88db into main Oct 28, 2026
9 checks passed
@scttfrdmn
scttfrdmn deleted the fix/1377-implied-tag-actions branch October 28, 2026 21:05
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.

IAM coverage gate: CreateQueue with Tags needs sqs:TagQueue, which the CLI inventory doesn't list

1 participant