Description
In an inbound rule, IpProtocol: "-1" allows every protocol from the specified source. Port values cannot narrow that permission.
Potential impact
An allowed client could also reach other listening services where the network provides a route.
Remediation
Select the sources and protocols the service needs. Specify ports for TCP or UDP, or types and codes for ICMP. Check other attached groups for broader permissions, then test client connectivity and application authorization.
Examples
TargetSG is the group receiving the rule. Define it and specify one source CIDR, prefix list or source security group.
Before
Resources:
InboundRule:
Type: AWS::EC2::SecurityGroupIngress
Properties:
IpProtocol: "-1"
FromPort: 0
ToPort: 65535
GroupId: !GetAtt TargetSG.GroupId
The first rule allows every protocol from that source.
After
Resources:
InboundRule:
Type: AWS::EC2::SecurityGroupIngress
Properties:
IpProtocol: tcp
FromPort: 443
ToPort: 443
GroupId: !GetAtt TargetSG.GroupId
The second allows only TCP 443. Configure TLS and authentication on the service if it provides HTTPS.