Repository navigation
fix(iam): aws:ResourceTag on an IAM request describes the resource (#804) - #813
Merged
Merged
Conversation
) 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 Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #804.
iamAuthzResourcesreturned[]authzResource{{ARN: arn}}— no tags. Since #770 made thatpath the one every entity-naming IAM request takes, such a request published no
aws:ResourceTag/<key>at all: anAllow … if aws:ResourceTag/team=platformgrantednothing, and — the direction that matters — a
Deny … if aws:ResourceTag/env=prodsilentlystopped biting, leaving the
Allowbeneath it to decide the request.What changed
performs for
Path, so the key costs nothing beyond that read. The tags travel attached tothe ARN, so a condition about one resource cannot be satisfied by a tag on another. All five
resolvable types are covered now that policies and instance profiles carry tags (iam: tags are stored but no entity read reports them #796).
A service-linked role's tags are read by ARN — its ARN is derived from a service principal
or a deletion-task ID rather than read out of a record.
resourceTagsFor'scase "iam":is deleted. It readreqCtx.Principal.ARNand publishedthe caller's tags as the resource's for the six operations that name no resource, so a caller
tagged
team=platformsatisfied a condition written about an untagged entity — and satisfiedit where there is no resource to carry a tag. It dates from v0.18.0, before either key had a
producer for IAM; the caller's tags are
aws:PrincipalTag/<key>(iam: produce aws:userid and aws:PrincipalTag/, the two caller keys still without a producer #771). Those six now publishno
aws:ResourceTag/<key>, in a comment shaped like the EC2-absence one beside it.authzResourceTagPrefixesrather than a literal so the two doors cannot come to publishdifferent ones. Publishing at the generic gate alone would have refused inside the handler a
request the gate had just allowed — Principal-aware test mode: enforce IAM authorization in composition tests #411/iam: the condition operator families substrate does not implement are discarded, not refused — ...IfExists, ArnNotLike, numeric, date, IpAddress #714/iam: policy variables are compared literally, so a negated ${aws:username} is more permissive than on AWS #745 from a fourth side.
p.authzResourcenowanswers an
authzResource, which compiles unchanged at all ~60 call sites.Provenance
authzResourceTagPrefixes("iam")falls through toaws:ResourceTag/alone, and that is nowcited: 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}andaws:TagKeys— and noiam:-prefixed resource-tag key, soIAM 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
Tagsmember onthe
Groupdata type, noTagGroup/UntagGroup/ListGroupTagsin the Actions index, noiam:*Grouptagging action in the vendored snapshot, and the User Guide's "You can tag mostIAM 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 atmainin a throwawayworktree first:
Deny … if aws:ResourceTag/env=prodbites on the prod-tagged role and not on another —the silently-inert Deny;
Allow … if aws:ResourceTag/team=platformgrants on the matching entity only, swept overa tagged and an untagged user, role, policy-by-ARN and instance profile. The caller carries
team=platformtoo, so a decision made from the caller's record would allow all eight;ListRoles— the old false allow;aws:ResourceTag, at both doors;instance profile, a service-linked role, a group, a group named by a finished ARN, a
non-ARN policy source and an absent entity;
StateManagerpublishes none rather than panicking;newIAMPluginDoorServer, which wires noAuthController: a caller whosepolicy allows
iam:GetRoleifaws:ResourceTag/env=prodreads the prod-tagged role and isrefused the untagged one. Both were 403 before.
TestABAC_IAMRole_ResourceTagis rewritten: it askediam:PassRolewith the tagged role asthe caller, so it passed only because
resourceTagsForpublished the caller's tags. It nowuses an untagged caller and a tagged role, and asserts the untagged role is refused.
Compatibility
A
Denyconditioned on an IAM resource tag bites where it was inert; anAllowthat wassatisfied by the caller's own tags stops being satisfied.
Verification
gofmt/go build/go vet/golangci-lintclean (0 issues);make testandGOTOOLCHAIN=go1.26.6 make testpass; coverage emulator 83.7%, total 83.1% (baseline83.6/83.0);
make docs-reference docs-reference-check docs-versions authz-reference-check,npm --prefix docs run build, andgo vet -C test/e2e ./... && go test -C test/e2e ./...allpass.