Description
In a network ACL allow rule, Protocol: -1 covers every protocol for that direction and CIDR. PortRange cannot narrow an all-protocol rule.
Potential impact
Broad inbound rules can expose unnecessary services. Broad outbound rules can permit unintended external communication.
Remediation
Choose the protocols needed for each direction and CIDR. Specify TCP or UDP ports, or ICMP types and codes, as applicable. Distinguish all-protocol denies from required allow exceptions. Check rule order and permit the return traffic in the opposite direction.
Examples
Both excerpts show outbound rule 100 on MyNacl. Supply the routing and return rules before testing a connection to the intended destination.
Before
Resources:
OutboundRule:
Type: AWS::EC2::NetworkAclEntry
Properties:
NetworkAclId: !Ref MyNacl
RuleNumber: 100
Protocol: -1
Egress: true
RuleAction: allow
CidrBlock: 0.0.0.0/0
The first rule allows all protocols to every IPv4 destination.
After
Resources:
OutboundRule:
Type: AWS::EC2::NetworkAclEntry
Properties:
NetworkAclId: !Ref MyNacl
RuleNumber: 100
Protocol: 6
Egress: true
RuleAction: allow
CidrBlock: 172.16.0.0/24
PortRange:
From: 443
To: 443
The second allows only TCP 443 to 172.16.0.0/24. Check the rest of the ACL for other permissions.