Skip to content

fix(iam): aws:ResourceTag on an IAM request describes the resource (#804) - #813

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/804-resource-tags
Sep 12, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/804-resource-tags

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Closes #804.

iamAuthzResources returned []authzResource{{ARN: arn}} — no tags. Since #770 made that
path the one every entity-naming IAM request takes, such a request published no
aws:ResourceTag/<key> at all: an Allow … if aws:ResourceTag/team=platform granted
nothing, and — the direction that matters — a Deny … if aws:ResourceTag/env=prod silently
stopped biting, leaving the Allow beneath it to decide the request.

What changed

Provenance

authzResourceTagPrefixes("iam") falls through to aws:ResourceTag/ alone, and that is now
cited: the IAM User Guide's Tags for AWS Identity and Access Management
resources
names exactly
four tag condition keys for IAM — aws:ResourceTag/{key-name}, aws:RequestTag/{key-name},
aws:PrincipalTag/{key-name} and aws:TagKeys — and no iam:-prefixed resource-tag key, so
IAM has no service-specific duplicate of the global key the way EC2 has ec2:ResourceTag.
(The Service Authorization Reference page renders client-side and the vendored snapshot carries
no condition keys, so this page is the citation rather than that one.)

That groups cannot be tagged rests on the same four citations as #796: no Tags member on
the Group data type, no TagGroup/UntagGroup/ListGroupTags in the Actions index, no
iam:*Group tagging action in the vendored snapshot, and the User Guide's "You can tag most
IAM resources, but not groups, assumed roles, access reports, or hardware-based MFA devices."

Tests

emulator/iam_resource_tag_authz_test.go, all five verified failing at main in a throwaway
worktree first:

  • a Deny … if aws:ResourceTag/env=prod bites on the prod-tagged role and not on another —
    the silently-inert Deny;
  • an Allow … if aws:ResourceTag/team=platform grants on the matching entity only, swept over
    a tagged and an untagged user, role, policy-by-ARN and instance profile. The caller carries
    team=platform too, so a decision made from the caller's record would allow all eight;
  • that same caller is refused on an untagged entity and on ListRoles — the old false allow;
  • the six fall-through operations publish no aws:ResourceTag, at both doors;
  • both doors publish the same tags for the same request, over user, role, policy-by-ARN,
    instance profile, a service-linked role, a group, a group named by a finished ARN, a
    non-ARN policy source and an absent entity;
  • a gate with no StateManager publishes none rather than panicking;
  • end to end through newIAMPluginDoorServer, which wires no AuthController: a caller whose
    policy allows iam:GetRole if aws:ResourceTag/env=prod reads the prod-tagged role and is
    refused the untagged one. Both were 403 before.

TestABAC_IAMRole_ResourceTag is rewritten: it asked iam:PassRole with the tagged role as
the caller, so it passed only because resourceTagsFor published the caller's tags. It now
uses an untagged caller and a tagged role, and asserts the untagged role is refused.

Compatibility

A Deny conditioned on an IAM resource tag bites where it was inert; an Allow that was
satisfied by the caller's own tags stops being satisfied.

Verification

gofmt/go build/go vet/golangci-lint clean (0 issues); make test and
GOTOOLCHAIN=go1.26.6 make test pass; coverage emulator 83.7%, total 83.1% (baseline
83.6/83.0); make docs-reference docs-reference-check docs-versions authz-reference-check,
npm --prefix docs run build, and go vet -C test/e2e ./... && go test -C test/e2e ./... all
pass.

)

The resource resolver #770 introduced returned the ARN alone, so from that
release every entity-naming IAM request published no aws:ResourceTag/<key> at
all: an Allow conditioned on one granted nothing, and a Deny conditioned on one
silently stopped biting.

The tags now ride out of the read the resolver already performs to recover the
entity's path, attached to the ARN they belong to, so a condition about one
resource cannot be satisfied by a tag on another. A service-linked role's tags
are read by ARN, its ARN being derived rather than read; a group carries none.

resourceTagsFor's iam arm read the principal's ARN and published the caller's
tags as the resource's for the six operations that name no resource — a false
allow dating from v0.18.0, before aws:PrincipalTag had a producer for IAM. It is
deleted, and those six publish no resource tag at all.

The plugin door publishes the same tags as the generic gate, so a request the
gate allows is not refused inside the handler.
@codecov

codecov Bot commented Sep 12, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.43750% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
emulator/iam_authz_resources.go 97.95% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 0827990 into main Sep 12, 2026
17 checks passed
@scttfrdmn
scttfrdmn deleted the fix/804-resource-tags branch September 12, 2026 01:23
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.

fix(iam): aws:ResourceTag on an IAM request describes the caller, not the resource

1 participant