agentsclimarketplace

Nginx hardening

Skill trumb/claude-nginx-hardening/skills/nginx-hardening

Use when auditing nginx configs, analyzing access logs for attacks, generating security rules, responding to IoCs, or deploying hardening changes. Triggers on nginx security, WAF, hardening, scanner blocking, or attack pattern analysis.From its SKILL.md

Install
npx -y skills add trumb/claude-nginx-hardening --skill nginx-hardening

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 2 stars2 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

11.4 KB, as published. Nobody here has run it

Nginx Hardening Skill — Core Reference

1. Overview

This plugin provides full-lifecycle nginx security hardening through Claude Code. It audits static configs, analyzes access logs for attack patterns, generates blocking rules, and deploys changes through a gated pipeline.

Design goals:

  • Preserve availability — never propose a rule that could block legitimate traffic without explicit human approval
  • Never expose raw attacker data to LLM — all log data is hex-encoded or sanitized before reaching any agent layer
  • Additive-only — rules are appended, never modify or remove existing directives
  • Deterministic writes — all file mutations happen through non-LLM scripts (sanitizer.py, invariant-checker.py), never by agent output
  • Staged recommendation by default — findings are presented for human review; enforcement requires explicit opt-in

2. Operating Modes

ModePermissionTriggerActions
Recommendation (default)R0 (read config), R1 (read logs)Any audit or analysis commandStatic analysis, log parsing, finding generation, rule proposals — all read-only
EnforcementW1 (stage files), W2 (write config), X1 (reload nginx)Explicit --enforce flag or human acceptance at decision gateBackup, write rule, run invariant checks, nginx -t, deploy, reload

Recommendation Mode never modifies any file. Enforcement Mode requires passing all 5 pipeline layers including human approval at Layer 4.

3. Analysis Levels

LevelScopeChecksActivation
L1 — Static Confignginx conf filesHeaders (HSTS, CSP, X-Frame, X-Content-Type, Referrer-Policy, Permissions-Policy), TLS floor (protocol versions, cipher posture), unsafe directives (autoindex, server_tokens, merge_slashes off), include hierarchy (circular, missing, duplicated), duplicate/shadowed directives, location block precedence and regex ordering, wildcard server_name, access/error logging presence, rate-limiting configuration (limit_req_zone, limit_conn_zone), proxy header safety (X-Forwarded-For, X-Real-IP, Host passthrough)Always
L2 — Log Analysisaccess/error logsScanner UA detection, brute-force patterns (auth endpoints, rate), exploit path probing (by category 1-35), suspicious HTTP methods (TRACE, OPTIONS flood, CONNECT), status code distributions and anomalies, IoC hit matching (IP, path, UA), request rate anomalies per IP/subnet, malicious User-Agent fingerprintsIf logs present
L3 — Live TestHTTP(S) requestsResponse header verification (security headers present and correct), TLS handshake verification (protocol, cipher), response code checks (blocked paths return 404), deny-behavior verification (scanner UA gets 444/403), health endpoint reachabilityOpt-in only

L3 Forbidden Actions: Intrusive fuzzing, brute-force testing, content mutation, high-rate probing (>1 req/sec), any request that could trigger WAF/IDS alerts on production.

4. Attack Categories (35)

Original (1-20)

#CategoryThreatExample Paths
1DotfilesExposed version control, config/.git/HEAD, /.svn/entries, /.DS_Store
2Script extensionsDirect script execution/.env.php, /shell.asp, /cmd.jsp
3Source mapsClient code leak/app.js.map, /main.css.map
4Config filesCredential/secret leak/.env, /.env.bak, /config.yml, /.npmrc
5WordPressWP-specific exploitation/wp-login.php, /wp-admin/, /xmlrpc.php
6Spring ActuatorJava app internals/actuator/health, /actuator/env, /jolokia/
7Swagger/OpenAPIAPI schema leak/swagger-ui.html, /api-docs, /openapi.json
8PHP/Laravel debugDebug info leak/_debugbar, /telescope, /phpinfo.php
9Container/K8sOrchestration metadata/.kube/config, /api/v1/pods, /.docker/config.json
10JS dev toolsDev tooling exposure/webpack.config.js, /.babelrc, /vite.config.ts
11AtlassianJira/Confluence exploit/jira/, /confluence/, /%24%7Bjndi:
12MS ExchangeExchange/OWA exploit/owa/, /ecp/, /autodiscover/autodiscover.xml
13GraphQLIntrospection/abuse/graphql, /graphiql, /?query={__schema}
14Admin panelsAdmin interface discovery/admin/, /administrator/, /cpanel/, /phpmyadmin/
15CVE probesKnown vulnerability scanning/cgi-bin/, /..;/, /%2e%2e/, /proxy:http
16WP user enumWordPress user enumeration/?author=1, /wp-json/wp/v2/users
17Path traversalDirectory escape/../../../etc/passwd, /....//....//
18Phishing kitsHosted phish artifacts/office365/, /banking/login.html, /.well-known/ abuse
19Backup/bin dirsExposed backups/binaries/backup/, /db.sql.gz, /site.tar.gz, /bin/
20robots/security.txtRecon via metadata/robots.txt (excessive), /.well-known/security.txt abuse

March 2026 (21-35)

#CategoryThreatExample Paths
21HNAP/RouterHome router exploitation/HNAP1/, /cgi-bin/luci, /goform/
22VPN/SSL gatewaysVPN appliance targeting/remote/login, /dana-na/, /+CSCOE+/, /ssl-vpn/
23Apache StrutsStruts RCE probing/struts/, /*.action, /devmode.action
24Log4Shell/JNDIJNDI injection/${jndi:ldap://, /${jndi:rmi://, /${jndi:dns://
25SSH key/cloud credsCredential file theft/.ssh/id_rsa, /.aws/credentials, /.gcp/credentials.json
26IoT/OEM devicesIoT management interfaces/cgi-bin/ViewLog.asp, /camera/, /ISAPI/
27Package manager filesDependency file leak/package.json, /composer.json, /Gemfile.lock, /go.sum
28App settings filesApplication config leak/appsettings.json, /application.yml, /settings.py
29XDEBUGPHP debug interface/?XDEBUG_SESSION_START, /xdebug, /?PHPSTORM
30Enterprise appsEnterprise software probes/sap/, /Citrix/, /ibm/, /oracle/
31InfluxDBTime-series DB exposure/query?db=, /api/v2/buckets, /influxdb/
32Network infraNetwork device interfaces/cgi-bin/config.exp, /level/15/exec/, /tmui/
33Lotus NotesLegacy groupware/names.nsf, /domcfg.nsf, /webadmin.nsf
34Login discoveryAuth endpoint enumeration/login, /signin, /auth/, /user/login, /api/auth
35Misc exploit pathsUncategorized exploit probes/console/, /debug/, /status, /server-info

5. Finding Families

Findings from analysis map to these broader families:

FamilyCoversSource Level
Transport securityTLS version floor, cipher strength, HSTSL1, L3
HeadersSecurity response headers (CSP, X-Frame, etc.)L1, L3
Request filteringBlock rules for categories 1-35L1, L2
Path exposureLeaked config, source, backup filesL1, L2
Scanner detectionKnown scanner UA fingerprintsL2
Brute-force detectionAuth endpoint hammering, rate spikesL2
Enumeration behaviorUser enum, directory listing, info endpointsL2
IoC matchesKnown-bad IPs, paths, UAs from threat feedsL2
Device exploitationIoT/router/appliance probes (categories 21, 26, 32)L2
Proxy safetyForwarded headers, upstream trustL1
Logging gapsMissing access/error logs, log rotationL1
Rate controlMissing or misconfigured rate limitingL1, L2
Include hierarchyCircular, missing, or duplicated includesL1
Location precedenceRegex ordering, shadowed locationsL1
Stale control cleanupObsolete directives, deprecated modulesL1
Exception hygieneOverbroad exceptions, expired allowlist entriesL1, L2

6. Rule Generation Constraints

All generated nginx rules MUST satisfy:

ConstraintRationale
End in return 404; or deny all; return 404;Uniform deny behavior, no information leak
Never contain !~ (negative regex match)Fragile, easily bypassed
Never contain negative lookahead (?!...)nginx PCRE support varies, brittle
Never contain proxy_passRules must block, never forward
Never contain return 200Rules must deny, never affirm
Never contain rewriteAvoid redirect chains, keep rules terminal
Scoped as narrowly as possibleMinimize blast radius; prefer exact path over broad regex

Additional constraints: Rules use location blocks (not if directives where avoidable). Regex patterns prefer ~* (case-insensitive) for path matching. Each rule block includes a comment referencing its category number.

7. Security Pipeline

Layer 1: log-parser agent ─── Read-only, hex-encodes attacker payloads
    │                         Extracts structured events from raw logs
    ▼
Layer 2: sanitizer.py ─────── Deterministic (no LLM), allowlist filtering
    │                         Strips PII, validates field types, enforces length limits
    ▼
Layer 3: config-auditor ───── Read + stage only, proposes rules
    │                         Generates findings, maps to categories, drafts rule blocks
    ▼
Layer 4: decision gate ────── Human accept/reject
    │                         Presents diff, risk assessment, rollback plan
    ▼
Layer 5: invariant-checker ── invariant-checker.py + nginx -t + backup + deploy
                              Validates rule syntax, checks invariants, tests config, deploys

Data flows strictly downward. No layer can invoke a higher-numbered layer. Layer 2 output is the only data Layer 3 ever sees from logs.

8. Log Analysis Methodology

  1. Auto-detect — Scan standard paths (/var/log/nginx/, site-specific logs) and identify log format (combined, custom)
  2. Parse — Extract fields: timestamp, IP, method, path, status, size, referrer, UA. Layer 1 hex-encodes any field containing non-ASCII or suspicious patterns
  3. Sanitize — Layer 2 applies allowlist: valid HTTP methods, printable ASCII paths (hex-encoded otherwise), known status codes, UA length limits. PII (IPs) hashed for presentation
  4. Analyze — Layer 3 correlates sanitized events: group by category (1-35), detect scanner UAs, identify brute-force patterns, flag status anomalies, match against IoC lists
  5. Present — Findings displayed as structured table: category, severity, count, sample paths (sanitized), proposed action
  6. Accept/Reject — Human reviews each finding at Layer 4. Accepted findings proceed to Layer 5 for rule generation and deployment

9. References

  • @INVARIANTS.md — Invariant definitions and validation rules for Layer 5
  • @EXECUTION-POLICY.md — Permission model (R0/R1/W1/W2/X1), escalation rules, rollback procedures
  • @FAILURE-POLICY.md — Error handling, graceful degradation, circuit breakers
  • @RULE-CLASSES.md — Rule taxonomy, severity levels, auto-expire policies
  • @PROFILES.md — Server profiles (static, proxy, API, mixed), per-profile defaults and exceptions

Keep looking

Skills are one crate of 628,853. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.