Repository navigation
Description
What
aws:ResourceTag/<key> on an IAM request is answered from the wrong entity, in both directions.
Since #770, every IAM request naming an entity is resolved by iamAuthzResources, which returns
return []authzResource{{ARN: arn}}(emulator/iam_authz.go:114) — the ARN with no tags. CheckAccess merges
res.Tags under each prefix authzResourceTagPrefixes publishes (emulator/authz.go:252-256), so
for those requests the condition context holds no aws:ResourceTag/<key> at all:
- an
Allowconditioned onaws:ResourceTag/teamgrants nothing — a false deny, an inconvenience; - a
Denyconditioned onaws:ResourceTag/envsilently stops biting — a false allow, and the
failure substrate exists to prevent. A permission boundary written as "deny writes to anything
taggedenv=prod" is inert here and enforced on AWS.
For the six operations that resolve no resource and fall through to the account wildcard
(ListUsers, ListRoles, ListGroups, ListPolicies, ListInstanceProfiles,
SimulateCustomPolicy), resourceTagsFor's iam arm runs instead — and it reads the caller:
case "iam":
entityType, entityName := parsePrincipalARN(reqCtx.Principal.ARN)(emulator/authz.go:1219-1248). It publishes the calling user's or role's own tags as the
resource's tags, so a caller tagged team=platform satisfies a resource-tag condition written
about an entity that carries no tags at all.
That arm dates from v0.18.0 (028da7a), when neither aws:ResourceTag nor aws:PrincipalTag had a
producer for IAM and reading the caller was the only reading available. #771 gave the caller's tags
their own key: aws:PrincipalTag/<key>, published by iamPrincipalTags
(emulator/credentials.go:227-264). So the caller now has an owner and this arm is a second,
wrong reading of the same request.
Why the fix is cheap
iamAuthzRequestResource already reads the named entity's record to recover its Path — an IAM ARN
embeds the path (arn:${Partition}:iam::${Account}:user/${UserNameWithPath}), so the read is
unavoidable and already paid for. Decoding Tags in the same unmarshal costs nothing and hands the
resolver the tags that belong to the ARN it is returning, which is the invariant
buildResourceARNs' per-resource Tags field exists to keep (emulator/authz.go:245-256).
Acceptance criteria
- An IAM request naming an entity publishes that entity's tags as
aws:ResourceTag/<key>—
every prefixauthzResourceTagPrefixes("iam")publishes, checked against what AWS documents
for IAM's condition keys rather than assumed - A
Denyconditioned onaws:ResourceTag/env=prodrefuses an operation on aenv=prod-tagged
role and does not refuse the same operation on another role - A caller tagged
team=platformis refused anAllow … if aws:ResourceTag/team=platform
on an untagged entity — the false allow this issue reports -
resourceTagsFor's iam arm no longer reads the principal; whatever replaces it says why, and
the six operations that resolve no resource publish noaws:ResourceTag - Both authorization doors agree, as iam: authorize against the resource a request names, not arn:aws:iam::<acct>:* #770's table test already asserts for the ARN
Found while planning v0.112.0, reviewing what #770 changed about which resource an IAM request is
decided against.
Activity
fix(iam): aws:ResourceTag on an IAM request describes the resource (#804