Skip to content

fix(E3530): flag NotPrincipal, group ARNs, and string "*" in role trust policies - #4862

Merged
kddejong merged 3 commits into
aws-cloudformation:mainfrom
Varshith-Kali:fix-4857-e3530-trust-policy-shapes
Oct 31, 2026
Merged

kddejong merged 3 commits into
aws-cloudformation:mainfrom
Varshith-Kali:fix-4857-e3530-trust-policy-shapes

Conversation

@Varshith-Kali

Copy link
Copy Markdown
Contributor

Summary

E3530 validates AWS::IAM::Role trust policies against policy_trust.json, which reused the general Principal definitions. Three shapes that IAM CreateRole rejects therefore passed silently, and the stack failed at deploy time. This tightens the trust schema so E3530 flags each of them.

Changes (policy_trust.json only; identity and resource policy schemas untouched)

  • NotPrincipal is no longer an allowed statement property in trust policies, and Principal is now required (previously requiredXor with NotPrincipal). A NotPrincipal statement now reports E3530.
  • New trust-specific TrustPrincipal definition: object-only, so the bare string form Principal: "*" is rejected. The object form {"AWS": "*"} stays valid.
  • New trust-specific TrustAwsPrincipalArn: same alternatives as the general definition minus the IAM group branch, so group ARNs are rejected while root, user, role, assumed-role, account ID, and CloudFront ARNs stay valid.

Testing

  • New regression tests in test/unit/rules/resources/iam/test_trust_policy.py: each of the three issue shapes produces zero findings before the fix and E3530 after; valid shapes (root, account ID, user, role, assumed-role, service, federated, {"AWS": "*"} object form, principal lists) verified unaffected.
  • test/unit/rules/resources/: 1323 passed.
  • End to end against the issue repro templates: E3530 now fires on notprincipal.yaml and principal-star-string.yaml, and on the literal group-ARN form. (The !Sub group form surfaces W1031 warnings instead: the Sub cannot be statically resolved to a concrete ARN at lint time, so the schema check cannot produce a definitive E3530 there.)

Fixes #4857

@Varshith-Kali

Copy link
Copy Markdown
Contributor Author

Hi team, on this fix(E3530) PR: the [CI] Test PR workflow run on the current head is still parked waiting for a first-time-contributor approval (action_required). Could a maintainer approve the run so CI can proceed? Thanks.

@Varshith-Kali

Copy link
Copy Markdown
Contributor Author

Hi @kddejong, friendly follow up: the CI runs on this PR are still parked at the first-time-contributor approval gate (action_required), so the checks cannot start until a maintainer approves the run. Could you approve it when you have a moment? Thanks!

…st policies

The trust schema reused the general Principal definitions, so three shapes
that IAM CreateRole rejects passed E3530 silently: a NotPrincipal statement,
an IAM group ARN as the AWS principal, and the bare string form
Principal "*".

Tighten policy_trust.json for trust policies only: require Principal (drop
the NotPrincipal alternative), reject the string form with a trust-specific
object-only Principal, and drop the group alternative from the trust
principal ARN patterns. The identity and resource policy schemas are
untouched.

Fixes aws-cloudformation#4857

Signed-off-by: Varshith Puli <pulivarshit@gmail.com>
@kddejong
kddejong force-pushed the fix-4857-e3530-trust-policy-shapes branch from 3819fd7 to 033b8bc Compare October 28, 2026 21:23
TrustAwsPrincipalArn was written before aws-cloudformation#4927 widened the shared
principal pattern, so merging reintroduced the false positive on
sts root and federated-user ARNs. Take the sts branch from
policy.json; the iam branch still omits group deliberately.

Also wrap an over-length assertion and cover the CanonicalUser,
Federated and Service keys, which were copied without tests.
@codecov

codecov Bot commented Oct 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.74%. Comparing base (3f36743) to head (159fed8).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4862   +/-   ##
=======================================
  Coverage   94.74%   94.74%           
=======================================
  Files         442      442           
  Lines       16105    16105           
  Branches     3125     3125           
=======================================
  Hits        15258    15258           
  Misses        468      468           
  Partials      379      379           
Flag Coverage Δ
unittests 94.73% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kddejong
kddejong merged commit b17a430 into aws-cloudformation:main Oct 31, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

E3530: role trust policy with NotPrincipal, a :group/ principal or Principal: "*" not reported

2 participants