EC2 Security-Group Auditor
An AWS CloudOps agent skill that analyzes EC2 security group inbound rules
to identify publicly exposed ports, classify each security group's exposure
level with a CVSS-style risk score, and provide specific remediation guidance
mapped to compliance controls.
Quick verdict logic (at-a-glance)
For EACH inbound rule: classify SOURCE (PUBLIC / RESTRICTED /
CONDITIONAL), then PORT (CRITICAL / NON_CRITICAL). Combine:
PUBLIC + CRITICAL → OPEN; PUBLIC + NON_CRITICAL →
PUBLIC_NONCRITICAL; RESTRICTED source → RESTRICTED. SG verdict =
WORST per-rule verdict (OPEN > PUBLIC_NONCRITICAL > RESTRICTED).
Sources arrive in FOUR distinct API arrays — IpRanges, Ipv6Ranges,
UserIdGroupPairs, PrefixListIds — iterate all four or you will miss
IPv6 exposure, SG-ref cycles, and prefix-list drift. Full procedure,
port-range intersection rules, and edge cases in §"Classification logic";
deep AWS dataplane behavior in §"AWS dataplane expert details".
Activation keywords
security group, SG, ec2, inbound rule, port exposure, open SSH, open RDP,
open database, 0.0.0.0/0, public port, network exposure, CIDR audit,
firewall rule, attack surface, compliance check, VPC security, prefix list,
CIS benchmark, PCI-DSS.
Reasoning framework (Mindset — why the procedure is ordered this way)
Security groups are stateful — return traffic for an allowed inbound
flow is automatically permitted, so there is no need for "return port"
rules. That confusion is common: engineers add 32768-65535 inbound from
0.0.0.0/0 thinking it is needed for responses — it is not; that rule is
a side channel for inbound traffic and should be removed. Because SGs are
stateful and evaluated per-rule by the AWS dataplane, the verdict for a
security group is the worst (most permissive) verdict of any individual
inbound rule — a single open rule creates an attack surface even if
every other rule is locked down. The procedure below evaluates each rule
independently first, then aggregates to the worst case. This is the
inverse of firewall "default deny" reasoning: a restrictive rule does NOT
narrow an already-open rule on the same SG.
AWS dataplane expert details (Mindset — non-obvious AWS behavior)
Full AWS dataplane expert details moved to
references/advanced-patterns.md.
Classification logic (Process — per-rule evaluation, worst-case aggregation)
Evaluate EACH inbound rule independently, assign a per-rule verdict, then
take the worst verdict across all rules as the SG's verdict.
OPEN > PUBLIC_NONCRITICAL > RESTRICTED.
Decision procedure (pseudocode)
function classify_sg(sg):
per_rule_verdicts = []
for rule in sg.inbound_rules:
src = classify_source(rule.source) # PUBLIC | RESTRICTED | CONDITIONAL
port = classify_port(rule.port, rule.protocol) # CRITICAL | NON_CRITICAL | N_A
if src == PUBLIC:
if port == CRITICAL:
per_rule_verdicts.append(OPEN)
elif port == NON_CRITICAL:
per_rule_verdicts.append(PUBLIC_NONCRITICAL)
else:
per_rule_verdicts.append(PUBLIC_NONCRITICAL) # ICMP-only
elif src == CONDITIONAL: # managed prefix list
entries = inspect_prefix_list(rule.source)
if any_entry_public(entries):
if port == CRITICAL: per_rule_verdicts.append(OPEN)
else: per_rule_verdicts.append(PUBLIC_NONCRITICAL)
else:
per_rule_verdicts.append(RESTRICTED)
else: # RESTRICTED source
per_rule_verdicts.append(RESTRICTED)
if no inbound rules: return RESTRICTED
return worst(per_rule_verdicts) # OPEN > PUBLIC_NONCRITICAL > RESTRICTED
function classify_port(port, protocol):
if protocol == -1: return CRITICAL # ALL protocols
if port == "0-65535": return CRITICAL # all TCP/UDP ports
if intersects(port, HIGH_RISK_PORTS): return CRITICAL
if port in [80, 443, 8080]: return NON_CRITICAL
if protocol == ICMP: return N_A # handled separately
return NON_CRITICAL # unknown port, non-critical default
Port range intersection (the most common model error)
A rule with a port range must be checked for intersection with the
high-risk registry (§"High-risk port registry"). Examples:
20-25 contains 22 (SSH) and 25 (SMTP) → CRITICAL → OPEN if PUBLIC
3300-3400 contains 3306 (MySQL) → CRITICAL → OPEN if PUBLIC
440-450 contains 443 only → does NOT intersect high-risk → PUBLIC_NONCRITICAL if PUBLIC
0-65535 intersects all high-risk ports → always CRITICAL
Multi-port and mixed-protocol entries
- AWS SG rules accept a single port or a port range — NOT a
comma-separated list. Each port or range is a separate rule entry. If
the input shows comma-separated ports in one rule, split into per-rule
evaluations and aggregate.
- For ICMP,
Port maps to Type:Code: 8 = Echo Request, 0 =
Echo Reply, 13 = Timestamp, -1:-1 = ALL. An ICMP-only rule from a
PUBLIC source is PUBLIC_NONCRITICAL (reconnaissance, not data-plane
access).
- A rule with the same port on both TCP and UDP (e.g., RDP 3389 over
TCP+UDP): evaluate each protocol independently, take the worse verdict.
Worked examples
Mixed rules (web-tier pattern): SG has 443 TCP 0.0.0.0/0 AND
22 TCP 10.0.0.0/8. Rule 1 = PUBLIC_NONCRITICAL (public source,
non-critical port); Rule 2 = RESTRICTED (private source, even though
port 22 is critical). Aggregate = PUBLIC_NONCRITICAL. Do NOT
classify as OPEN just because SSH appears — check the SOURCE first.
All-ports range: SG has 0-65535 TCP 0.0.0.0/0. Range intersects
the entire high-risk registry → OPEN. Do NOT treat 0-65535 as a
single non-critical port.
Secondary worked examples moved to
references/worked-examples.md.
Risk scoring and compliance mapping
CVSS-style severity per verdict
| Verdict + context |
Severity |
CVSS range |
Action |
OPEN — all-ports (0-65535) or protocol -1 from PUBLIC |
Critical |
9.8–10.0 |
P0: remediate immediately |
| OPEN — administrative ports (22, 23, 3389, 5900, 2375) |
Critical |
9.0–9.8 |
P0: incident-grade response |
| OPEN — K8s/Docker (6443, 10250, 2379, 2375, 2376) |
Critical |
9.0–9.8 |
P0: cluster takeover risk |
| OPEN — databases (3306, 5432, 1433, 1521, 27017, 6379, 9200) |
Critical |
8.5–9.3 |
P1: data exfiltration risk |
| OPEN — amplification (UDP 53, UDP 123, UDP 11211) |
High |
7.5–8.0 |
P1: DDoS reflection vector |
| PUBLIC_NONCRITICAL — direct to instance (no ALB) |
Medium |
4.3–5.3 |
P2: add ALB or verify intent |
| PUBLIC_NONCRITICAL — behind ALB/WAF |
Low |
0.0–3.1 |
P3: informational |
| RESTRICTED |
None |
0.0 |
No action |
Compliance framework mapping
Each finding maps to specific control IDs that auditors and compliance
teams reference:
| Finding |
CIS AWS Benchmark v3.0 |
PCI-DSS v4.0 |
NIST SP 800-53 Rev. 5 |
SSH (22) from 0.0.0.0/0 |
5.1 |
1.2.1, 1.3.1 |
SC-7(5), AC-4 |
RDP (3389) from 0.0.0.0/0 |
5.2 |
1.2.1, 1.3.1 |
SC-7(5), AC-4 |
Any other port from 0.0.0.0/0 |
5.3 |
1.2.1 |
SC-7(5) |
| Default SG allows any traffic |
5.4 |
1.2.2 |
SC-7, SC-7(12) |
| DB/admin port on public SG |
— |
1.3.4, 1.4.1 |
SC-7(5), SC-7(11) |
| Amplification vector (UDP DNS/NTP) |
— |
1.3.6 |
SC-7(20), SC-5 |
CIS 5.1/5.2 are the most commonly failed controls in AWS environments.
Any OPEN verdict on ports 22 or 3389 is a direct CIS 5.1/5.2 violation
and should be cited in the REMEDIATION field.
NEVER (critical anti-patterns — apply before emitting a verdict)
NEVER classify SSH (port 22) or RDP (port 3389) open to 0.0.0.0/0
(or ::/0) as anything other than OPEN. Botnets enumerate these
ports within minutes. This is a direct CIS 5.1/5.2 violation.
NEVER classify 0-65535 (all TCP ports) or protocol -1 (all
protocols) from 0.0.0.0/0 as merely RESTRICTED or
PUBLIC_NONCRITICAL. All-ports-to-internet is maximum exposure.
NEVER assume a port range is safe because it is "narrow." A range
20-25 contains 22 (SSH); 3300-3310 contains 3306 (MySQL).
Always intersect the range against the high-risk registry.
NEVER classify a rule as OPEN solely because a high-risk port
appears — check the SOURCE first. Port 22 from 10.0.0.0/8 is
RESTRICTED. Confusing these produces false-positive OPEN verdicts.
NEVER assume a port is safe because the service is "just a database."
MySQL, PostgreSQL, Redis, MongoDB, Elasticsearch exposed to the
internet are the root cause of countless data breaches.
NEVER treat a managed prefix list (pl-xxxxxxxx) as automatically
RESTRICTED. AWS-managed lists for CloudFront, S3, and DynamoDB contain
public IPs. Inspect with
aws ec2 get-managed-prefix-list-entries --prefix-list-id <pl-id>.
NEVER treat 10.0.0.0/7 as fully private. The /7 spans 10/8
(RFC 1918) AND 11/8 (public). Any CIDR broader than the RFC 1918
boundaries is partially public → classify as PUBLIC.
NEVER add inbound "ephemeral" rules (1024-65535 from 0.0.0.0/0)
for return traffic. Security groups are stateful — responses to
outbound flows are automatically allowed. This misconfiguration is
common and creates a wide attack surface for zero benefit.
NEVER assume ::/0 (IPv6 any) is less dangerous than 0.0.0.0/0.
AWS IPv6 addresses are globally routable by default. A dual-stack
instance with ::/0 on port 22 is just as exposed as IPv4.
NEVER dismiss UDP DNS (port 53) from 0.0.0.0/0. An open UDP 53
resolver is a DNS amplification reflector (~50-80× amplification).
AWS throttles accounts hosting open resolvers. Classify as OPEN.
NEVER permit ICMP ALL (type -1) from 0.0.0.0/0 without flagging
it. While ICMP alone is PUBLIC_NONCRITICAL, ALL enables timestamp
queries (OS fingerprinting), address-mask queries (network mapping),
and Smurf amplification.
NEVER expose SNMP (UDP 161) to the internet. Community strings
(public, private) are sent in cleartext in SNMPv1/v2c; the full
network topology and configuration are leaked. Classify as OPEN.
NEVER assume overlapping or redundant CIDR rules are harmless. AWS
evaluates every inbound allow rule independently (UNION semantics —
there is NO first-match priority and NO deny in SGs; deny lives in
NACLs). A port with BOTH 0.0.0.0/0 and 10.0.0.0/8 sources means
the broader (0.0.0.0/0) rule is the effective exposure; the
restrictive rule adds nothing and must be REMOVED, not narrowed.
Flag every duplicate and overlap as a cleanup item — they obscure
the real posture during manual review AND defeat naive
grep "0.0.0.0/0" audits.
NEVER miss split-horizon CIDR evasion. Two rules 0.0.0.0/1 and
128.0.0.0/1 on the same port cover the ENTIRE IPv4 space, yet
neither literally equals 0.0.0.0/0. The same applies to /2 quad
splits and /3 octets. Always union complementary halves before
classifying — a per-rule RESTRICTED verdict can hide a union that is
effectively PUBLIC.
NEVER trust a customer-managed prefix list as permanently RESTRICTED.
The list owner can add public CIDRs at any time without changing the
SG rule. Re-audit prefix-list entries on every review cycle. Flag
any pl-xxxxxxxx reference in a RESTRICTED SG for periodic
re-validation.
NEVER recommend simply deleting a rule without providing the
replacement. SG rule deletion is a live-affecting change — the
replacement (bastion SG reference, SSM Session Manager, app-tier SG
reference) must be specified so the operator can apply it without
losing application access.
Source classification (Reference)
Classify the Source field BEFORE evaluating the port — misclassifying a
source is the most common auditor error.
| Source |
Class |
Notes |
0.0.0.0/0 |
PUBLIC (IPv4 internet) |
All IPv4 addresses. |
::/0 |
PUBLIC (IPv6 internet) |
All IPv6 addresses. Treat identically. |
0.0.0.0/1 + 128.0.0.0/1 |
PUBLIC (split-horizon evasion) |
Union covers all IPv4; classify each as PUBLIC. |
| CIDR broader than RFC 1918 boundaries |
PUBLIC (partial) |
e.g., 10.0.0.0/7 spans 10/8 (private) AND 11/8 (public). |
100.64.0.0/10 |
RESTRICTED (CGNAT, RFC 6598) |
Carrier-grade NAT; flag for review. |
10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 |
RESTRICTED (RFC 1918) |
Standard private ranges. |
sg-xxxxxxxx |
RESTRICTED (SG reference) |
Self-references valid for inter-tier comms. |
pl-xxxxxxxx |
CONDITIONAL |
See §"Prefix-list evaluation procedure". |
Specific public IP /32 |
RESTRICTED (single source) |
Narrow; flag for rotation review. |
| Missing / blank |
RESTRICTED |
Treat conservatively as no source. |
Prefix-list evaluation procedure (Reference)
When a rule's source is pl-xxxxxxxx, classification is CONDITIONAL on the
prefix list's entries:
Step 1 — Identify the type
aws ec2 describe-managed-prefix-lists --prefix-list-ids pl-xxxxxxxx
Check OwnerId: if it matches your account, it is customer-managed;
if Amazon, it is AWS-managed (CloudFront, S3, DynamoDB).
Step 2 — Enumerate entries
aws ec2 get-managed-prefix-list-entries --prefix-list-id pl-xxxxxxxx
Step 3 — Classify
- ALL entries RFC 1918 or
/32 known IPs → RESTRICTED.
- ANY public entry → treat as PUBLIC for classification.
- AWS-managed exception (CloudFront/S3/DynamoDB): entries are AWS
service IPs — effectively public but trusted infrastructure. Classify
as PUBLIC_NONCRITICAL for non-critical ports (443, 80); OPEN
for critical ports (22, 3389, databases, all-ports). AWS edge IPs
should not be trusted with administrative access.
High-risk port registry (Reference)
Administrative access
| Port(s) |
Protocol |
Service |
Risk |
| 22 |
TCP |
SSH |
Brute-force #1; CIS 5.1. |
| 23 |
TCP |
Telnet |
Unencrypted; trivially exploitable. |
| 3389 |
TCP/UDP |
RDP |
Brute-force; BlueKeep. CIS 5.2. |
| 5900-5910 |
TCP |
VNC |
Often no auth; trivial takeover. |
| 2375, 2376 |
TCP |
Docker daemon |
Container RCE; full host compromise. |
Databases
| Port(s) |
Protocol |
Service |
Risk |
| 3306 |
TCP |
MySQL / Aurora MySQL |
Data exfiltration, ransomware. |
| 5432 |
TCP |
PostgreSQL / Aurora PG |
Data exfiltration, ransomware. |
| 1433 |
TCP |
MSSQL |
Data exfil; SA brute-force. |
| 1521 |
TCP |
Oracle TNS |
Data exfil; TNS poisoning. |
| 27017-27019 |
TCP |
MongoDB |
NoSQL ransomware. |
| 6379 |
TCP |
Redis |
Cryptomining, data exfil, ransomware. |
| 9042 |
TCP |
Cassandra |
NoSQL data exfiltration. |
| 5984 |
TCP |
CouchDB |
Default "admin party" on old versions. |
| 11211 |
TCP/UDP |
Memcached |
UDP amplification DDoS (~51,000×). |
| 9200, 9300 |
TCP |
Elasticsearch |
Data exfil + ransomware. |
Message queues / streaming / container orchestration
| Port(s) |
Protocol |
Service |
Risk |
| 5671, 5672 |
TCP |
AMQP / RabbitMQ |
Queue manipulation. |
| 9092 |
TCP |
Kafka |
Topic read/write; data tampering. |
| 6443 |
TCP |
Kubernetes API |
Full cluster takeover. |
| 10250 |
TCP |
Kubelet |
Per-node RCE. |
| 2379, 2380 |
TCP |
etcd |
K8s control-plane root. |
Windows / RPC / directory
| Port(s) |
Protocol |
Service |
Risk |
| 135, 139, 445 |
TCP |
MS-RPC / NetBIOS / SMB |
WannaCry; EternalBlue. |
| 389, 636 |
TCP |
LDAP / LDAPS |
Credential theft. |
| 25 |
TCP |
SMTP |
Open-relay spam. |
Amplification vectors (non-TCP)
| Port(s) |
Protocol |
Service |
Amplification factor |
| 53 |
UDP |
DNS |
~50-80× |
| 123 |
UDP |
NTP (MONLIST) |
~556× |
| 161 |
UDP |
SNMP |
~3-15× |
| 1900 |
UDP |
SSDP / UPnP |
~30× |
| 5353 |
UDP |
mDNS |
Local enumeration |
Maximum exposure
| Port(s) |
Protocol |
Risk |
| 0-65535 |
TCP |
Every TCP service attackable. |
All (-1) |
ALL |
TCP + UDP + ICMP + SCTP; worst case. |
Non-critical (PUBLIC_NONCRITICAL when PUBLIC)
| Port(s) |
Protocol |
Notes |
| 80 |
TCP |
Acceptable behind ALB; verify redirect to 443. |
| 443 |
TCP |
Acceptable for web-facing tiers behind ALB/WAF. |
| 8080 |
TCP |
Acceptable behind ALB; verify not admin panel. |
Output format (Process — per security group)
SECURITY_GROUP: <name>
VERDICT: OPEN | PUBLIC_NONCRITICAL | RESTRICTED
SEVERITY: Critical | High | Medium | Low | None
CIS_CONTROLS: <e.g., "5.1" or "5.2, 5.3" or "N/A">
REASON: <1-2 sentences citing the specific rules and per-rule verdicts>
REMEDIATION: <specific action, or "None required" if RESTRICTED>
Pre-flight safety checks (Process — run before any remediation CLI)
- Capture current SG rule set:
aws ec2 describe-security-groups --group-ids <sg-id> --output json > /tmp/<sg-id>-backup-$(date +%s).json.
- Verify rollback: after backup, confirm the file is non-empty and parses
as valid JSON (
python3 -c "import json; json.load(open('<file>'))").
A truncated/empty backup is useless for rollback.
- Prefer additive changes (add restrictive rule, verify, then remove
open rule) over destructive changes (delete first).
- For OPEN verdicts on administrative ports (22, 3389, 2375, 6443,
10250), confirm the operator has an alternative access path (SSM
Session Manager, console, or another SG rule) BEFORE removing the
open rule.
- Verify dependency impact:
aws ec2 describe-network-interfaces --filters Name=group-id,Values=<sg-id>
— removing a rule that a load balancer, peered VPC, or Lambda function
depends on will cause an outage.
- For prefix-list sources, snapshot entries:
aws ec2 get-managed-prefix-list-entries --prefix-list-id <pl-id> --output json > /tmp/<pl-id>-backup-$(date +%s).json.
Remediation guidance (Process — per verdict)
For OPEN security groups:
- SSH (22): prefer AWS Systems Manager Session Manager — no open
ports, IAM-authenticated, fully audited. Fallback: bastion SG ref.
- RDP (3389): restrict to a bastion or jump-SG ref.
- Databases (3306, 5432, 1433, 1521, 27017, 6379, 9042, 5984, 11211,
9200): restrict to the application-tier SG ID ONLY. Database subnets
should have no IGW route (private subnet with NAT, not public).
- Elasticsearch (9200, 9300): restrict to ingestion SG + dashboard
SG; transport port (9300) never leaves the peer set.
- Docker daemon (2375, 2376): never expose to internet. Bind to
localhost or private VPN; enable TLS client cert auth on 2376.
- Kubernetes API (6443) / Kubelet (10250) / etcd (2379-2380):
restrict to control-plane and operator CIDRs. P0 remediation.
- SMB (445) / NetBIOS (139): remove entirely; restrict to
directory-member SG references.
- DNS (UDP 53): if not a designated resolver, remove. If it IS a
resolver, restrict to known client CIDRs and enable RRL.
- SNMP (UDP 161): restrict to monitoring SG; upgrade to SNMPv3
authPriv.
- Memcached UDP: disable UDP entirely; amplification is severe.
- All-ports (0-65535) / protocol -1: delete and recreate with ONLY
the specific ports the workload requires.
For PUBLIC_NONCRITICAL security groups:
- Public HTTPS (443): verify the SG is attached to an ALB/NLB, not
directly to backend instances. The backend SG should reference the ALB
SG ID, not
0.0.0.0/0.
- Public HTTP (80): acceptable only for redirect-to-HTTPS.
- ICMP: restrict to a known monitoring CIDR; never allow ICMP ALL.
For RESTRICTED security groups:
- No remediation required for RFC 1918 / SG-ref /
/32 rules.
- If rules use
100.64.0.0/10 (CGNAT) or broad /7–/9 CIDRs,
flag for review.
- For customer-managed prefix-list references, schedule periodic
re-audit of list entries — the list owner can add public CIDRs without
changing the SG rule.
- Recommend enabling VPC Flow Logs for ongoing auditing.
Recent AWS features (2024-2026)
Recent AWS features notes moved to
references/advanced-patterns.md.
Section taxonomy (CloudOps auditor pattern)
Pattern: CloudOps Auditor — Mindset → Process → Reference → Tool.
Each major section is tagged inline with its pattern role so the
structure is machine-recognizable and aids comprehension:
- Frontmatter — name, description, version.
- Activation keywords — discoverability terms.
- Quick verdict logic — at-a-glance summary (progressive disclosure entry point).
- Reasoning framework
[Mindset] — the why.
- AWS dataplane expert details
[Mindset] — non-obvious AWS behavior.
- Classification logic
[Process] — per-rule evaluation then
worst-case aggregation, as formal pseudocode.
- Risk scoring and compliance mapping
[Process] — CVSS severity +
CIS/PCI-DSS/NIST control IDs.
- NEVER
[Process] — anti-patterns applied before verdict.
- Source classification
[Reference] — CIDR / SG-ref / prefix-list
decision table.
- Prefix-list evaluation procedure
[Reference] — programmatic
inspection.
- High-risk port registry
[Reference] — categorized port tables.
- Output format
[Tool] — per-SG report shape.
- Pre-flight safety checks
[Process] — non-destructive guards.
- Remediation guidance
[Tool] — per-verdict action plan.
References (load on demand)
- references/advanced-patterns.md — AWS dataplane expert details (union evaluation, conntrack ceiling, four source arrays, quotas, peering/RAM, prefix-list drift, Config/Security Hub controls, Reachability Analyzer) and recent AWS features (moved from this file)
- references/diagnostic-commands.md — effective enumeration queries for scoping an audit (moved from this file)
- references/worked-examples.md — secondary worked examples: private-CIDR database, prefix-list source, IPv6 dual-stack, overlapping CIDRs, split-horizon evasion, prefix-list drift (moved from this file)
- references/security-group-exposure-guide.md — high-risk port registry, CIDR/source classification, remediation patterns
Domain
AWS CloudOps / EC2 Network Security & Compliance.
AWS documentation
1---2name: ec2-security-group-auditor3description: 'Classifies each EC2 security group''s inbound exposure as OPEN, PUBLIC_NONCRITICAL, or RESTRICTED (worst-case per-rule aggregation) and emits remediation mapped to CIS AWS Foundations / PCI-DSS / NIST SP 800-53. Invoke when: (a) pre-production SG review, (b) periodic CIS/PCI-DSS compliance audit, (c) incident response involving suspected network exposure, or (d) VPC/account security-baseline validation. Recognizes port ranges, non-TCP protocols, managed prefix lists, IPv6 sources, split-horizon CIDR pairs, and overlapping rules. Keywords: security group, SG, ec2, inbound rule, port exposure, 0.0.0.0/0, CIDR audit, attack surface, compliance check, VPC security.'4license: Apache-2.05compatibility: Requires an LLM-based agent runtime (Claude Code, Cursor, Windsurf) or direct invocation. No AWS CLI calls needed for classification — the skill operates on provided SG rule data. For live AWS audits, requires aws-cli >= 2.0 with ec2:DescribeSecurityGroups and ec2:GetManagedPrefixListEntries permissions.6metadata:7 source: https://skillmd.com/skills/jhkchan/ec2-security-group-auditor8 domain: aws-cloudops9 complexity: medium10 requires_llm: 'true'11 phase: '2'12 supports_pipeline: 'true'13 family: Security14 verdict_shape: OPEN | PUBLIC_NONCRITICAL | RESTRICTED15 version: 0.4.016 author: Jacky Chan — AWS Community Builder17 tags: aws, ec2, security-group, network-security, compliance, audit18 dependencies: aws-orchestrator19 keywords: security group, SG, ec2, inbound rule, port exposure, 0.0.0.0/0, CIDR audit, attack surface, compliance check, VPC security, CIS benchmark, PCI-DSS, NIST SP 800-53, network exposure, prefix list20 when_to_use: Use when reviewing EC2 security group inbound rules for public exposure, compliance auditing against CIS AWS Foundations Benchmark / PCI-DSS / NIST SP 800-53, incident response involving suspected network exposure, or onboarding a new VPC or account for security baseline validation.21---2223# EC2 Security-Group Auditor2425An AWS CloudOps agent skill that analyzes EC2 security group inbound rules26to identify publicly exposed ports, classify each security group's exposure27level with a CVSS-style risk score, and provide specific remediation guidance28mapped to compliance controls.2930## Quick verdict logic (at-a-glance)3132For EACH inbound rule: classify **SOURCE** (PUBLIC / RESTRICTED /33CONDITIONAL), then **PORT** (CRITICAL / NON_CRITICAL). Combine:34PUBLIC + CRITICAL → **OPEN**; PUBLIC + NON_CRITICAL →35**PUBLIC_NONCRITICAL**; RESTRICTED source → **RESTRICTED**. SG verdict =36WORST per-rule verdict (`OPEN > PUBLIC_NONCRITICAL > RESTRICTED`).37Sources arrive in FOUR distinct API arrays — `IpRanges`, `Ipv6Ranges`,38`UserIdGroupPairs`, `PrefixListIds` — iterate all four or you will miss39IPv6 exposure, SG-ref cycles, and prefix-list drift. Full procedure,40port-range intersection rules, and edge cases in §"Classification logic";41deep AWS dataplane behavior in §"AWS dataplane expert details".4243## Activation keywords4445security group, SG, ec2, inbound rule, port exposure, open SSH, open RDP,46open database, 0.0.0.0/0, public port, network exposure, CIDR audit,47firewall rule, attack surface, compliance check, VPC security, prefix list,48CIS benchmark, PCI-DSS.4950## Reasoning framework (Mindset — why the procedure is ordered this way)5152Security groups are **stateful** — return traffic for an allowed inbound53flow is automatically permitted, so there is no need for "return port"54rules. That confusion is common: engineers add `32768-65535` inbound from55`0.0.0.0/0` thinking it is needed for responses — it is not; that rule is56a side channel for inbound traffic and should be removed. Because SGs are57stateful and evaluated per-rule by the AWS dataplane, the verdict for a58security group is the **worst (most permissive) verdict of any individual59inbound rule** — a single open rule creates an attack surface even if60every other rule is locked down. The procedure below evaluates each rule61independently first, then aggregates to the worst case. This is the62inverse of firewall "default deny" reasoning: a restrictive rule does NOT63narrow an already-open rule on the same SG.6465## AWS dataplane expert details (Mindset — non-obvious AWS behavior)66Full AWS dataplane expert details moved to67[references/advanced-patterns.md](references/advanced-patterns.md).6869## Classification logic (Process — per-rule evaluation, worst-case aggregation)7071Evaluate EACH inbound rule independently, assign a per-rule verdict, then72take the **worst** verdict across all rules as the SG's verdict.73`OPEN > PUBLIC_NONCRITICAL > RESTRICTED`.7475### Decision procedure (pseudocode)7677```78function classify_sg(sg):79 per_rule_verdicts = []80 for rule in sg.inbound_rules:81 src = classify_source(rule.source) # PUBLIC | RESTRICTED | CONDITIONAL82 port = classify_port(rule.port, rule.protocol) # CRITICAL | NON_CRITICAL | N_A8384 if src == PUBLIC:85 if port == CRITICAL:86 per_rule_verdicts.append(OPEN)87 elif port == NON_CRITICAL:88 per_rule_verdicts.append(PUBLIC_NONCRITICAL)89 else:90 per_rule_verdicts.append(PUBLIC_NONCRITICAL) # ICMP-only91 elif src == CONDITIONAL: # managed prefix list92 entries = inspect_prefix_list(rule.source)93 if any_entry_public(entries):94 if port == CRITICAL: per_rule_verdicts.append(OPEN)95 else: per_rule_verdicts.append(PUBLIC_NONCRITICAL)96 else:97 per_rule_verdicts.append(RESTRICTED)98 else: # RESTRICTED source99 per_rule_verdicts.append(RESTRICTED)100101 if no inbound rules: return RESTRICTED102 return worst(per_rule_verdicts) # OPEN > PUBLIC_NONCRITICAL > RESTRICTED103104function classify_port(port, protocol):105 if protocol == -1: return CRITICAL # ALL protocols106 if port == "0-65535": return CRITICAL # all TCP/UDP ports107 if intersects(port, HIGH_RISK_PORTS): return CRITICAL108 if port in [80, 443, 8080]: return NON_CRITICAL109 if protocol == ICMP: return N_A # handled separately110 return NON_CRITICAL # unknown port, non-critical default111```112113### Port range intersection (the most common model error)114115A rule with a port **range** must be checked for **intersection** with the116high-risk registry (§"High-risk port registry"). Examples:117- `20-25` contains 22 (SSH) and 25 (SMTP) → CRITICAL → OPEN if PUBLIC118- `3300-3400` contains 3306 (MySQL) → CRITICAL → OPEN if PUBLIC119- `440-450` contains 443 only → does NOT intersect high-risk → PUBLIC_NONCRITICAL if PUBLIC120- `0-65535` intersects all high-risk ports → always CRITICAL121122### Multi-port and mixed-protocol entries123124- AWS SG rules accept a **single port** or a **port range** — NOT a125 comma-separated list. Each port or range is a separate rule entry. If126 the input shows comma-separated ports in one rule, split into per-rule127 evaluations and aggregate.128- For **ICMP**, `Port` maps to `Type:Code`: `8` = Echo Request, `0` =129 Echo Reply, `13` = Timestamp, `-1:-1` = ALL. An ICMP-only rule from a130 PUBLIC source is PUBLIC_NONCRITICAL (reconnaissance, not data-plane131 access).132- A rule with the same port on **both TCP and UDP** (e.g., RDP 3389 over133 TCP+UDP): evaluate each protocol independently, take the worse verdict.134135### Worked examples136137- **Mixed rules (web-tier pattern):** SG has `443 TCP 0.0.0.0/0` AND138 `22 TCP 10.0.0.0/8`. Rule 1 = PUBLIC_NONCRITICAL (public source,139 non-critical port); Rule 2 = RESTRICTED (private source, even though140 port 22 is critical). Aggregate = **PUBLIC_NONCRITICAL**. Do NOT141 classify as OPEN just because SSH appears — check the SOURCE first.142143- **All-ports range:** SG has `0-65535 TCP 0.0.0.0/0`. Range intersects144 the entire high-risk registry → **OPEN**. Do NOT treat `0-65535` as a145 single non-critical port.146Secondary worked examples moved to147[references/worked-examples.md](references/worked-examples.md).148149## Risk scoring and compliance mapping150151### CVSS-style severity per verdict152153| Verdict + context | Severity | CVSS range | Action |154| --- | --- | --- | --- |155| OPEN — all-ports (`0-65535`) or protocol `-1` from PUBLIC | **Critical** | 9.8–10.0 | P0: remediate immediately |156| OPEN — administrative ports (22, 23, 3389, 5900, 2375) | **Critical** | 9.0–9.8 | P0: incident-grade response |157| OPEN — K8s/Docker (6443, 10250, 2379, 2375, 2376) | **Critical** | 9.0–9.8 | P0: cluster takeover risk |158| OPEN — databases (3306, 5432, 1433, 1521, 27017, 6379, 9200) | **Critical** | 8.5–9.3 | P1: data exfiltration risk |159| OPEN — amplification (UDP 53, UDP 123, UDP 11211) | **High** | 7.5–8.0 | P1: DDoS reflection vector |160| PUBLIC_NONCRITICAL — direct to instance (no ALB) | **Medium** | 4.3–5.3 | P2: add ALB or verify intent |161| PUBLIC_NONCRITICAL — behind ALB/WAF | **Low** | 0.0–3.1 | P3: informational |162| RESTRICTED | **None** | 0.0 | No action |163164### Compliance framework mapping165166Each finding maps to specific control IDs that auditors and compliance167teams reference:168169| Finding | CIS AWS Benchmark v3.0 | PCI-DSS v4.0 | NIST SP 800-53 Rev. 5 |170| --- | --- | --- | --- |171| SSH (22) from `0.0.0.0/0` | **5.1** | 1.2.1, 1.3.1 | SC-7(5), AC-4 |172| RDP (3389) from `0.0.0.0/0` | **5.2** | 1.2.1, 1.3.1 | SC-7(5), AC-4 |173| Any other port from `0.0.0.0/0` | **5.3** | 1.2.1 | SC-7(5) |174| Default SG allows any traffic | **5.4** | 1.2.2 | SC-7, SC-7(12) |175| DB/admin port on public SG | — | **1.3.4**, 1.4.1 | SC-7(5), SC-7(11) |176| Amplification vector (UDP DNS/NTP) | — | 1.3.6 | SC-7(20), SC-5 |177178**CIS 5.1/5.2** are the most commonly failed controls in AWS environments.179Any OPEN verdict on ports 22 or 3389 is a direct CIS 5.1/5.2 violation180and should be cited in the REMEDIATION field.181182## NEVER (critical anti-patterns — apply before emitting a verdict)183184- NEVER classify SSH (port 22) or RDP (port 3389) open to `0.0.0.0/0`185 (or `::/0`) as anything other than **OPEN**. Botnets enumerate these186 ports within minutes. This is a direct CIS 5.1/5.2 violation.187188- NEVER classify `0-65535` (all TCP ports) or protocol `-1` (all189 protocols) from `0.0.0.0/0` as merely RESTRICTED or190 PUBLIC_NONCRITICAL. All-ports-to-internet is maximum exposure.191192- NEVER assume a port range is safe because it is "narrow." A range193 `20-25` contains 22 (SSH); `3300-3310` contains 3306 (MySQL).194 Always intersect the range against the high-risk registry.195196- NEVER classify a rule as OPEN solely because a high-risk port197 appears — check the SOURCE first. Port 22 from `10.0.0.0/8` is198 RESTRICTED. Confusing these produces false-positive OPEN verdicts.199200- NEVER assume a port is safe because the service is "just a database."201 MySQL, PostgreSQL, Redis, MongoDB, Elasticsearch exposed to the202 internet are the root cause of countless data breaches.203204- NEVER treat a managed prefix list (`pl-xxxxxxxx`) as automatically205 RESTRICTED. AWS-managed lists for CloudFront, S3, and DynamoDB contain206 public IPs. Inspect with207 `aws ec2 get-managed-prefix-list-entries --prefix-list-id <pl-id>`.208209- NEVER treat `10.0.0.0/7` as fully private. The `/7` spans `10/8`210 (RFC 1918) AND `11/8` (public). Any CIDR broader than the RFC 1918211 boundaries is partially public → classify as PUBLIC.212213- NEVER add inbound "ephemeral" rules (`1024-65535` from `0.0.0.0/0`)214 for return traffic. Security groups are stateful — responses to215 outbound flows are automatically allowed. This misconfiguration is216 common and creates a wide attack surface for zero benefit.217218- NEVER assume `::/0` (IPv6 `any`) is less dangerous than `0.0.0.0/0`.219 AWS IPv6 addresses are globally routable by default. A dual-stack220 instance with `::/0` on port 22 is just as exposed as IPv4.221222- NEVER dismiss UDP DNS (port 53) from `0.0.0.0/0`. An open UDP 53223 resolver is a DNS amplification reflector (~50-80× amplification).224 AWS throttles accounts hosting open resolvers. Classify as OPEN.225226- NEVER permit ICMP `ALL` (type `-1`) from `0.0.0.0/0` without flagging227 it. While ICMP alone is PUBLIC_NONCRITICAL, `ALL` enables timestamp228 queries (OS fingerprinting), address-mask queries (network mapping),229 and Smurf amplification.230231- NEVER expose SNMP (UDP 161) to the internet. Community strings232 (`public`, `private`) are sent in cleartext in SNMPv1/v2c; the full233 network topology and configuration are leaked. Classify as OPEN.234235- NEVER assume overlapping or redundant CIDR rules are harmless. AWS236 evaluates every inbound allow rule independently (UNION semantics —237 there is NO first-match priority and NO deny in SGs; deny lives in238 NACLs). A port with BOTH `0.0.0.0/0` and `10.0.0.0/8` sources means239 the broader (`0.0.0.0/0`) rule is the effective exposure; the240 restrictive rule adds nothing and must be REMOVED, not narrowed.241 Flag every duplicate and overlap as a cleanup item — they obscure242 the real posture during manual review AND defeat naive243 `grep "0.0.0.0/0"` audits.244245- NEVER miss split-horizon CIDR evasion. Two rules `0.0.0.0/1` and246 `128.0.0.0/1` on the same port cover the ENTIRE IPv4 space, yet247 neither literally equals `0.0.0.0/0`. The same applies to `/2` quad248 splits and `/3` octets. Always union complementary halves before249 classifying — a per-rule RESTRICTED verdict can hide a union that is250 effectively PUBLIC.251252- NEVER trust a customer-managed prefix list as permanently RESTRICTED.253 The list owner can add public CIDRs at any time without changing the254 SG rule. Re-audit prefix-list entries on every review cycle. Flag255 any `pl-xxxxxxxx` reference in a RESTRICTED SG for periodic256 re-validation.257258- NEVER recommend simply deleting a rule without providing the259 replacement. SG rule deletion is a live-affecting change — the260 replacement (bastion SG reference, SSM Session Manager, app-tier SG261 reference) must be specified so the operator can apply it without262 losing application access.263264## Source classification (Reference)265266Classify the `Source` field BEFORE evaluating the port — misclassifying a267source is the most common auditor error.268269| Source | Class | Notes |270| --- | --- | --- |271| `0.0.0.0/0` | **PUBLIC** (IPv4 internet) | All IPv4 addresses. |272| `::/0` | **PUBLIC** (IPv6 internet) | All IPv6 addresses. Treat identically. |273| `0.0.0.0/1` + `128.0.0.0/1` | **PUBLIC** (split-horizon evasion) | Union covers all IPv4; classify each as PUBLIC. |274| CIDR broader than RFC 1918 boundaries | **PUBLIC** (partial) | e.g., `10.0.0.0/7` spans `10/8` (private) AND `11/8` (public). |275| `100.64.0.0/10` | **RESTRICTED** (CGNAT, RFC 6598) | Carrier-grade NAT; flag for review. |276| `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16` | **RESTRICTED** (RFC 1918) | Standard private ranges. |277| `sg-xxxxxxxx` | **RESTRICTED** (SG reference) | Self-references valid for inter-tier comms. |278| `pl-xxxxxxxx` | **CONDITIONAL** | See §"Prefix-list evaluation procedure". |279| Specific public IP `/32` | **RESTRICTED** (single source) | Narrow; flag for rotation review. |280| Missing / blank | **RESTRICTED** | Treat conservatively as no source. |281282## Prefix-list evaluation procedure (Reference)283284When a rule's source is `pl-xxxxxxxx`, classification is CONDITIONAL on the285prefix list's entries:286287### Step 1 — Identify the type288289```290aws ec2 describe-managed-prefix-lists --prefix-list-ids pl-xxxxxxxx291```292Check `OwnerId`: if it matches your account, it is **customer-managed**;293if `Amazon`, it is **AWS-managed** (CloudFront, S3, DynamoDB).294295### Step 2 — Enumerate entries296297```298aws ec2 get-managed-prefix-list-entries --prefix-list-id pl-xxxxxxxx299```300301### Step 3 — Classify302303- **ALL entries** RFC 1918 or `/32` known IPs → **RESTRICTED**.304- **ANY public entry** → treat as **PUBLIC** for classification.305- **AWS-managed exception** (CloudFront/S3/DynamoDB): entries are AWS306 service IPs — effectively public but trusted infrastructure. Classify307 as **PUBLIC_NONCRITICAL** for non-critical ports (443, 80); **OPEN**308 for critical ports (22, 3389, databases, all-ports). AWS edge IPs309 should not be trusted with administrative access.310311## High-risk port registry (Reference)312313### Administrative access314| Port(s) | Protocol | Service | Risk |315| --- | --- | --- | --- |316| 22 | TCP | SSH | Brute-force #1; CIS 5.1. |317| 23 | TCP | Telnet | Unencrypted; trivially exploitable. |318| 3389 | TCP/UDP | RDP | Brute-force; BlueKeep. CIS 5.2. |319| 5900-5910 | TCP | VNC | Often no auth; trivial takeover. |320| 2375, 2376 | TCP | Docker daemon | Container RCE; full host compromise. |321322### Databases323| Port(s) | Protocol | Service | Risk |324| --- | --- | --- | --- |325| 3306 | TCP | MySQL / Aurora MySQL | Data exfiltration, ransomware. |326| 5432 | TCP | PostgreSQL / Aurora PG | Data exfiltration, ransomware. |327| 1433 | TCP | MSSQL | Data exfil; SA brute-force. |328| 1521 | TCP | Oracle TNS | Data exfil; TNS poisoning. |329| 27017-27019 | TCP | MongoDB | NoSQL ransomware. |330| 6379 | TCP | Redis | Cryptomining, data exfil, ransomware. |331| 9042 | TCP | Cassandra | NoSQL data exfiltration. |332| 5984 | TCP | CouchDB | Default "admin party" on old versions. |333| 11211 | TCP/UDP | Memcached | UDP amplification DDoS (~51,000×). |334| 9200, 9300 | TCP | Elasticsearch | Data exfil + ransomware. |335336### Message queues / streaming / container orchestration337| Port(s) | Protocol | Service | Risk |338| --- | --- | --- | --- |339| 5671, 5672 | TCP | AMQP / RabbitMQ | Queue manipulation. |340| 9092 | TCP | Kafka | Topic read/write; data tampering. |341| 6443 | TCP | Kubernetes API | Full cluster takeover. |342| 10250 | TCP | Kubelet | Per-node RCE. |343| 2379, 2380 | TCP | etcd | K8s control-plane root. |344345### Windows / RPC / directory346| Port(s) | Protocol | Service | Risk |347| --- | --- | --- | --- |348| 135, 139, 445 | TCP | MS-RPC / NetBIOS / SMB | WannaCry; EternalBlue. |349| 389, 636 | TCP | LDAP / LDAPS | Credential theft. |350| 25 | TCP | SMTP | Open-relay spam. |351352### Amplification vectors (non-TCP)353| Port(s) | Protocol | Service | Amplification factor |354| --- | --- | --- | --- |355| 53 | UDP | DNS | ~50-80× |356| 123 | UDP | NTP (MONLIST) | ~556× |357| 161 | UDP | SNMP | ~3-15× |358| 1900 | UDP | SSDP / UPnP | ~30× |359| 5353 | UDP | mDNS | Local enumeration |360361### Maximum exposure362| Port(s) | Protocol | Risk |363| --- | --- | --- |364| 0-65535 | TCP | Every TCP service attackable. |365| All (`-1`) | ALL | TCP + UDP + ICMP + SCTP; worst case. |366367### Non-critical (PUBLIC_NONCRITICAL when PUBLIC)368| Port(s) | Protocol | Notes |369| --- | --- | --- |370| 80 | TCP | Acceptable behind ALB; verify redirect to 443. |371| 443 | TCP | Acceptable for web-facing tiers behind ALB/WAF. |372| 8080 | TCP | Acceptable behind ALB; verify not admin panel. |373374## Output format (Process — per security group)375376```text377SECURITY_GROUP: <name>378VERDICT: OPEN | PUBLIC_NONCRITICAL | RESTRICTED379SEVERITY: Critical | High | Medium | Low | None380CIS_CONTROLS: <e.g., "5.1" or "5.2, 5.3" or "N/A">381REASON: <1-2 sentences citing the specific rules and per-rule verdicts>382REMEDIATION: <specific action, or "None required" if RESTRICTED>383```384385## Pre-flight safety checks (Process — run before any remediation CLI)386387- Capture current SG rule set: `aws ec2 describe-security-groups388 --group-ids <sg-id> --output json > /tmp/<sg-id>-backup-$(date +%s).json`.389- Verify rollback: after backup, confirm the file is non-empty and parses390 as valid JSON (`python3 -c "import json; json.load(open('<file>'))"`).391 A truncated/empty backup is useless for rollback.392- Prefer **additive** changes (add restrictive rule, verify, then remove393 open rule) over **destructive** changes (delete first).394- For OPEN verdicts on administrative ports (22, 3389, 2375, 6443,395 10250), confirm the operator has an alternative access path (SSM396 Session Manager, console, or another SG rule) BEFORE removing the397 open rule.398- Verify dependency impact:399 `aws ec2 describe-network-interfaces --filters Name=group-id,Values=<sg-id>`400 — removing a rule that a load balancer, peered VPC, or Lambda function401 depends on will cause an outage.402- For prefix-list sources, snapshot entries:403 `aws ec2 get-managed-prefix-list-entries --prefix-list-id <pl-id>404 --output json > /tmp/<pl-id>-backup-$(date +%s).json`.405406## Remediation guidance (Process — per verdict)407408For **OPEN** security groups:409410- **SSH (22):** prefer AWS Systems Manager Session Manager — no open411 ports, IAM-authenticated, fully audited. Fallback: bastion SG ref.412- **RDP (3389):** restrict to a bastion or jump-SG ref.413- **Databases (3306, 5432, 1433, 1521, 27017, 6379, 9042, 5984, 11211,414 9200):** restrict to the application-tier SG ID ONLY. Database subnets415 should have no IGW route (private subnet with NAT, not public).416- **Elasticsearch (9200, 9300):** restrict to ingestion SG + dashboard417 SG; transport port (9300) never leaves the peer set.418- **Docker daemon (2375, 2376):** never expose to internet. Bind to419 localhost or private VPN; enable TLS client cert auth on 2376.420- **Kubernetes API (6443) / Kubelet (10250) / etcd (2379-2380):**421 restrict to control-plane and operator CIDRs. P0 remediation.422- **SMB (445) / NetBIOS (139):** remove entirely; restrict to423 directory-member SG references.424- **DNS (UDP 53):** if not a designated resolver, remove. If it IS a425 resolver, restrict to known client CIDRs and enable RRL.426- **SNMP (UDP 161):** restrict to monitoring SG; upgrade to SNMPv3427 authPriv.428- **Memcached UDP:** disable UDP entirely; amplification is severe.429- **All-ports (0-65535) / protocol -1:** delete and recreate with ONLY430 the specific ports the workload requires.431432For **PUBLIC_NONCRITICAL** security groups:433434- **Public HTTPS (443):** verify the SG is attached to an ALB/NLB, not435 directly to backend instances. The backend SG should reference the ALB436 SG ID, not `0.0.0.0/0`.437- **Public HTTP (80):** acceptable only for redirect-to-HTTPS.438- **ICMP:** restrict to a known monitoring CIDR; never allow ICMP ALL.439440For **RESTRICTED** security groups:441442- No remediation required for RFC 1918 / SG-ref / `/32` rules.443- If rules use `100.64.0.0/10` (CGNAT) or broad `/7`–`/9` CIDRs,444 flag for review.445- For customer-managed prefix-list references, schedule periodic446 re-audit of list entries — the list owner can add public CIDRs without447 changing the SG rule.448- Recommend enabling VPC Flow Logs for ongoing auditing.449450## Recent AWS features (2024-2026)451Recent AWS features notes moved to452[references/advanced-patterns.md](references/advanced-patterns.md).453454## Section taxonomy (CloudOps auditor pattern)455456**Pattern:** CloudOps Auditor — `Mindset → Process → Reference → Tool`.457Each major section is tagged inline with its pattern role so the458structure is machine-recognizable and aids comprehension:4594601. **Frontmatter** — name, description, version.4612. **Activation keywords** — discoverability terms.4623. **Quick verdict logic** — at-a-glance summary (progressive disclosure entry point).4634. **Reasoning framework** `[Mindset]` — the *why*.4645. **AWS dataplane expert details** `[Mindset]` — non-obvious AWS behavior.4656. **Classification logic** `[Process]` — per-rule evaluation then466 worst-case aggregation, as formal pseudocode.4677. **Risk scoring and compliance mapping** `[Process]` — CVSS severity +468 CIS/PCI-DSS/NIST control IDs.4698. **NEVER** `[Process]` — anti-patterns applied before verdict.4709. **Source classification** `[Reference]` — CIDR / SG-ref / prefix-list471 decision table.47210. **Prefix-list evaluation procedure** `[Reference]` — programmatic473 inspection.47411. **High-risk port registry** `[Reference]` — categorized port tables.47512. **Output format** `[Tool]` — per-SG report shape.47613. **Pre-flight safety checks** `[Process]` — non-destructive guards.47714. **Remediation guidance** `[Tool]` — per-verdict action plan.478479## References (load on demand)480481- [references/advanced-patterns.md](references/advanced-patterns.md) — AWS dataplane expert details (union evaluation, conntrack ceiling, four source arrays, quotas, peering/RAM, prefix-list drift, Config/Security Hub controls, Reachability Analyzer) and recent AWS features (moved from this file)482- [references/diagnostic-commands.md](references/diagnostic-commands.md) — effective enumeration queries for scoping an audit (moved from this file)483- [references/worked-examples.md](references/worked-examples.md) — secondary worked examples: private-CIDR database, prefix-list source, IPv6 dual-stack, overlapping CIDRs, split-horizon evasion, prefix-list drift (moved from this file)484- [references/security-group-exposure-guide.md](references/security-group-exposure-guide.md) — high-risk port registry, CIDR/source classification, remediation patterns485486## Domain487488AWS CloudOps / EC2 Network Security & Compliance.489490## AWS documentation491492- **Amazon EC2 User Guide (Security Groups)** — https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-security-groups.html493- **EC2 Security** — https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-security.html494- **EC2 API Reference** — https://docs.aws.amazon.com/AWSEC2/latest/APIReference/495- **AWS CLI — ec2 command reference** — https://docs.aws.amazon.com/cli/latest/reference/ec2/496- **VPC security groups** — https://docs.aws.amazon.com/vpc/latest/userguide/vpc-security-groups.html