Control: VPC security groups should restrict ingress Kafka port access from 0.0.0.0/0
Description
AWS VPC security groups can help in managing network access by providing stateful filtering of ingress and egress network traffic to AWS resources.
Usage
Run the control in your terminal:
powerpipe control run aws_compliance.control.vpc_security_group_restrict_ingress_kafka_port
Snapshot and share results via Turbot Pipes:
powerpipe loginpowerpipe control run aws_compliance.control.vpc_security_group_restrict_ingress_kafka_port --share
SQL
This control uses a named query:
with ingress_kafka_port as ( select group_id, count(*) as num_ssh_rules from aws_vpc_security_group_rule where type = 'ingress' and ( cidr_ipv4 = '0.0.0.0/0' or cidr_ipv6 = '::/0' ) and ( ( ip_protocol = '-1' and from_port is null ) or ( from_port <= 9092 and to_port >= 9092 ) ) group by group_id)select arn as resource, case when k.group_id is null then 'ok' else 'alarm' end as status, case when k.group_id is null then sg.group_id || ' ingress restricted for kafka port from 0.0.0.0/0.' else sg.group_id || ' contains ' || k.num_ssh_rules || ' ingress rule(s) allowing kafka port from 0.0.0.0/0.' end as reason , sg.region, sg.account_idfrom aws_vpc_security_group as sg left join ingress_kafka_port as k on k.group_id = sg.group_id;