Repository navigation
Description
What's wrong
organizations:MoveAccount's request body carries three IDs — AccountId, SourceParentId, DestinationParentId — but orgAuthzResourceID (emulator/organizations_tags.go:499) only recognizes ResourceId, PolicyId, TargetId, AccountId, OrganizationalUnitId, RootId, ParentId. Since MoveAccount's body has no ParentId field (it has SourceParentId/DestinationParentId instead), the function falls through to AccountId and authorizes every MoveAccount call against the account being moved only — SourceParentId and DestinationParentId are never checked against the caller's policy Resource list.
Confirmed against real AWS
Verified live, against a real AWS Organizations root (management account 942542972736), via iam simulate-custom-policy:
$ aws iam simulate-custom-policy \
--policy-input-list '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"organizations:MoveAccount","Resource":["arn:aws:organizations::942542972736:ou/o-pygqyjjoym/ou-fr7j-testtest1","arn:aws:organizations::942542972736:account/o-pygqyjjoym/*"]}]}' \
--action-names organizations:MoveAccount \
--resource-arns "arn:aws:organizations::942542972736:root/o-pygqyjjoym/r-fr7j"
# => implicitDeny
$ aws iam simulate-custom-policy \
--policy-input-list '{same policy}' \
--action-names organizations:MoveAccount \
--resource-arns "arn:aws:organizations::942542972736:ou/o-pygqyjjoym/ou-fr7j-testtest1"
# => allowed
Real AWS evaluates a MoveAccount policy against each resource named in the request (account, source parent, destination parent) independently — a policy scoped to only the destination OU (no root ARN) correctly denies when the root is a resource in play, e.g. as the source parent. Substrate's model never evaluates source/destination parent ARNs at all, so a policy that (correctly, per AWS) should deny a move-to-root is allowed by substrate regardless of the parent ARNs in the policy.
Repro
- Start a
TestServer, create an OU under root, create a signed principal with an inline policy grantingorganizations:MoveAccounton[accountARN, ouARN, ouARN/*]— deliberately omitting the root ARN (the exact shape a delegated-admin confinement policy uses). - Move a tagged account from the root into the OU — succeeds (correct).
- Move it back from the OU to the root — substrate allows it. Real AWS should deny it, since the root is the destination parent and is not named in the policy's Resource list.
Suggested fix
orgAuthzResourceID (or a MoveAccount-specific variant) should also check SourceParentID/DestinationParentID, and CheckAccess (or its Organizations-specific caller) should evaluate the policy against all three named resources (account, source parent, destination parent) rather than just one — matching the "any related resource must independently authorize" behavior IAM's own IAM Policy Simulator exhibits for the real API.
This is the case docs/open-questions.md Q9 in automat (github.com/scttfrdmn/automat) exists to ask about; automat's own real-AWS smoke test for this is still pending a live org run, so this gap was invisible until an emulator-backed test tried to reproduce that exact confinement policy against substrate.
Activity
scttfrdmn commentedon Aug 16, 2026
Confirmed and fixed in #661. Three things came out of the research that your analysis did not have, one of which is a correction to it.
The fix is narrower than it looks. I parsed all 63 Organizations action blocks in the Service Authorization Reference markdown source:
MoveAccountis the only action with more than one asterisked (required) resource type. 28 have exactly one, 34 have none. So this is not a service-wide change in how Organizations authorizes — it is one operation that outgrew a helper whose contract was "one resource", plus general machinery with exactly one caller today.AttachPolicy/DetachPolicymust not change, and don't. They asterisk onlypolicy\*;account,organizationalunitandrootare optional there. Widening them to require the target ARN too would turn AWS's own single-ARN OU example into a denial — the false-deny direction, which breaks working policies. They keep the single-resource path.There is a second real direction the issue does not mention: a parent-scoped
Denynever matched. Because no parent ARN was ever built, an explicit{"Effect":"Deny","Action":"organizations:MoveAccount","Resource":"<sandbox OU arn>"}silently did nothing — "this account may never leave the sandbox OU" was unenforced. A fix that only tightened the Allow side would leave that broken, so it has its own test (
TestOrganizations_Authz_MoveAccountParentScopedDenyBlocks).A correction. My first pass expected a false-deny mirror — a policy naming only
[rootArn, ouArn], the shape AWS's "granting permissions to a single OU" example uses, being wrongly refused. That is not a defect. The account is also a required resource, so a parent-only policy is denied both before and after; the test I wrote for it passed pre-fix and was replaced. The new decision is strictly stricter than the old one, never more permissive.On the gap in AWS's documentation, since you hit the same wall: the required-resource asterisks survive only in the SAR markdown source — the rendered page is JS-only, and the machine-readable
servicereference.us-east-1.amazonaws.comJSON omits the required flag entirely (the stringRequireddoes not appear in it). The "the entire statement is evaluated against every resource that is required" rule is stated forec2:RunInstancesand never for Organizations, and AWS publishes no MoveAccount policy example at all — the nearest one uses"organizations:*"on a single OU ARN, which would not authorize a three-resource MoveAccount. WhetherSourceParentIdis authorized at all is therefore settled by yoursimulate-custom-policyrun against a real organization, and it is cited in the release notes as an observation rather than as documented behaviour.ec2:RunInstanceshas the same shape — five asterisked resource types, only the instance ARN built — and is filed separately so the machinery landing here has a named next caller.Shipping in v0.102.0.
fix(organizations,iam): authorize every resource a request names (#660)…
fix(ec2,iam): authorize every ID an EC2 request names (#744) (#763)