fix(account): refuse the management account as an AccountId target (#8276)

* fix(account): refuse the management account as an AccountId target
This commit is contained in:
Yang Hao authored and GitHub committed 2026-11-14 09:31:36 -04:00
1 parent ad549728df
commit 869a5fcb59
4 files changed
+163 -8

No files matched your search

@@ -150,8 +150,9 @@ public class AccountService implements Resettable, StoredResourceArns {
throw new AwsException("AccessDeniedException",
"The calling account is not the management account or a delegated administrator.", 403);
}
if (managementAccount && requestedAccountId.equals(callerAccountId)) {
throw validation("The management account cannot specify its own AccountId.");
if (requestedAccountId.equals(organization.getMasterAccountId())) {
throw new AwsException("AccessDeniedException",
"AccountId must name a member account, not the management account of the organization.", 403);
}
return requestedAccountId;
}