Skip to content

A caller whose IAM entity has a path is never enforced: the path is read as part of the name #801

Closed

Description

@scttfrdmn

What

A caller whose IAM entity is stored under a non-default path is not enforced at all: every
request they make is allowed, whatever their policies say.

resolveIAMEntity → iamEntityForPrincipalARN → parsePrincipalARN
(emulator/iam_plugin.go:2719-2731) splits the ARN's resource part on the first slash and
takes everything after it as the entity name:

return resource[:slash], resource[slash+1:]

So for a user created with --path /division/engineering/, whose ARN is
arn:aws:iam::123456789012:user/division/engineering/alice, the name comes back as
division/engineering/alice. The lookup key is then
user:division/engineering/alice, which nothing is ever stored under — the record is at
user:alice. resolveIAMEntity reports exists == false, and both authorization doors treat
that as "not an IAM entity, so not enforced":

  • AuthController.CheckAccess (emulator/authz.go:172-180) logs at Debug and returns nil.
  • IAMPlugin.authorizeWith (emulator/iam_plugin.go) does the same, deliberately — enforcement
    is opt-in by creating the principal.

That fallback is right for a credential with no IAM entity behind it. It is wrong here: the
entity exists, it has policies, and substrate silently grants everything instead of applying
them. It is a false allow on the principal side of the same divergence #770 fixed on the
resource side — a consumer's IaC test passes here and the deployment is refused on AWS.

aws:PrincipalTag/<key> is affected the same way: iamPrincipalTags (#771) resolves the entity
through the same helper, so a path-carrying principal publishes no tags either.

Why it was not folded into #770

#770 is about the resource a request is decided against. This is about the principal the
decision is made for, and fixing it means changing how an entity name is recovered from an
ARN — which every door and the simulator share. Found while writing #770's path-fidelity tests:
the fixture originally stored the calling user at /division/engineering/, and every deny case
passed vacuously because the caller was never enforced. Those tests now store the caller at /
and give the named entities the path, with a comment pointing here
(emulator/iam_authz_resources_test.go).

Precedent for the fix

simulationUserName already solves the same problem for the simulator, per #745: the name is
the segment after the last slash, because a path is not part of the name. AWS's own ARN
format says so — arn:${Partition}:iam::${Account}:user/${UserNameWithPath}, where the name and
its path are one component.

Acceptance criteria

  • A principal ARN carrying a path resolves to the entity actually stored — user/alice
    for arn:aws:iam::123456789012:user/division/engineering/alice.
  • An assumed-role ARN still resolves to the role and drops the session name, including when
    the role has a path (arn:aws:sts::123:assumed-role/division/eng/worker/sess1 is the case
    to think hardest about — AWS does not include the role's path in the assumed-role ARN,
    so this must be verified against the docs rather than assumed).
  • iamPrincipalTags publishes aws:PrincipalTag/<key> for a path-carrying principal.
  • Both doors agree for such a caller: AuthController.CheckAccess and
    IAMPlugin.authorize reach the same verdict.
  • A test with the caller stored at a non-default path, asserting a deny that used to pass
    vacuously — and iam: authorize against the resource a request names, not arn:aws:iam::<acct>:* #770's own fixture simplified back to giving the caller a path.

Activity

  1. added
    type: bug
    on Sep 11, 2026
  2. added this to the v0.112.0 milestone on Sep 11, 2026
  3. scttfrdmn commented on Sep 11, 2026

    @scttfrdmn
    OwnerAuthor

    Researching this for v0.112.0 turned up a second defect that masks the one reported here, and it
    changes what the fix has to be.

    resolvePrincipal builds an IAM user's principal ARN without the entity's path:

    arn := fmt.Sprintf("arn:aws:iam::%s:user/%s", account, key.UserName)

    (emulator/credentials.go:182, from IAMAccessKey.UserName). So a signed AWS-CLI call from a user
    stored at /division/engineering/ presents arn:aws:iam::123456789012:user/alice, the first-slash
    parse recovers alice, the lookup hits, and the caller is enforced — by accident, while
    substrate reports an ARN that is not the user's ARN. That is a defect of its own:
    aws:PrincipalArn, GetCallerIdentity's Arn, and any trust policy naming the real user ARN are
    all answered with the wrong string.

    The consequence for this issue: the two must move together.

    • Fixing the parse alone leaves the principal ARN wrong.
    • Fixing the ARN alone turns today's accident into exactly the false allow reported here, for every
      signed call.

    Where the false allow is reachable today

    Not through a long-term access key, per the above. Two live paths do carry a path-bearing principal
    ARN:

    1. CloudFormation. cfnAttribution.principal builds &Principal{ARN: a.roleARN, …} from the
      stack's --role-arn verbatim (emulator/cfn_deployer.go:983), and AWS's own console creates
      CloudFormation service roles at /service-role/. A stack deployed with such a role has every
      resource call unenforced.
    2. sts:AssumeRole is worse than unenforced — it fails. assumeRole looks the role up with
      _, roleName := parsePrincipalARN(roleARN) (emulator/sts_plugin.go:160), so a role at any
      non-default path cannot be assumed at all: a hard "role not found" for an ARN that is perfectly
      valid.

    Both are in scope for the fix, and both give a live proof that fails in the opposite direction on a
    main build.

    The assumed-role criterion, settled

    The criterion above asks for arn:aws:sts::123:assumed-role/division/eng/worker/sess1 to be thought
    hardest about. AWS's answer (https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html):

    arn:aws:sts::{account}:assumed-role/{role-name}/{role-session-name}

    Exactly two components, and the role's path is excluded — while an IAM entity ARN is
    user/${UserNameWithPath}, one component in which the name is the last segment. So the existing
    first-slash unwrapping of an assumed-role ARN is correct and needs a pinning test rather than a
    change; that ARN is one AWS never mints and substrate cannot mint (it builds one from a role name,
    which contains no slash). The documented two-component parse will be kept deliberately, with the
    reasoning recorded rather than the impossible case handled.

    Planned for v0.112.0 as the first PR.

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

    type: bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions