An AWS CDK security group allows all outbound traffic, which lets a compromised instance reach anything

tx0/python:security-group-open-egressstrictnotesecurity/iacdepth fastsecurity

What it finds

allow_all_outbound=True permits connections to any address and port. Narrow egress rules make data exfiltration and command-and-control traffic harder.

From the rule's source, security_group_open_egress.rs.

Example from the rule's tests
from aws_cdk import aws_ec2 as ec2 def stack(scope, vpc):    ec2.SecurityGroup(scope, "A", vpc=vpc, allow_all_outbound=True)tx0 reports: this security group allows every outbound connection    ec2.SecurityGroup(scope, "B", vpc=vpc, allow_all_outbound=False)
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 strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/python:security-group-open-egress" = "note"

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:security-group-open-egress] reason="..."

tx0 explain tx0/python:security-group-open-egress shows the same in the terminal. Found a false positive? Report it.