Skip to content

Security: Shadow-Software-Platform/numberone

SECURITY.md

Security Policy & Threat Model — Number One

Threat Model & Implemented Controls (OWASP ASVS / CWE / NIST SSDF)

  • Tamper-Evident Stream & Crash Durability: Canonical SHA-256 hash chaining (prevHash -> hash) across discrete atomic event files and SHA-256 content-addressed blobs (MAX_BLOB_BYTES = 50 MB), written via O_CREAT|O_EXCL temp file + fsync + atomic rename + parent-dir fsync with atomic linkSync cross-process locks (0o600), process-shared instance IDs, (dev, ino) ownership verification, /proc/<pid>/stat zombie & start-ticks stale lock detection, contiguous-chain tip recovery, and integrity verification via n1 verify / n1 doctor.
  • Projection Integrity & Privilege Isolation (L1 > L2 > L3 > L4):
    • Projection caches (state.json) are tamper-detected via canonical SHA-256 snapshotDigest, strict anchor event (seq + hash) validation, and rebuilt with null-prototype maps (Object.create(null)) + forbidden-key guards (__proto__, constructor, prototype, toJSON, etc.).
    • L4 ai-agent sessions (including MCP clients and transcript ingestion) cannot supersede directives, overwrite existing lessons/ADRs/directives/issues, self-verify lessons, resolve issues, forge exec.completed crash resolutions, or promote/revert officer knowledge; MCP record_stream_event enforces an explicit non-privileged allowlist and MCP issue_directive is restricted to advisory severity.
    • PartyModeOrchestrator tracks vetoing officer roles (veto:<officer>) on Crew Remediation Gate directives so partial-officer specialist sessions cannot clear release blocks raised by absent officers.
    • AuthorityEngine evaluates executable proposal.command strings raw (without prose negation stripping) so flags like --without-lease or shell separators cannot bypass forbidden-pattern gates.
  • Living Whitepaper & Proof Ledger Security (src/core/whitepaper.ts):
    • Config, whitepaper, receipt, and ledger paths are strictly workspace-confined (assertSafeRelativeWorkspacePath + symlink-safe isWritablePathConfinedToRoot), blocking writes into .git/, protected .numberone/ internal files, and sensitive secret files.
    • Sensitive credential files (.env*, credentials.json, keys, etc.) are rejected from explicit receipts/sealed lists and skipped during auto-discovery; rendered blocks and audit_telemetry undergo secret redaction, Markdown table-cell escaping, and living-block marker injection checks; verifyLivingWhitepaper fails closed on schema_version, file ordering, MAX_SEALED_FILES, or telemetry drift.
    • Over MCP (L4 trust boundary), configPath is restricted to .numberone/*.json and init_whitepaper blocks overwrite: true.
  • Automatic Secret Redaction & Sensitive File Exclusion (CWE-532 / CWE-200):
    • Stream summaries, event metadata (actor, harness, sessionId, tags, blob.key), payloads, command outputs, text/JSON/YAML/XML blobs, LLM prompts, EvolutionVerdict outputs, MCP error responses, and outbound GitHub/Jira payloads (redacted prior to truncation) pass through the linear-time deterministic secret redactor (src/utils/redactor.ts), scrubbing PEM/PGP private keys (including truncated headers), AWS (AKIA/ASIA), GitHub (gh*/github_pat_), GitLab (glpat-/gloas-/glrt-), npm/PyPI/Google/OpenAI/Anthropic/Slack/Stripe tokens, Azure SAS sig=, JWTs, Bearer/Token/ApiKey headers, credentialed URLs (https, wss, sftp, ldaps, etc.), and sensitive key-value secrets.
    • Sensitive credential files (.env*, *.env, *.pem, *.key, *.p8, *.kdbx, id_rsa, id_ed25519, .ssh/config, .npmrc, .netrc, .htpasswd, shell history, credentials.json, etc.) are recorded metadata-only (sensitiveRedacted: true) and skipped by dynamic officer matchers, whitepaper sealing, and transcript ingestion (checking both path and canonical realpath).
    • .numberone/ state directories and files (including .numberone/whitepaper.json) use restrictive owner-only permissions (0o700 dirs / 0o600 files).
    • Gemini API keys are sent in the x-goog-api-key HTTP header rather than URL query strings; outbound HTTP clients enforce HTTPS, block private/loopback/metadata IPv4 & IPv6 ranges (including NAT64, 6to4, Teredo, IPv4-mapped/translated, zone IDs, and trailing-dot FQDNs) with per-retry DNS checks, disable redirect credential forwarding (redirect: 'error'), enforce streaming response body byte and timeout caps, scope configured credential env vars to domain prefixes (GITHUB_/GH_, JIRA_, OPENAI_/ANTHROPIC_/GEMINI_/LLM_), bind ambient env tokens to official provider hosts (or host-side N1_TRUSTED_API_HOSTS), and require host-side N1_ALLOW_PRIVATE_HOSTS=1 before honoring workspace allowPrivateHosts.
  • Default-Deny Arbitrary Command Execution (CWE-78):
    • KnowledgeEvolutionEngine disables shell execution for empirical_benchmark proposals by default (allowCommandExecution: false); MCP propose_officer_evolution permanently hardcodes allowCommandExecution: false.
    • CLI n1 evolve --allow-exec runs opted-in commands with an allowlist-sanitized environment (buildSanitizedChildEnv).
    • n1 exec -- <bin> <args...> executes directly with shell: false (eliminating double-shell interpretation) and bounds grandchild pipe-hold exits.
    • Generated Git hooks and bash/zsh shell hooks validate executables, enforce workspace/git-common-dir symlink confinement, and use strict POSIX single-quoting.
  • Symlink Escape & Path Traversal Confinement (CWE-59 / CWE-22):
    • File readers use FD-based O_RDONLY | O_NONBLOCK | O_NOFOLLOW + fstatSync(fd) + realpathSync confinement within workspaceRoot, blocking symlink swaps, FIFOs, sockets, and growing-file OOM.
    • Writable path confinement (isWritablePathConfinedToRoot) uses lstatSync to detect and reject dangling symlinks as well as live symlinks escaping the root across shims, Git hooks, whitepaper writers, and directory persistence.
  • ReDoS & Resource Exhaustion Controls (CWE-1333 / CWE-400):
    • .gitignore and evolved glob patterns use linear-time $O(N \cdot M)$ dynamic programming (matchGlobLinear) with zero regex backtracking; dynamic regexes are statically validated against nested quantifiers, quantified alternation (including nested ((a|aa))+), lazy adjacent wildcards, backreferences, and lookarounds.
    • Watched commands bound stdout/stderr memory capture in $O(1)$ using Buffer slices (default 2 MB head+tail) and forward parent SIGINT/SIGTERM to process groups.
    • MCP stdio transport uses raw-Buffer pre-allocation frame limiting (2 MB cap before UTF-8 string decoding) with stdin pause/resume backpressure and drain-safe EPIPE handling; watcher snapshot text cache is capped at 64 MB and directory watches at 2,000.
    • Daemon lifecycle serializes under .daemon.lock, opens daemon.log with O_NOFOLLOW, and verifies exact NUL-split /proc/<pid>/cmdline argv and /proc/<pid>/stat start ticks before signaling.
  • Supply Chain Integrity & Container Hardening:
    • Production runtime depends solely on zod (0 CVEs) and Node.js 22 standard library, locked by package-lock.json, audited in CI (npm audit --audit-level=high), and kept current via Dependabot (npm, github-actions, and docker).
    • GitHub Actions workflows are pinned to immutable 40-char commit SHAs with minimal top-level permissions:; .github/workflows/release.yml packs the release tarball once and publishes that exact verified artifact (with SHA256SUMS.txt and zero .map files) to both npm (SLSA OIDC provenance) and GitHub Releases.
    • Container image builds from a SHA-256 digest-pinned Node 22 Alpine image with tini PID-1 init, OCI provenance labels, root-owned read-only /app, non-root USER node, STOPSIGNAL SIGTERM, HEALTHCHECK, and CI verification under --read-only --cap-drop=ALL --security-opt=no-new-privileges.

Reporting a Vulnerability

Open a private security advisory or contact the workspace Security Officer via n1 party --officers security --topic "Security advisory".

There aren't any published security advisories