An IAM policy statement allows every action, every resource or every principal with *

tx0/python:policy-allows-everythingrecommendedwarningsecurity/iacdepth fastsecurity, cwe-732

What it finds

A statement with "Action": "*" grants all permissions, "Resource": "*" applies them to every resource of the account, and "Principal": "*" or AnyPrincipal() grants them to anyone. Checked are policy documents written as dict displays with "Effect": "Allow", and aws_iam.PolicyStatement and principals in AWS CDK code.

From the rule's source, policy_allows_everything.rs.

Example from the rule's tests
from aws_cdk import aws_iam as iam POLICY = {    "Statement": [        {"Effect": "Allow", "Action": "*", "Resource": "arn:aws:s3:::x"},tx0 reports: this policy statement allows every action        {"Effect": "Deny", "Action": "*", "Resource": "*"},    ]} def stack():    iam.PolicyStatement(actions=["s3:GetObject"], resources=["*"])tx0 reports: this policy statement allows every resource    iam.PolicyStatement(actions=["s3:GetObject"], resources=["arn:aws:s3:::x/*"])    iam.AnyPrincipal()tx0 reports: this principal stands for everyone
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/python:policy-allows-everything" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

# tx0: ignore[tx0/python:policy-allows-everything] reason="..."

tx0 explain tx0/python:policy-allows-everything shows the same in the terminal. Found a false positive? Report it.