Skip to content

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

Closed

Description

@scttfrdmn

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 Allow conditioned on aws:ResourceTag/team grants nothing — a false deny, an inconvenience;
  • a Deny conditioned on aws:ResourceTag/env silently stops biting — a false allow, and the
    failure substrate exists to prevent. A permission boundary written as "deny writes to anything
    tagged env=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 prefix authzResourceTagPrefixes("iam") publishes, checked against what AWS documents
    for IAM's condition keys rather than assumed
  • A Deny conditioned on aws:ResourceTag/env=prod refuses an operation on a env=prod-tagged
    role and does not refuse the same operation on another role
  • A caller tagged team=platform is refused an Allow … 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 no aws: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

  1. added this to the v0.112.0 milestone on Sep 11, 2026
  2. added
    type: bug
    area: iam
    priority: high
    on Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: iampriority: hightype: bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions