Skip to Content
Asterrr's Handbook
3 · Infrastructure security

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.

opens 22config changeNON_COMPLIANTremediateDeveloper editsruleSecurity groupConfig ruleEventBridgeRestrict sourceNotify team
Config records the security group change, evaluates the managed rule, and an automatic remediation or an EventBridge-driven function restores a safe rule.

The Config rule

ItemValue
Managed rulevpc-sg-open-only-to-authorized-ports (identifier VPC_SG_OPEN_ONLY_TO_AUTHORIZED_PORTS)
ResourceAWS::EC2::SecurityGroup
TriggerConfiguration changes and periodic
ParametersauthorizedTcpPorts, authorizedUdpPorts, comma lists or ranges such as 443,1020-1025
LogicLooks 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.

PolicyWhat it does
Common security groupApplies a baseline security group to chosen accounts and resources
Content auditAudits rules for noncompliant entries and can remediate
Usage auditFinds 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

LayerUse
IAM and SCPLimit who may call security group rule changes at all
Security HubControls flag open groups as findings
Systems Manager Session ManagerRemove 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.

Further reading

On this page