AGENT SKILL

nexus-security-hardening

Wave-2 security hardening for Nexus Link — runs the diagnostic tools, dispatches the MURE build, verifies the gates. Invoke for "wave 2", "security hardening", "nexus security", "pre-customer security", "rls audit", "audit chain verify", "antipattern scan".

License 许可
MIT
最近更新
2026-11-14
Stars
★ 2
Forks
0

01 前言 Front Matter

name
nexus-security-hardening
triggers
[ "wave 2", "security hardening", "nexus security", "pre-customer security", "rls audit", "audit chain verify", "antipattern scan", "wave2" ]
description
Wave-2 security hardening for Nexus Link — runs the diagnostic tools, dispatches the MURE build, verifies the gates. Invoke for "wave 2", "security hardening", "nexus security", "pre-customer security", "rls audit", "audit chain verify", "antipattern scan".

02 资源文件 1

03 SKILL.md 正文

Nexus Security Hardening (Wave 2)

Wave 2 is the pre-customer security gate (MASTER-PLAN §11): close the three load-bearing gaps (network perimeter, tamper-evident audit, real encryption) before any tenant PII lands on Hetzner. This skill orchestrates the diagnostic-verify-build-verify cycle, builds from the verified Code Reference Pack, and dispatches the MURE fleet on the codebase leaves.

Hard truth from the research: Nexus's breach risks are misconfigured boring infrastructure (Capital One = SSRF, Equifax = unpatched CVE, LastPass = dev-held-prod-keys, MOVEit = SQLi, 23andMe = no MFA, Colonial = legacy VPN, SolarWinds = build-pipeline), not exotic zero-days. The meta-failure across nearly every breach is insufficient detection (78-day dwell at Equifax). Detection + response is the real safety net.

Source-of-record (read before building)

  • 02_RESOURCES/RESEARCH/nexus-security-hardening-deep-research-2026-07-06.md — the WHAT (3 gaps, 4 designs, 10 breach vectors, 30-line build spec).
  • 02_RESOURCES/RESEARCH/nexus-security-code-reference-pack-2026-07-06.md — the HOW (20 controls, verbatim code, sources, license, pitfalls, Nexus adaptation).
  • docs/NEXUS-LINK-WAVE2-SECURITY-VISUAL-PLAN-2026-07-06.html — the legible plan (build sequence, gates, effort map).

Diagnostic tools (verify — run BEFORE and AFTER each slice)

Bundled in scripts/. Heuristic — flags candidates for human review. Each finding points at the control that fixes it.

  • antipattern-scan.mjs (this skill) — greps for the DO-NOT-USE anti-patterns (str(e) logging, bcrypt, AES-GCM random nonce, SMS 2FA, psycopg client-merge, global WAF rule removal, fast-hash passwords, pepper-in-env, TLS-verify-disabled, pg_hba trust). Exit 1 on critical → CI gate.
  • rls-audit (TODO) — every Postgres table: RLS on? anon/authenticated readable without owner-scoping? Flags the silent anon-key bypass.
  • audit-chain-verify (TODO) — runs the nightly hash-chain verification query; any BROKEN_LINK / ROW_HASH_MISMATCH = breach signal.
  • network-perimeter-check (TODO) — no public DB/Studio ports, origin IP not in DNS, allowlist freshness < 25h.
  • dep-scan (TODO) — wraps syft/grype across Python/Rust/Tauri-npm.

Run the suite: node .claude/skills/nexus-security-hardening/scripts/antipattern-scan.mjs 03_NEXUS-LINK/nexus-app.

The build sequence (highest-leverage first — each ends in a gate)

  1. Network perimeter (L4a/b) — ufw default-deny + Cloudflare-origin allowlist + bind 127.0.0.1 + Tunnel. Cheapest, highest leverage. GATE: no public DB/Studio ports.
  2. Audit hash-chain spine (L3) — audit_log (NO UPDATE/DELETE) + 0x00-prefixed BEFORE-INSERT trigger + nightly verify + PII triggers + log sanitizer (fixes str(e)). GATE: nightly verify all-OK; deliberate tamper detected.
  3. Field-level encryption (L1a) — XChaCha20-Poly1305-IETF for tokens + DM bodies; LUKS on hosts. GATE: ciphertext round-trips; AAD binds to (tenant,row).
  4. Envelope + Vault KEK (L2) — self-hosted EU Vault, transit engine, per-tenant keys. GATE: cross-tenant wrapped_dek won't decrypt.
  5. App-layer (L5) — SECURITY DEFINER public writes + psycopg3 binding + SSRF guard (reuse social-adapter) + log sanitizer. GATE: G1 tenant-isolation negative test green.
  6. Supply chain + WAF block-mode (L6) — SBOM/grype + SLSA L3 + scoped deps + Tauri signing; WAF flips log→block after 2-week tuning.

MURE dispatch (the fleet executes the codebase leaves)

Wave 2 → role-assigned leaves. MURE is owner-armed (spend) — prep the packet at zero cost, owner arms. Infra pieces (real Hetzner ufw, Cloudflare dashboard, Vault cluster) need the owner's hands — MURE builds the config/scripts.

Role Leaves
architect audit_log schema + RLS policies + SECURITY DEFINER functions (the SQL design)
engineer Python modules (log sanitizer, SSRF guard, Argon2id/PEPPER, envelope calls) + migrations
mechanic infra plumbing (ufw script, Cloudflare allowlist sync, Tunnel config, Tailscale, Vault standup script)
sentinel runs the diagnostic tools (antipattern-scan, rls-audit, chain-verify), writes the posture report
adjudicator attacks each slice: G1 tenant-isolation negative test, hash-chain tamper detection, SSRF redirect-to-metadata, WAF false-positive review
chronicler the G12 incident runbook (DSGVO Art. 33 72h clock) + the build record
oracle/calibrator gate evidence (each control's verification ledger)

DO NOT USE (the verify-pass-killed anti-patterns — antipattern-scan enforces)

Hand-rolled AES-GCM · bcrypt for new code · a linear hash chain labeled "RFC 6962" (it's a Merkle tree with mandatory 0x00/0x01 prefixes) · global WAF rule removal · SMS 2FA · pepper in DB/.env/repo · US-region KMS · psycopg ClientCursor/mogrify · Cloudflare One Access mTLS as workload auth · WAF in block-mode day 1.

The two trap doors (do not skip)

<!-- @anchor: v1 | failure: research wf_5fdd3afa verify-pass refuted the audit hash-chain RFC 6962 mislabel + the omitted 0x00 prefix | regression: scripts/antipattern-scan.mjs + audit-chain-verify + the L3a/L3b controls in the Code Reference Pack -->

  • The 0x00 prefix is mandatory. RFC 6962 §2.1 requires 0x00 leaf / 0x01 node domain-separation or second-preimage resistance is lost. The audit chain MUST include E'\\x00' before the canonical bytes. <!-- @anchor: v1 | failure: OWASP CRS false-positive storms block paying tenants when WAF ships in block-mode day 1 (German umlauts, JSON-with-SQL-keywords trip 942100/932100) | regression: the 2-week log-mode cadence gate in the visual plan §03 -->
  • WAF block-mode is a GATE, not a default. Log-mode 2 weeks → targeted ctl:ruleRemoveTargetById=<id>;ARGS:<param> exclusions → only then flip to block.

"Done" = the pre-customer gate

Network default-deny live · audit hash-chain + nightly verify green · tokens/bodies field-encrypted under per-tenant Vault keys · G1 tenant-isolation negative tests in CI · SBOM + signed Tauri releases · WAF in block-mode · L5.5 detection wired to the G12 runbook. No paying tenant PII on Hetzner until those are green.

Session Notes

2026-07-06

  • session: first build | tools: Write×2, Bash (scan run)
  • built: master skill + antipattern-scan.mjs (10 patterns, CI gate). TODO: rls-audit, audit-chain-verify, network-perimeter-check, dep-scan.
  • corrections: none (the RFC 6962 correction was caught upstream in the code-pack verify pass + folded into the L3a/L3b controls)
  • errors: none
  • notes: skill + tool travel together under .claude/skills/nexus-security-hardening/; the tool is @capability-tagged for recall. Infra pieces + MURE arming are owner-gated.

04 同仓库更多 Skills

nexuslinkproductions
nexuslinkproductions/yuri-os

executing-plans

Use when you have a written implementation plan to execute in a separate session with review checkpoints

★ 2
nexuslinkproductions
nexuslinkproductions/yuri-os

using-git-worktrees

Use when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback

★ 2
nexuslinkproductions
nexuslinkproductions/yuri-os

triage

Triage issues through a state machine driven by triage roles. Use when user wants to create an issue, triage issues, review incoming bugs or feature requests, prepare issues for an AFK agent, or manage issue workflow.

★ 2
nexuslinkproductions
nexuslinkproductions/yuri-os

trade-edge-audit

The EDGE LENS for trading peers — recalls EVERY factor/indicator running from the live forecast ledger (no enumeration) and renders the whole pile through the edge arsenal off ONE call: multi-horizon scoring (the ladder) + deflated Sharpe (overfit) + Benjamini-Hochberg FDR (multiple-testing across the fleet) + spread-bounce + maker-fee falsification, then ranks only what survives ALL of it. Use when a peer must answer "does ANY running factor have real, overfit-corrected, multiple-testing-corrected, fee-surviving edge, and at which horizon" without hand-assembling 6 tools. The trade-engine analog of quantum-hypothesis-simulation.

★ 2
nexuslinkproductions
nexuslinkproductions/yuri-os

trade-decision-sim

The DECISION LENS for trading peers — recalls the CURRENT signal snapshot per market from the live ledger and renders it through the sim arsenal off ONE call: quantum factor-circuit order-optimal sequencing + decision-sim CVaR-robust sizing, sized against the MEASURED per-factor edge (from the edge-audit), correlation-aware. Emits an actionable call per market {side, sizePct, confidence, sequence}. Flat/zero-size when there is no measured edge after cost — the honest default. Sibling of trade-edge-audit (the EDGE lens); the trade-engine analog of quantum-hypothesis-simulation for a live decision.

★ 2
nexuslinkproductions
nexuslinkproductions/yuri-os

to-issues

Break a plan, spec, or PRD into independently-grabbable issues on the project issue tracker using tracer-bullet vertical slices. Use when user wants to convert a plan into issues, create implementation tickets, or break down work into issues.

★ 2