Repository navigation
Description
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
forarn: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/sess1is 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). -
iamPrincipalTagspublishesaws:PrincipalTag/<key>for a path-carrying principal. - Both doors agree for such a caller:
AuthController.CheckAccessand
IAMPlugin.authorizereach 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
scttfrdmn commentedon Sep 11, 2026
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.
resolvePrincipalbuilds an IAM user's principal ARN without the entity's path:(
emulator/credentials.go:182, fromIAMAccessKey.UserName). So a signed AWS-CLI call from a userstored at
/division/engineering/presentsarn:aws:iam::123456789012:user/alice, the first-slashparse recovers
alice, the lookup hits, and the caller is enforced — by accident, whilesubstrate reports an ARN that is not the user's ARN. That is a defect of its own:
aws:PrincipalArn,GetCallerIdentity'sArn, and any trust policy naming the real user ARN areall answered with the wrong string.
The consequence for this issue: the two must move together.
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:
cfnAttribution.principalbuilds&Principal{ARN: a.roleARN, …}from thestack's
--role-arnverbatim (emulator/cfn_deployer.go:983), and AWS's own console createsCloudFormation service roles at
/service-role/. A stack deployed with such a role has everyresource call unenforced.
sts:AssumeRoleis worse than unenforced — it fails.assumeRolelooks the role up with_, roleName := parsePrincipalARN(roleARN)(emulator/sts_plugin.go:160), so a role at anynon-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
mainbuild.The assumed-role criterion, settled
The criterion above asks for
arn:aws:sts::123:assumed-role/division/eng/worker/sess1to be thoughthardest about. AWS's answer (https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html):
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 existingfirst-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.
test(iam): cover the implicit UserName and the ARN forms the resolver…
fix(test): remove the test harness's timing, name-resolution and pool…