Repository navigation
Description
AttachRolePolicy and AttachUserPolicy accept any PolicyArn without checking that it
resolves. attachRolePolicy (iam_plugin.go:843-887) validates the role exists, then
appends the ARN to role_policies:<name> unconditionally. GetPolicy on the same ARN
returns NoSuchEntity 404. So a consumer can attach a policy that does not exist and only
find out later, through a different operation.
Reported as part of #484, which hit the concrete case: five service-role ARNs an
SSM/Lambda/ECS consumer attaches were not in the bundled catalog. v0.87.0 seeded those five,
which fixes the reported symptom. This issue is the general case, kept open deliberately.
Why rejecting was refused in v0.87.0
Real IAM validates the policy exists and returns NoSuchEntity if it does not, so refusing
is the faithful behaviour. Substrate bundles 52 of roughly 1,200 AWS managed policies.
Rejecting an unresolvable ARN today would refuse every attach of the other ~1,150 — a
consumer attaching AmazonRDSFullAccess would get a hard failure where AWS succeeds. That
trades a confusing success for a wrong failure, and the wrong failure is worse: it breaks
working consumer code rather than merely failing to catch a typo.
#484's reporter offered both directions and would have accepted either. The decision is
recorded here rather than left implied by the code.
Possible middle paths
- Validate shape, not existence. Refuse an ARN that is not a well-formed policy ARN —
wrong service, wrong resource type, missingpolicy/— which catches typo-shaped
mistakes without requiring the catalog to be complete. Does not catch
arn:aws:iam::aws:policy/AmazonRDSFullAccesss. - Warn. Log at
WARNon an attach whose ARN neither resolves in the catalog nor exists
in state, naming the ARN. Costs nothing, changes no observation, and is the same shape as
SQS message-attribute rules are not applied to attributes already in state #491's receive-time warning. - Seed the full managed-policy ARN list without documents. Roughly 1,200 name/ARN/ID
triples let existence checks be exact while documents stay seeded for the ones that
matter. Sizeable data addition, and it makesGetPolicyresolve a policy whose document
is empty, which then needs its own caveat. - Make it seedable. A control-plane switch for strict attach validation, off by default,
so a consumer who wants the error branch tested can arm it.
(2) and (4) compose and neither breaks an existing consumer; that pairing is the likely
answer, but the decision belongs in this issue rather than pre-empted here.
Acceptance criteria
- Decide between the paths above and record the reasoning.
-
AttachUserPolicy,AttachGroupPolicyandPutRolePolicy's managed equivalents get
the same treatment — the asymmetry is not specific to roles. - Whatever ships, an ARN that
GetPolicyresolves must never be refused. -
docs/services.mdstates which check an attach performs. - Tests cover an unbundled-but-real managed ARN and a malformed one, and pin that they
are treated differently.
Activity
feat(iam): bundle the five service-role managed policies (#484) (#500)
scttfrdmn commentedon Aug 14, 2026
Scheduled for v0.100.0. The issue leaves the decision open and lists four paths; the
decision is (1) + (2): validate the ARN's shape, and warn rather than refuse on one that
substrate cannot resolve.
missing
policy/— is refused withInvalidInput400. This is the case that catches atypo, which is what makes the current silent success confusing.
policy:state logs at
WARNnaming the ARN, and succeeds. Refusing it would break everyattach of the ~1,150 real AWS managed policies substrate does not bundle: a consumer
attaching
AmazonRDSFullAccesswould hit a hard failure where AWS succeeds, which isworse than the confusing success. That is the issue's own reasoning and it still holds.
GetPolicyresolves is never refused — the issue's hard acceptancecriterion.
Rejected, for the record:
GetPolicyresolve policies whosedocuments do not exist, trading one confusing answer for a worse one: a policy that
reports itself real and grants nothing.
asking for it. Reconsider if one does.
Also fixing the asymmetry the issue names, rather than recreating it: the check applies to
AttachUserPolicy,AttachRolePolicyand the newAttachGroupPolicyarriving in thesame milestone with the IAM group operations (#579's prerequisite).
This changes existing behaviour. A fixture that attaches a malformed
PolicyArnstarts failing where it used to silently succeed. It goes under
## Compatibilityin thev0.100.0 release notes.
scttfrdmn commentedon Aug 15, 2026
Decision recorded, implemented in #647 for v0.100.0.
What ships: paths (1) + (2) — validate the ARN's shape, warn on one that resolves nowhere.
PolicyArnthat is not a well-formed policy ARN is refused withInvalidInput(400), the code the model declares for all three attach operations. The pattern is derived from the model's ownaccountIdType(\d{12}),policyPathTypeandpolicyNameType([\w+=,.@-]+), and thearnType20–2048 bound is checked first so an oversized value is refused on its size rather than run through a regex.WARNnaming it. Two messages, not one: an unbundled AWS managed policy is the expected case, while a customer-managed ARN that noCreatePolicyever created is a likelier real mistake.aws,aws-cn,aws-us-gov, theaws-isovariants, and whatever follows). Refusing an unknown partition would refuse an ARN that is perfectly well-formed for a region substrate does not model.GetPolicyresolves is never refused, and never warns. That is this issue's hard acceptance criterion and it is asserted for a bundled ARN and a created one, across all three operations.Why existence is not required. Substrate bundles 52 of roughly 1,200 AWS managed policies. Requiring existence would refuse every attach of the other ~1,150 — attaching
AmazonAthenaFullAccesswould hard-fail where AWS succeeds. That trades a confusing success for a wrong failure, and the wrong failure is worse: it breaks working consumer code rather than merely failing to catch a typo. This issue's own reasoning on that point still holds.Paths not taken:
GetPolicyresolve policies whose documents are empty — a resolvable ARN whose document is a lie needs its own caveat, and it is a large data addition serving only to make an existence check possible.Applied to all three operations, not two:
AttachGroupPolicyships in the same release (part of #579's group prerequisite), so leaving it out would recreate the asymmetry this issue reports inside a brand-new operation.Ordering: the shape check runs before authorization (it needs no state, and a malformed request is invalid whatever the caller may do); the existence warning runs after the entity lookup, so an attach that is going to fail with
NoSuchEntitydoes not also warn about a policy nothing was attaching.This changes existing behaviour and is called out under
## Compatibilityin the v0.100.0 release: a fixture attaching a made-up, non-ARN-shapedPolicyArnstarts failing withInvalidInput; one attaching a real-but-unbundled AWS managed ARN keeps working.fix(iam): an attach validates the shape of its PolicyArn (#499) (#647)
fix(iam): drop a return value no attach reads, and assert both ARN bo…
docs(iam): the simulator's scope, and an e2e journey through it (#648)
fix(iam): a boundary an SDK can read, and a count something wrote (#852…
fix(iam): validate PolicyArn shape on the three detach operations (#875…