Description
In an egress rule, IpProtocol: "-1" allows every protocol to the destination. FromPort and ToPort cannot narrow it.
Potential impact
A workload can communicate with external services or transfer data using protocols it does not need.
Remediation
Choose the destination and required protocol. Specify TCP or UDP ports, or ICMP types and codes. Remove broader permissions from the attached groups and test the required external services. Replies to permitted inbound connections already pass through state tracking.
Examples
SourceSG is the group receiving this rule. Define the group and specify one destination CIDR, prefix list or security group.
Before
Resources:
OutboundRule:
Type: AWS::EC2::SecurityGroupEgress
Properties:
IpProtocol: "-1"
FromPort: 0
ToPort: 65535
GroupId: !GetAtt SourceSG.GroupId
Once a destination is supplied, -1 allows all protocols regardless of the displayed port values.
After
Resources:
OutboundRule:
Type: AWS::EC2::SecurityGroupEgress
Properties:
IpProtocol: tcp
FromPort: 443
ToPort: 443
GroupId: !GetAtt SourceSG.GroupId
The second permits only TCP 443. If the application uses HTTPS, verify that it validates the server certificate.