Skip to main content

More Info:

Default security groups should restrict all public traffic to follow AWS security best practices.

Risk Level

Low

Address

Security

Compliance Standards

  • APRA CPS 234 (Australia)
  • AWS Well Architected Framework
  • BSI C5 (Germany)
  • Brazil LGPD
  • CCPA / CPRA (California)
  • CIS AWS
  • CIS Critical Security Controls v8
  • CMMC 2.0
  • CSA Cloud Controls Matrix v4
  • Cloudanix Best Practice
  • DPDPA
  • Digital Operational Resilience Act (EU)
  • FedRAMP
  • GDPR
  • ISO/IEC 27017
  • ISO/IEC 27018
  • ISO/IEC 27701
  • KSA PDPL
  • MAS Technology Risk Management (Singapore)
  • MITRE ATT&CK (Cloud)
  • NIS2 Directive
  • NIST
  • NIST CSF
  • NIST SP 800-171
  • NYDFS 23 NYCRR 500
  • PCI
  • Reserve Bank of India (RBI) Cyber Security Framework
  • Reserve Bank of India (RBI) Master Direction – Information Technology Framework
  • SOC2
  • SWIFT Customer Security Controls Framework
  • Sarbanes-Oxley IT General Controls
  • UK NCSC Cyber Assessment Framework

Triage and Remediation

Remediation

Using Console

To remediate the misconfiguration “Default Security Group Should Not Allow Unrestricted Public Traffic” for AWS using the AWS console, follow the steps below:
  1. Log in to the AWS Management Console.
  2. Navigate to the EC2 service.
  3. In the left-hand menu, click on “Security Groups”.
  4. Select the default security group.
  5. In the “Inbound Rules” tab, remove any rules that allow unrestricted public traffic (i.e. 0.0.0.0/0).
  6. Add specific rules for the required ports and protocols to allow traffic only from authorized sources.
  7. Review and save the changes.
By following these steps, you will remediate the misconfiguration and ensure that the default security group does not allow unrestricted public traffic.

To remediate the misconfiguration “Default Security Group Should Not Allow Unrestricted Public Traffic” for AWS using AWS CLI, follow the below steps:
  1. Open the AWS CLI on your local machine.
  2. Run the following command to get the ID of the default security group in your AWS account:
  3. Run the following command to update the inbound rules of the default security group to allow only necessary traffic:
    This command will remove all the inbound rules that allow unrestricted public traffic.
  4. Now, add the necessary inbound rules to the default security group using the following command:
    Replace <port-number> with the port number you want to allow traffic for and <ip-address> with the IP address range you want to allow traffic from.
  5. Repeat step 4 for all the necessary inbound rules.
  6. Verify the updated inbound rules of the default security group using the following command:
    This command will display the updated inbound rules for the default security group.
By following the above steps, you can remediate the misconfiguration “Default Security Group Should Not Allow Unrestricted Public Traffic” for AWS using AWS CLI.
To remediate the misconfiguration of default security group allowing unrestricted public traffic in AWS using Python, you can follow these steps:
  1. Import the necessary AWS SDK libraries and modules in Python.
  1. Create a connection to the AWS EC2 service using the boto3 library.
  1. Get the default security group ID using the describe_security_groups() method.
  1. Revoke the ingress rules that allow unrestricted public traffic using the revoke_security_group_ingress() method.
  1. Confirm that the ingress rules have been revoked by describing the security group again.
This should remediate the misconfiguration of default security group allowing unrestricted public traffic in AWS using Python.
  • Substitute VPC_ID with the ID of the VPC that owns the default security group.
  • Substitute INTERNAL_CIDR with your internal network range(s) that should be allowed, or remove/adjust the block per your requirements.
  • This does not force replacement of the default security group; Terraform will update its rules in place, which can impact connectivity just like the CLI revoke-security-group-ingress commands.
For verification, terraform plan should show the aws_default_security_group.default resource modifying its ingress (and possibly egress) so that any rules with cidr_blocks = ["0.0.0.0/0"] or ipv6_cidr_blocks = ["::/0"] on ingress are being removed.

Additional Reading: