An AWS CDK security group lets any address reach SSH, RDP or another administration port
What it finds
Opening port 22, 3389 or a database administration port to 0.0.0.0/0 or ::/0 exposes it to scans and password guessing from the whole internet. Access goes through a bastion, a VPN or a list of known addresses.
From the rule's source, admin_port_open_to_world.rs.
from aws_cdk import aws_ec2 as ec2 def stack(sg): sg.add_ingress_rule(ec2.Peer.any_ipv4(), ec2.Port.tcp(22))tx0 reports: an administration port is open to every address sg.add_ingress_rule(ec2.Peer.ipv4("0.0.0.0/0"), ec2.Port.tcp(3389))tx0 reports: an administration port sg.add_ingress_rule(ec2.Peer.any_ipv4(), ec2.Port.tcp(443)) sg.add_ingress_rule(ec2.Peer.ipv4("10.0.0.0/8"), ec2.Port.tcp(22)) 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:
[rules]
"tx0/python:admin-port-open-to-world" = "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:admin-port-open-to-world] reason="..."tx0 explain tx0/python:admin-port-open-to-world shows the same in the terminal. Found a false positive? Report it.