The default Amazon EC2 security group must not define inbound or outbound rules because permissive rules on the default group can expose instances to unauthorized access and enable lateral movement between resources.
In CloudFormation, this rule checks AWS::EC2::SecurityGroup resources with Properties.GroupName set to "default" and requires that Properties.SecurityGroupIngress and Properties.SecurityGroupEgress are either absent or empty. Resources with non-empty ingress or egress arrays will be flagged.
If you need to allow specific traffic, create a separate security group with explicit least-privilege rules and attach that group to instances instead of modifying the default group.
Parameters:KeyName:Description:The EC2 Key Pair to allow SSH access to the instanceType:'AWS::EC2::KeyPair::KeyName'Resources:Ec2Instance:Type:'AWS::EC2::Instance'Properties:SecurityGroups:- !Ref InstanceSecurityGroup- MyExistingSecurityGroupKeyName:!Ref KeyNameImageId:ami-7a11e213InstanceSecurityGroup:Type:'AWS::EC2::SecurityGroup'Properties:GroupName:defaultGroupDescription:Enable SSH access via port 22
Non-Compliant Code Examples
Parameters:KeyName:Description:The EC2 Key Pair to allow SSH access to the instanceType:'AWS::EC2::KeyPair::KeyName'Resources:Ec2Instance:Type:'AWS::EC2::Instance'Properties:SecurityGroups:- !Ref InstanceSecurityGroup- MyExistingSecurityGroupKeyName:!Ref KeyNameImageId:ami-7a11e213InstanceSecurityGroup:Type:'AWS::EC2::SecurityGroup'Properties:GroupName:defaultGroupDescription:Enable SSH access via port 22SecurityGroupIngress:- IpProtocol:tcpFromPort:'22'ToPort:'22'CidrIp:0.0.0.0/0SecurityGroupEgress:- IpProtocol:tcpFromPort:'22'ToPort:'22'CidrIp:0.0.0.0/0
1
2
rulesets:- CloudFormation / AWS # Rules to enforce / AWS.
맞춤형 데모 요청
Datadog 시작하기
Ask AI
AI-generated responses may be inaccurate. Verify important info.