Security Group Guardrails
Detect and fix security groups opened to 0.0.0.0/0 with AWS Config, and enforce rules across accounts with Firewall Manager.
The decision: how do you detect and correct a security group opened to the internet, in one account and across the organization?
The scenario. A developer adds an inbound rule that opens SSH to 0.0.0.0/0. The answer is detective plus corrective control, not a blunt network ACL.
The Config rule
| Item | Value |
|---|---|
| Managed rule | vpc-sg-open-only-to-authorized-ports (identifier VPC_SG_OPEN_ONLY_TO_AUTHORIZED_PORTS) |
| Resource | AWS::EC2::SecurityGroup |
| Trigger | Configuration changes and periodic |
| Parameters | authorizedTcpPorts, authorizedUdpPorts, comma lists or ranges such as 443,1020-1025 |
| Logic | Looks only at groups with ingress from 0.0.0.0/0 or ::/0. Non-compliant when such a group allows ports outside your list. Not applicable when no rule has those sources |
Config remediation runs Systems Manager Automation documents, manual or automatic. A custom Lambda reacting through EventBridge is the other common pattern, for example one that rewrites the SSH source to the corporate firewall IP.
Org-wide enforcement
Firewall Manager security group policies give three jobs.
| Policy | What it does |
|---|---|
| Common security group | Applies a baseline security group to chosen accounts and resources |
| Content audit | Audits rules for noncompliant entries and can remediate |
| Usage audit | Finds unused and redundant security groups to clean up |
Start with automatic remediation off, review the effect, then turn it on. Exclude the Firewall Manager administrator account from scope. Avoid pairing it with another tool that fights over the same groups.
Other layers
| Layer | Use |
|---|---|
| IAM and SCP | Limit who may call security group rule changes at all |
| Security Hub | Controls flag open groups as findings |
| Systems Manager Session Manager | Remove the need to open port 22 in the first place |
Exam trap
"Use a network ACL to deny 0.0.0.0/0" blocks every legitimate internet user in the subnet, and other apps break. Fix the group, not the subnet.
Exam signal
"Prevent or automatically correct a security group that allows unrestricted access": AWS Config rule with remediation. "Across all accounts": Firewall Manager.