ec2-security-group-auditor
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.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-24
- Stars
- ★ 4
- Forks
- 0
01 前言 Front Matter
- name
- ec2-security-group-auditor
- license
- Apache-2.0
- metadata
- { "tags": "aws, ec2, security-group, network-security, compliance, audit", "phase": "2", "author": "Jacky Chan — AWS Community Builder", "domain": "aws-cloudops", "family": "Security", "version": "0.4.0", "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 list", "complexity": "medium", "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.", "dependencies": "aws-orchestrator", "requires_llm": "true", "verdict_shape": "OPEN | PUBLIC_NONCRITICAL | RESTRICTED", "supports_pipeline": "true" }
- description
- 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.
- compatibility
- 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.
02 资源文件 19
- 参考文档eval/test-cases.yaml3.2 KB
- 参考文档evals/baselines/all-ports-open.md485 B
- 参考文档evals/baselines/bastion-ssh-open.md441 B
- 参考文档evals/baselines/db-mysql-open.md499 B
- 参考文档evals/baselines/db-private-cidr.md457 B
- 参考文档evals/baselines/web-tier-https.md516 B
- 参考文档evals/eval_config.yaml1.5 KB
- 参考文档evals/evals.json4.2 KB
- 参考文档evals/prompts/all-ports-open.md216 B
- 参考文档evals/prompts/bastion-ssh-open.md215 B
- 参考文档evals/prompts/db-mysql-open.md211 B
- 参考文档evals/prompts/db-private-cidr.md216 B
- 参考文档evals/prompts/web-tier-https.md266 B
- 参考文档example/end-to-end-audit.md4.7 KB
- 参考文档references/advanced-patterns.md6.1 KB
- 参考文档references/diagnostic-commands.md706 B
- 参考文档references/security-group-exposure-guide.md6.9 KB
- 参考文档references/worked-examples.md2.2 KB
- 参考文档skill.usf.yaml4.3 KB
03 SKILL.md 正文
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-25contains 22 (SSH) and 25 (SMTP) → CRITICAL → OPEN if PUBLIC3300-3400contains 3306 (MySQL) → CRITICAL → OPEN if PUBLIC440-450contains 443 only → does NOT intersect high-risk → PUBLIC_NONCRITICAL if PUBLIC0-65535intersects 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,
Portmaps toType: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/0AND22 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 treat0-65535as 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) from0.0.0.0/0as 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-25contains 22 (SSH);3300-3310contains 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/8is 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 withaws ec2 get-managed-prefix-list-entries --prefix-list-id <pl-id>. -
NEVER treat
10.0.0.0/7as fully private. The/7spans10/8(RFC 1918) AND11/8(public). Any CIDR broader than the RFC 1918 boundaries is partially public → classify as PUBLIC. -
NEVER add inbound "ephemeral" rules (
1024-65535from0.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(IPv6any) is less dangerous than0.0.0.0/0. AWS IPv6 addresses are globally routable by default. A dual-stack instance with::/0on 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) from0.0.0.0/0without flagging it. While ICMP alone is PUBLIC_NONCRITICAL,ALLenables 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/0and10.0.0.0/8sources 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 naivegrep "0.0.0.0/0"audits. -
NEVER miss split-horizon CIDR evasion. Two rules
0.0.0.0/1and128.0.0.0/1on the same port cover the ENTIRE IPv4 space, yet neither literally equals0.0.0.0/0. The same applies to/2quad splits and/3octets. 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-xxxxxxxxreference 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
/32known 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 /
/32rules. - If rules use
100.64.0.0/10(CGNAT) or broad/7–/9CIDRs, 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
- Amazon EC2 User Guide (Security Groups) — https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-security-groups.html
- EC2 Security — https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-security.html
- EC2 API Reference — https://docs.aws.amazon.com/AWSEC2/latest/APIReference/
- AWS CLI — ec2 command reference — https://docs.aws.amazon.com/cli/latest/reference/ec2/
- VPC security groups — https://docs.aws.amazon.com/vpc/latest/userguide/vpc-security-groups.html
04 同仓库更多 Skills
xray-tracing-deployer
Deploys AWS X-Ray distributed tracing with production-grade configuration: X-Ray daemon deployment (EC2 systemd, ECS sidecar, EKS DaemonSet, Lambda built-in), SDK instrumentation (Java, Python, Node.js, Go, .NET) with annotations and metadata, sampling rules (default reservoir + rate vs custom rules with URL / method / service-name predicates), service map generation, trace query and retrieval, groups and insights, CloudWatch ServiceLens integration, IAM permissions (PutTraceSegments, GetSamplingRules), and latest features (Lambda Powertools tracing, OpenTelemetry / ADOT Collector support, W3C trace context). Emits a READY_TO_DEPLOY checklist with every configuration item verified. Use when enabling X-Ray on a new application, adding tracing to ECS / EKS / Lambda, validating a sampling configuration, or generating daemon deployment CLI and IaC templates. Triggers: X-Ray, distributed tracing, X-Ray daemon, sampling rules, service map, X-Ray SDK, OpenTelemetry, ADOT, Lambda Powertools, CloudWatch ServiceLens.
wellarchitected-workload-auditor
Audits AWS Well-Architected Tool workloads for review staleness, per-pillar high-risk issue counts, milestone tracking gaps, and remediation plan completeness. Emits a deterministic verdict (STALE_REVIEW | HIGH_RISK | CONFIG_GAP | OK) per workload with per-pillar risk breakdown, milestone trend analysis, and specific remediation. Use when reviewing Well-Architected workloads, checking WA review freshness, auditing high-risk issues per pillar, validating milestone coverage, or tracking remediation plans.
wellarchitected-review-operator
Operates AWS Well-Architected Tool reviews end-to-end — creates workloads, runs pillar reviews (operational excellence, security, reliability, performance, cost optimization, sustainability, Prosperity), answers questions with risk-tier rationale, generates reports and improvement plans, creates milestones, and integrates with Trusted Advisor and Well-Architected Labs. Runs deterministic pre-checks (workload existence, lens availability, pillar coverage), emits the exact update-answer / get-consolidated-report CLI behind a CONFIRM gate, and verifies risk-tier transitions. Emits READY | BLOCKED | COMPLETED. Use when creating a workload, answering pillar questions, generating an improvement plan, creating a milestone, or integrating with Trusted Advisor. Triggers: well-architected tool, well architected review, workload review, pillar, operational excellence, security, reliability, performance, cost optimization, sustainability, prosperity, improvement plan, milestone, trusted advisor.
wafv2-web-acl-deployer
Provisions AWS WAFv2 Web ACLs with correct production defaults: scope selection (CLOUDFRONT vs REGIONAL), managed rule groups (AWSManagedRulesCommonRuleSet, SQLiRuleSet, LinuxRuleSet, WindowsRuleSet, IPReputationList, BotControlRuleSet, AmazonIpReputationList, ATP), custom rules (byte match, IP set, regex pattern, geo match, size constraint, rate-based), rule priority ordering, logging destinations (Kinesis Firehose, CloudWatch Logs, S3), resource association (ALB, API Gateway, CloudFront), rate-based rules with aggregate keys (IP, forwarded IP), Challenge and CAPTCHA actions, and account takeover prevention. Emits a READY_TO_DEPLOY checklist. Use when creating a Web ACL, attaching managed rules, configuring rate limiting, enabling WAF logging, associating a Web ACL with an ALB/API Gateway/CloudFront, or configuring CAPTCHA/Challenge actions. Triggers: create WAF Web ACL, WAFv2, managed rule groups, WAF rate limiting, WAF logging, WAF CAPTCHA, WAF Challenge action, bot control, ATP managed rules.
wafv2-web-acl-auditor
Audits AWS WAFv2 Web ACL configurations to determine whether the ACL provides effective protection: default-action posture (Allow vs Block), managed-rule-group coverage gaps, rule effectiveness (BLOCK vs COUNT, shadow/bypass rules, stale exclusions), rate-based rule correctness, logging and visibility configuration, and text-transformation bypass vectors. Emits a deterministic verdict per Web ACL. Use when reviewing a WAFv2 Web ACL for security posture, checking managed-rule coverage, validating rate-limit configuration, auditing WAF logging, or hardening a WAF before production deployment. Triggers: WAF, WAFv2, Web ACL, managed rule group, AWSManagedRules, rate-based rule, CAPTCHA, Challenge, OverrideAction, Count mode, forwarded IP, Bot Control, ATP, text transformation, WAF logging, WAF visibility, OWASP, SQLi, XSS, RFI.
waf-rule-deployer
Provisions AWS WAFv2 rule sets with production defaults: Web ACL creation (CloudFront scope in us-east-1 vs Regional scope), rule groups (managed vs custom) with capacity planning in WCU (Web ACL Capacity Units, 1500 default per ACL), managed rule groups (AWSManagedRulesCommonRuleSet, AWSManagedRulesSQLiRuleSet, AWSManagedRulesAmazonIpReputationList, AWSManagedRulesLinuxRuleSet, AWSManagedRulesWindowsRuleSet, AWSManagedRulesUnixRuleSet), custom rules (byte-match, regex pattern set, geo-match, rate-based), IP set and regex pattern set resources, rule priority ordering (lowest number evaluated first), action types (allow, block, count, CAPTCHA, Challenge), bot control managed rule group, account takeover. Triggers: create WAF rule, WAF managed rule group, WAF custom rule, WAF byte match, WAF geo match, WAF rate based rule, WAF IP set, WAF regex pattern set, WAF WCU budget, WAF CloudFront ACL, WAF logging Kinesis Firehose, WAF bot control, WAF ATP, WAF label matching, WAF Challenge action, WAF CAPTCHA.