fix(iam): resolve attached AWS-managed policies for any account - #1663
Merged
hectorvent merged 4 commits intoJul 3, 2026
Merged
Conversation
AWS-managed policies (arn:aws:iam::aws:policy/...) are global and live in the in-memory catalog, not the account-partitioned policy store; getPolicy already serves them from the catalog. Several IAM read paths, however, resolved attached policy ARNs straight from the account-scoped store (policies.get(arn) / the flatMap variants), so a managed policy attached to a principal owned by a non-default account was silently dropped. Add a catalog-aware resolvePolicy(arn) helper modeled on getPolicy and route the affected reads through it: listAttachedUser/Group/RolePolicies, the user/role permissions-boundary document resolvers, and collectUser/RolePolicies (the SimulatePrincipalPolicy / caller-context paths). Customer-policy-only logic and attachment-count bookkeeping on detach are left untouched.
…icy-attachment-resolution
…non-default account Adds the group analog of the existing user/role tests, exercising listAttachedGroupPolicies (the resolvePolicy catalog fix) for a group owned by a non-default account, with a customer policy attached to the same group as an account-scoping control.
Contributor
Author
|
Applied the Greptile P2 — added the group analog of the existing user/role tests: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #1573 (AWS-managed policies resolvable from any account context).
AWS-managed policies (
arn:aws:iam::aws:policy/...) are global and live in the in-memory catalog, not the account-partitioned policy store.getPolicyalready serves them from the catalog, but several IAM read paths resolved attached-policy ARNs straight from the account-scoped store (policies.get(arn)/ theflatMapvariants). As a result, a managed policy attached to a principal owned by a non-default account was silently dropped from the response.This adds a catalog-aware
resolvePolicy(arn)helper (modeled ongetPolicy) and routes the affected reads through it:listAttachedUserPolicies/listAttachedGroupPolicies/listAttachedRolePoliciescollectUserPolicies/collectRolePolicies(theSimulatePrincipalPolicy/ caller-context paths)Customer-policy-only logic and attachment-count bookkeeping on detach are left untouched.
Type of change
fix:)AWS Compatibility
For bug fixes: an AWS-managed policy attached to a user/group/role in a non-default account was not returned by the attached-policy read APIs (and not evaluated by
SimulatePrincipalPolicy), because those paths only consulted the account-scoped customer-policy store. Managed policies are global, so they are now resolved from the catalog regardless of the caller's account.Checklist
./mvnw testpasses locally (IamManagedPolicyAccountScopeTest: 6 tests;IamServiceTest: 57 tests — run in aneclipse-temurin:25-jdkcontainer)IamManagedPolicyAccountScopeTest)