Security groups must not allow a wide port range to the entire internet. Exposing multiple ports publicly increases attack surface and enables broad port scanning, automated exploitation, and easier lateral movement.
For Ansible amazon.aws.ec2_group or ec2_group resources, check rules[].from_port and rules[].to_port and ensure rules where to_port - from_port > 0 are not paired with cidr_ip set to 0.0.0.0/0 or cidr_ipv6 set to ::/0. Rules that require external access should restrict CIDR ranges to trusted networks or use specific single-port entries. Any rule defining a port range with an entire-network CIDR is flagged.
Secure example restricting access to a single port and a specific CIDR:
- name:example ec2 group v2amazon.aws.ec2_group:name:exampledescription:an example EC2 groupvpc_id:12345region:eu-west-1rules:- proto:tcpfrom_port:80to_port:80cidr_ip:0.0.0.0/0- proto:tcpfrom_port:22to_port:22cidr_ip:10.0.0.0/8
Non-Compliant Code Examples
- name:example ec2 groupamazon.aws.ec2_group:name:exampledescription:an example EC2 groupvpc_id:12345region:eu-west-1rules:- proto:tcpfrom_port:80to_port:82cidr_ip:0.0.0.0/0- proto:tcpfrom_port:2to_port:22cidr_ipv6:::/0
1
2
rulesets:- Ansible / AWS # Rules to enforce / AWS.
맞춤형 데모 요청
Datadog 시작하기
Ask AI
AI-generated responses may be inaccurate. Verify important info.