Skip to content

Organizations: MoveAccount does not authorize against SourceParentId/DestinationParentId, only AccountId #660

Closed

Description

@scttfrdmn

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

  1. Start a TestServer, create an OU under root, create a signed principal with an inline policy granting organizations:MoveAccount on [accountARN, ouARN, ouARN/*] — deliberately omitting the root ARN (the exact shape a delegated-admin confinement policy uses).
  2. Move a tagged account from the root into the OU — succeeds (correct).
  3. 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

  1. added
    type: bug
    on Aug 15, 2026
  2. added this to the v0.102.0 milestone on Aug 16, 2026
  3. scttfrdmn commented on Aug 16, 2026

    @scttfrdmn
    OwnerAuthor

    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: MoveAccount is 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/DetachPolicy must not change, and don't. They asterisk only policy\*; account, organizationalunit and root are 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 Deny never 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.com JSON omits the required flag entirely (the string Required does not appear in it). The "the entire statement is evaluated against every resource that is required" rule is stated for ec2:RunInstances and 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. Whether SourceParentId is authorized at all is therefore settled by your simulate-custom-policy run against a real organization, and it is cited in the release notes as an observation rather than as documented behaviour.

    ec2:RunInstances has 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.

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