Repository navigation
Description
AuthController.buildResourceARNs' iam arm returns a flat arn:aws:iam::<account>:* for
every IAM operation (emulator/authz.go, the req.Service == "iam" arm reached from
buildResourceARN). Whatever the request names — a user, a role, a policy, an instance
profile — the resource substrate authorizes against is a bare wildcard scoped to the account.
That is wrong in the safe direction for a broad statement and wrong in the unsafe direction
for a narrow one: a policy whose Resource is arn:aws:iam::123456789012:user/alice cannot
match arn:aws:iam::123456789012:*, so the statement grants nothing; and a NotResource or a
negated tag condition scoped the same way excludes nothing. Both are the pattern the bundled
AWS managed policies use.
It became observable with #745. Policy-variable substitution now resolves
IAMUserChangePassword's arn:aws:iam::*:user/${aws:username} to
arn:aws:iam::*:user/alice — the correct ARN — and the statement still grants nothing,
because there is no user-shaped resource on the request side to match it. The variable was
never the only thing missing.
docs/services.md states this under the policy-variables section, so a reader is not left
assuming the bundled policy works.
#747 mints the service-linked-role ARN it needs and no more, deliberately: the general
per-operation IAM resource is its own piece of work.
What this needs
A per-operation resource derivation for iam:, in the shape the ec2 and s3 arms already have:
the operation's own parameter (UserName, RoleName, PolicyArn, InstanceProfileName,
GroupName, PolicyName for an inline policy, …) resolved to the ARN AWS documents for that
resource type in the Service Authorization Reference. Operations AWS documents as not
supporting resource-level permissions — ListUsers, ListRoles, and the rest of the account-wide
listings — keep *, and that has to be read off AWS's own table rather than guessed, since a
narrowed resource on an operation AWS scopes to * is a refusal substrate would be inventing.
Both IAM authorization doors must agree. IAMPlugin.authorize passes "*" at all 37 of its
call sites, so narrowing only buildResourceARNs reproduces the one-ARN-two-answers class of
#411 and #714 in reverse — CheckAccess refuses and the handler allows, or the other way round.
Acceptance criteria
- A test asserts
IAMUserChangePasswordlets alice change her own password and refuses
bob's, end to end throughCheckAccess, with no hand-written policy - Each IAM resource type substrate models resolves to the ARN the Service Authorization
Reference documents for it, cited per type - Operations AWS documents as
*-only stay*, with the citation -
IAMPlugin.authorize's 37 call sites name the same resource asbuildResourceARNs, or
the divergence is stated and tested -
docs/services.mdreplaces the "filed on its own" note with what now resolves
Activity
feat(iam): service-linked roles, and a producer for iam:AWSServiceName (
scttfrdmn commentedon Sep 11, 2026
Scheduled for v0.111.0. A full inventory of the second door first, because the sizing in the issue
body is low and one of the resource types has no door at all.
IAMPlugin.authorizehas 49 call sites, not 37.authorize(emulator/iam_plugin.go:1544-1548)is a shim over
authorizeWith(:1564-1724), whoseresourceargument reaches onlyEvaluationRequest.Resourceat:1682and:1706.p.authorize(sitesiam_plugin.go37,iam_groups.go6,iam_simulate.go2,iam_policy_versions.go2,iam_list_policies.go1,iam_slr_handlers.go1"*"iam_slr_handlers.go:291, which computes one)authorizeWithsites already passing a real ARNiam_slr_handlers.go:113,:194(#747)The 37 in the doc comment at
iam_plugin.go:1561-1563is the count for that one file.Grouped by the resource type the operation names, which is how the work divides:
:237CreateUser,:285GetUser,:326DeleteUser,:960/:1010/:1056Attach/Detach/ListAttachedUserPolicies,
:1368/:1439/:1492Create/Delete/ListAccessKeys,:2184/:2242/:2294Tag/Untag/ListUserTags,iam_groups.go:111ListGroupsForUser:446,:514,:559,:607,:1094,:1144,:1190,:2363,:2421,:2473:736,:788,:851,iam_groups.go:49,:78,:175,:225,:271:1226,:1294,:1333,iam_policy_versions.go:60,:109:1804,:1883,:1924,:1981, which already build the action by concatenation:2040,:2113iam_simulate.go:112validatesPolicySourceArntwolines above the gate and then passes
"*". Cheapest fix in the set.*— 5 sites::387ListUsers,:686ListRoles,:909ListGroups,iam_list_policies.go:87ListPolicies,iam_simulate.go:154SimulateCustomPolicySeparately, and arguably worse than the
"*": the six instance-profile handlers call the plugindoor zero times —
createInstanceProfile:2717,getInstanceProfile:2763,deleteInstanceProfile:2791,addRoleToInstanceProfile:2827,removeRoleFromInstanceProfile:2884,listInstanceProfiles:2970. The genericAuthControllergate still runs upstream, butAddRoleToInstanceProfileisprivilege-escalation-relevant and has no plugin-side gate. "Both doors must agree" is vacuous for
instance-profileuntil they exist, so the gate is being added as part of this work, with its ownCHANGELOG entry.
On the citation criterion. The Service Authorization Reference pages for both IAM and EC2 render
their tables in JavaScript and are unreachable to a fetch —
docs/services.mdalready records thisfor the two ELB pages, which is why
Names.member.Nwas left at*. AWS's Service ReferenceInformation endpoint carries the same data as JSON
(
https://servicereference.us-east-1.amazonaws.com/v1/iam/iam.json, currentlyVersion v1.4):Actions[].Resources[].Nameper action,Resources[].ARNFormatsper type, and an action with noResourceskey supports no resource-level permissions. That snapshot is being vendored and a Gotable generated from it with an offline drift check, so every row is cited by construction and a
test — not a comment — asserts that each operation's resource type is one AWS publishes for it, and
that every operation AWS scopes to
*is absent from the table.Confirmed from that source:
userisarn:${Partition}:iam::${Account}:user/${UserNameWithPath},and
role/group/policy/instance-profilefollow the same…NameWithPathshape. That path isthe one wrinkle — unlike EC2, where an ID's prefix determines its ARN, an IAM ARN needs the
entity's stored
Path, and only theCreate*operations carry it on the wire. Resolutiontherefore costs one
state.Get, followingiamAuthzRolePath(iam_authz.go:163-176), and fallsback to
*rather than minting an ARN that only looks specific, periam_authz.go:135-138.feat(authz): vendor AWS's per-operation authorization data, generated…
scttfrdmn commentedon Sep 11, 2026
Surveyed this against
mainbefore starting. The defect reproduces exactly as filed, but the call-site inventory in the issue is low — it is 49 sites, not 37 — and the survey turned up a second, more serious finding the issue does not mention. Both are worth recording before the work lands.The defect, confirmed
buildResourceARN's iam arm (emulator/authz.go:934-941) returns a flatarn:aws:iam::<account>:*for every IAM operation, so a statement whoseResourceisarn:aws:iam::123456789012:user/alicematches nothing. This is why #745's policy-variable substitution still leaves the bundledIAMUserChangePasswordgranting nothing — the variable resolves correctly and then compares against the wrong resource (docs/services.md:1658-1665).The real inventory
p.authorizeis a shim overauthorizeWith(iam_plugin.go:1544-1548,:1564-1724); theresourceargument reaches onlyEvaluationRequest.Resourceat:1682and:1706.p.authorize(sitesiam_plugin.go37,iam_groups.go6,iam_simulate.go2,iam_policy_versions.go2,iam_list_policies.go1,iam_slr_handlers.go1"*"authorizeWithsites already passing a real ARNiam_slr_handlers.go:113,:194)Grouped by the resource type the operation names: user 13 sites, role 10, group 8, policy 5, polymorphic user/role/group 4 sites → 12 ops (
putInlinePolicyand friends,iam_plugin.go:1804,1883,1924,1981), polymorphic user/role 2 → 4 ops (permissions-boundary handlers,:2040,:2113), and entity ARN already in hand 1 (iam_simulate.go:112validatesPolicySourceArntwo lines above the gate — the cheapest fix in the set).Five sites legitimately keep
"*":ListUsers(:387),ListRoles(:686),ListGroups(:909),listPolicies(iam_list_policies.go:87),simulateCustomPolicy(iam_simulate.go:154). AWS publishes no resource types for those actions, so*is the correct answer, not a placeholder — and that will be asserted by test rather than left to a comment.The second finding: six handlers call the plugin door zero times
createInstanceProfile(:2717),getInstanceProfile(:2763),deleteInstanceProfile(:2791),addRoleToInstanceProfile(:2827),removeRoleFromInstanceProfile(:2884) andlistInstanceProfiles(:2970) have no plugin-side gate at all. The genericAuthControllergate still runs upstream, so this is not an open door, butAddRoleToInstanceProfileis privilege-escalation-relevant and "both doors agree" is vacuous forinstance-profilewhile one of them never runs. Gating those six is beyond this issue's literal text; it will land here with its own CHANGELOG bullet rather than as a silent extra.Also noted and filed separately as #796:
Tagsis stored onIAMUser/IAMRolebut never rendered —iamUserXMLFieldsandiamRoleXMLFieldsemit no<Tags>member.The path problem, and where the citations come from
Unlike EC2, where an ID's prefix determines its ARN, an IAM ARN needs the entity's stored
Path(${UserNameWithPath}), and only theCreate*operations carryPathon the wire. So resolution costs onestate.Getper resource-naming operation. There is precedent:iamAuthzRolePath(iam_authz.go:163-176) already does exactly this forDeleteServiceLinkedRole.PolicyArn-keyed operations need no read — the ARN is on the wire. Existing mintersiamUserARN/iamRoleARN/iamGroupARN(iam_types.go:264-278) andiamPolicyARNare reused; there is no instance-profile minter, since:2747inlines thefmt.Sprintfand skipsnormalisePath, so one gets extracted.The per-operation classification will not be hand-transcribed from the Service Authorization Reference — those HTML pages render their tables in JavaScript and are unreachable, which
docs/services.mdalready records for both ELB pages. It comes from AWS's machine-readable Service Reference Information endpoint, vendored and code-generated with an offline drift check (landed in #797). A test then asserts, for every row in the table, that its resource type is one AWS publishes for that action, and that every action with no published resource types is absent from the table. That is this issue's second and third acceptance criteria checked mechanically rather than claimed in prose.Assigned to v0.111.0 alongside #771 and #762 — the same defect seen from three sides.
fix(iam): authorize an IAM request against the entity it names (#770) (…
scttfrdmn commentedon Sep 11, 2026
Shipped in v0.111.0 (#802). Against the acceptance criteria as filed:
iamAuthzOperationResource, plus the three service-linked-role operationsiamAuthzSLRResourceARNalready resolved (iam: CreateServiceLinkedRole, so iam:AWSServiceName has a producer #747). Both doors calliamAuthzRequestResourceon the sameAWSRequest, so the answer cannot differ by call site — the plugin door's 48 literal"*"gates are gone, and a table test drivesCheckAccessandIAMPlugin.authorizeover every row asserting one ARN, computed from the fixture rather than from the resolver.IAMUserChangePasswordnow grants the caller their own password and nothing else. Verified live too, with the AWS CLI: alice, holding a customer-managed policy allowingiam:GetUseronarn:aws:iam::123456789012:user/alice, reads her own user and is refused bob's. The same script against the previousmainrefused both, onarn:aws:iam::123456789012:*.ListUsersunder a policy scoped touser/alicestill grants nothing. Five operations that name no resource keep the account wildcard —ListUsers,ListRoles,ListGroups,ListPolicies,SimulateCustomPolicy— which is AWS's own answer for them. It is deliberatelyarn:aws:iam::<account>:*rather than a bare*, because a bare*in the resource position matches every statement: harmless for anAllow, wrong for aDeny.Two things beyond the issue's text, both recorded in the CHANGELOG:
AddRoleToInstanceProfileis the classic privilege-escalation step, and "both doors agree" is vacuous forinstance-profilewhile one door is missing. The test proving them runs against a server built with noAuthController, since with the generic gate present a refusal proves nothing about the plugin's.iamInstanceProfileARNjoins the four minters it should have shipped with, so the profile's ARN goes throughnormalisePath.One limit surfaced while writing these tests and filed rather than folded in: #801 — the same divergence on the principal side, where a caller whose own entity lives at a non-default path is not enforced at all. The tests here authorize as a caller stored at the default path, and say why in place, so none of them can pass vacuously.
fix(iam): aws:ResourceTag on an IAM request describes the resource (#804