Security Agent v2: Research & Improvements #

Date: 2026-04-16 Author: Security Research Status: Proposal (ready for review)


1. Current State Summary #

The reverie security agent (reverie-security role) is a read-only reviewer that audits supply-chain and vulnerability risks via:

Capabilities (per crates/meshctl/src/roles.rs:283–317):

Hard boundaries:

Tools: cargo deny, cargo audit, /secrets-scanner, Grep, mem_save


2. Current Coverage vs. Threat Model #

Threat ModelCurrent CoverageGapSeverity
Dependency vulnerabilities (CVE/RUSTSEC)cargo deny (weekly + on-PR); deny.toml tracks 2 ignored advisories (RUSTSEC-2024-0436, RUSTSEC-2025-0119)No SLA for triage/response; advisory ignore list is not auto-reviewed; no SBOM generationM
Transitive supply-chain attackscargo deny tracks sources (unknown-registry=deny, unknown-git=warn)No cargo-vet consensus voting; no attestation chain validation; no hash pinning beyond lock fileM-H
Secrets leakage (API keys, tokens).gitignore has .secrets, .env; /secrets-scanner agent available on-demandNo pre-commit hook enforcement; no CI-gated secret detection; no periodic git history scan; scanner only runs when requestedH
License compliance violationsdeny.toml allowlist (11 licenses) checked in CINo SBOM export; no license-change detection alerts; no dashboardL-M
Malicious commit signersNoneNo GPG signature verification in release workflow; no SLSA provenanceH
Privilege escalation (worker sandbox)Documented in ops: no setuid, no sudo, unprivileged deploy pathNo runtime sandboxing verification; no capability audit of binariesM
Container/Docker image scanningNoneNo Dockerfiles found; no image SCA if containerization addedL (for now)
Unsafe code auditsNone5335-line Cargo.lock with untrusted deps; no cargo-geiger scansM
Lock file mutations (Cargo.lock tampering)Manual review; security agent can writeNo commit signature verification; no immutability enforcement in CIM
Dependency version pinning driftCargo.lock tracked in repo; multiple-versions=“allow”No policy enforcement on semver bounds; no audit trail of bumpsL-M

3. Automation Gaps #

Currently Missing #

  1. Pre-commit secret scanning.env, .secrets in .gitignore but no git hook validation
  2. Periodic dep audit cycle — only on schedule (weekly) + PR; no urgent re-runs for zero-days
  3. SBOM generation — no bill-of-materials export for release artifacts or vendored deps
  4. GPG commit signature verification — release workflow doesn’t gate on signed commits
  5. Runtime capability audit — binaries deployed unprivileged but no verification of capability set
  6. Cargo-vet integration — no consensus voting on transitive deps, only deny rules
  7. Unsafe code scanning (cargo-geiger) — no inventory of unsafe blocks
  8. Git history scanning — no periodic sweep for leaked secrets in past commits
  9. Dependency deprecation tracking — no alerts when a dep is archived/unmaintained (e.g., paste, number_prefix in deny ignore list)
  10. Lock file integrity checks — no signature verification or immutability enforcement on Cargo.lock in CI

4. Integration Gaps with Other Roles #

Handoffs #

From/ToCurrentMissing
anchor → securityManual request for audit; no auto-dispatchNo threat-model-driven dispatches; no escalation path for zero-days
security → releaseSecurity agent outputs advisory docs; no blockers on releaseNo gating: release doesn’t wait for final security sign-off; no security metadata in release notes
builder → securityBuilder flags vuln findings; security reviewsNo pre-flight checks before builder runs cargo build; no sandbox policy enforcement
ops → securityNoneNo runtime vulnerability scanning of deployed reveried; no daemon capability audit
security → anchorSaves findings to engramNo escalation signal for high-severity vulns; no auto-ticket creation

Proposed Handoffs #


5. Tooling Opportunities #

Tier 1 (High Impact, Available) #

ToolPurposeEffortWhy reverie needs it
cargo-auditScan Cargo.lock for known vulns (db-driven)SAlready in role; not actively integrated in CI/role workflow
cargo-denyLint graph/sources/advisories/licensesSAlready in CI; needs deeper integration (graph linting for transitive bloat)
cargo-vetConsensus voting on supply-chain integrityMComplement deny.toml with human-vetted transitive attestations
cargo-geigerCount unsafe blocks and associated riskSInventory unsafe code; highlight deps with high unsafe ratio
gitleaksScan repo history for secretsSPre-commit hook + periodic CI scan; prevent commit if match found
semgrepSAST: find patterns (injection, logic flaws)MDeep code review beyond OWASP spot-checks; CI gating

Tier 2 (Medium Impact, Enterprise) #

ToolPurposeEffortNotes
osv-scannerUnified vuln detection across ecosystemsMBetter than cargo-deny for cross-language projects; reverie is Rust-only (lower priority)
trivyComprehensive SCA + container scanningMFuture-proofing if Dockerfiles added; image scanning for CI/CD artifacts
grypeSyft-generated SBOM + vuln matchingMGenerate and sign SBOM for releases; attach to release artifacts

Tier 3 (Lower Priority for reverie v1) #

ToolPurposeNotes
cargo-supply-chainAudit download counts, publish dateInformational; low risk for private single-author projects
sandboxing (bubblewrap, gVisor)Runtime sandboxing for reveried workersOut of scope; requires daemon redesign

6. Seven Concrete Improvements (MVP + Future) #

1. CI-Gated Pre-commit Secret Scanning #

What: Add gitleaks scan to GitHub Actions; block commits with secrets in CI; add .git/hooks/pre-commit for local dev.

Why: .env and .secrets in .gitignore prevent accidental staging, but don’t block if developer forces add or edits history. Zero-days from leaked API keys.

Effort: S

Dependencies: gitleaks binary in GHA; ~/.git/hooks/pre-commit template (can be auto-installed via Makefile)

Ticket: TOD-XXX


2. Automated Unsafe Code Inventory via cargo-geiger #

What: Run cargo-geiger in CI weekly; generate unsafe ratio report; save to docs/security/unsafe-code-audit.md.

Why: 5335-line Cargo.lock with transitive deps; no visibility into unsafe code density or risk hotspots. Builder doesn’t know if a dependency is unsafe-heavy.

Effort: S

Dependencies: Integrate cargo-geiger into security agent; add to CI scheduled job; create report template

Ticket: TOD-XXX


3. cargo-vet Integration for Transitive Supply-Chain Attestation #

What: Adopt cargo-vet in addition to deny.toml; require security agent to audit high-risk transitive deps via community consensus.

Why: deny.toml blocks unsafe registries but doesn’t validate code quality of transitive deps (e.g., fastembed → tokenizers → paste — archived, unmaintained). cargo-vet enables voting-based trust model.

Effort: M

Dependencies: Maintain supply-chain.toml vouching for audited deps; integrate into CI (allow+block); security agent owns audit SLA

Ticket: TOD-XXX


4. Security Agent Auto-Dispatch on Zero-Day (Anchor Integration) #

What: Anchor monitors RUSTSEC feed; auto-dispatches security role with coord send --kind request --subject "ZERO_DAY_ALERT" ... if new advisory matches reverie deps.

Why: Weekly schedule catches advisories between PRs, but 7-day gap on critical CVEs is unacceptable. Current path is manual.

Effort: M

Dependencies: Anchor integration with RUSTSEC feed (curl + parse); security role handles high-effort zeroday triage requests; /herald-audit skill integration

Ticket: TOD-XXX


5. SBOM Generation & Signed Release Artifacts #

What: Generate SPDX JSON/XML SBOM via cargo-metadata; sign with GPG; attach to GitHub release. Include license inventory.

Why: No way for users to verify supply-chain integrity or audit licenses post-deployment. SLSA level 1 (provenance) not possible without SBOM.

Effort: M

Dependencies: cargo-metadata / syft; GPG key setup for maintainer; gh release upload with artifact signing

Ticket: TOD-XXX


6. GPG Commit Signature Verification in Release Workflow #

What: Release workflow checks that release tag is signed by trusted key; blocks unsigned releases.

Why: No way to verify release authenticity. Malicious actor could tag + release without maintainer knowledge.

Effort: S

Dependencies: GH branch protection rule: require signed commits; release workflow calls git verify-tag; maintainer GPG key in GH

Ticket: TOD-XXX


7. Mandatory Security Sign-Off for Releases #

What: Release workflow gates on security agent approval: security agent runs final audit, posts approve comment, release waits for that comment before gh release create.

Why: Currently release can ship without security review. Builder could push vuln code, anchor could merge, and release could happen in minutes. No human checkpoint.

Effort: M

Dependencies: Anchor watches for security approve comment; release workflow polls for it; security agent has explicit capability

Ticket: TOD-XXX


7. Minimum Viable v2 (Ship First) #

Prioritized by impact × effort:

Phase 1 (Week 1–2) #

  1. CI-Gated Secret Scanning (Effort: S; Impact: H)

    • Add gitleaks to .github/workflows/ci.yml (preflight job)
    • Block merge if secrets detected
    • Add pre-commit hook template to repo
  2. Unsafe Code Inventory (Effort: S; Impact: M)

    • Weekly cargo-geiger run; save report to docs/security/unsafe-code-audit.md
    • Include top-10 most-unsafe deps
  3. GPG Signature Verification (Effort: S; Impact: H)

    • Release workflow: git verify-tag before releasing
    • Branch protection rule: require signed commits on main

Phase 2 (Week 3–4) #

  1. SBOM Generation (Effort: M; Impact: M)

    • Generate + sign SBOM in release workflow
    • Attach to GitHub release
  2. Security Sign-Off Gate (Effort: M; Impact: H)

    • Release waits for security agent approval comment
    • Security agent runs final audit (deny + geiger + manual spot-check)

Phase 3 (Post-v2) #

  1. cargo-vet Integration (Effort: M; Impact: M)
  2. Zero-Day Auto-Dispatch (Effort: M; Impact: H)

8. Role Spec Diff (v1 → v2) #

security:
  description: "security auditor — secret scanning, dep audit, lock discipline, vuln triage, release sign-off"
  session: "reverie-security"
  worktree: "~/projects/reverie-wt-security"
  effort: "low"  # → "medium" (more active)
  model: "sonnet"
  reasoning_effort: "high"
  max_context: 128_000
  capabilities:
    - "run cargo deny / cargo audit / cargo-vet / cargo-geiger"
    - "audit lock files and dependency versions"
    - "review code for OWASP top-10 vulnerabilities"
    - "write security advisories in docs/security/"
    # NEW:
    - "scan git history for secrets via gitleaks"
    - "generate and sign SBOM (SPDX) for releases"
    - "approve/block releases via coord reply with security-sign-off"
    - "receive zero-day alerts from anchor; triage RUSTSEC advisories"
    - "audit runtime capabilities of deployed binaries"
  hard_boundaries:
    - "never modify source code outside docs/security/ and Cargo.lock"
    - "never merge PRs or push to main"
  tools:
    - "cargo deny"
    - "cargo audit"
    - "cargo-vet"                    # NEW
    - "cargo-geiger"                 # NEW
    - "gitleaks"                     # NEW
    - "/secrets-scanner agent"
    - "Grep"
    - "mem_save"
    - "gh" (for SBOM upload, comment posting)  # NEW
  task_affinity:
    - "audit"
    - "scan"
    - "vulnerability"
    - "dependency"
    - "zero-day"                     # NEW
    - "release-audit"                # NEW
    - "sbom"                         # NEW

Current:

To File (v2 Scope):


10. Appendix: Threat Model Prioritization #

Exploitable Today (if attacker has repo access) #

  1. Unsigned releases — release tag could be forged; no GPG check
  2. Secrets in history — if dev force-adds .env, no CI blocker
  3. Transitive supply-chain attack — malicious deep-tree dep not validated

Exploitable via Supply Chain (third-party compromise) #

  1. Malicious RUSTSEC advisory injection — advisories trusted without multi-source verification
  2. Unsafe code in dependencies — no visibility into risk density

Out of Scope (Reverie v1) #


11. Success Criteria #

v2 Done When:


12. References #


Status: Ready for anchor → builder hand-off + Linear ticket creation Next: File TOD-800..806; prioritize Phase 1; update security role in roles.rs post-MVP completion