SecretHarbor Technical Manual
The definitive reference guide for SecretHarbor (shb): architecture, kernel sandboxing primitives, format-preserving secret virtualization, process tree inheritance, and command-line usage.
SecretHarbor is currently in active developer preview. Pre-compiled release packages for macOS, Linux, and Windows are published on GitHub Releases, and the installer verifies each artifact's SHA-256 checksum before installation.
Overview & Core Philosophy
AI coding agents—such as Claude Code, Cursor, Codex, Google Antigravity, Gemini CLI, OpenCode, Amazon Kiro, Ollama, and Aider—require expansive read/write access to your workspace to generate tests, execute builds, inspect compiler outputs, and refactor code.
However, granting an untrusted AI model unconfined access to your local machine inevitably exposes sensitive API keys (Stripe, OpenAI, AWS), production database credentials, local SSH keys (~/.ssh), Docker daemon sockets (/var/run/docker.sock), and private loopback IPC endpoints.
CONTROL PLANE VS DATA PLANE
Host Operating System (Human Developer / Trusted Workstation)
│
├── Real .env (Real Production Database Passwords, Live Stripe Keys)
├── Real SSH Private Keys (~/.ssh/id_ed25519) & Cloud Tokens (~/.aws)
│
└── ═══════════════════════════════════════════════════════════════════════
[ SecretHarbor Security Boundary (Kernel-Level Enforcement) ]
═══════════════════════════════════════════════════════════════════════
│
├── AI Agent Process (claude, cursor-agent, agy, gemini, codex)
│ ├── Sees Format-Preserving Synthetic Fakes (sk_test_shb_fake_...)
│ ├── Egress Network Policy (Allowed with explicit deny lists)
│ ├── Intercepted Docker & Unix Domain Sockets
│ └── Close-on-Exec Sanitized File Descriptors (FD 3+ Closed)
│
└── Sandboxed Descendants (MCP Servers, bun test, pytest, npm, bash)
The Core Principle
Traditional agent security frameworks fail because they operate inside the agent or as natural-language system prompts. Prompt injection, subagent delegation, or shell tool escapes immediately bypass prompt guardrails. SecretHarbor is designed around a single immutable tenet:
"Do not lock the file. Lock the agent's capability to access the file."
Enforcement occurs strictly below the agent at the operating system kernel layer. An agent cannot negotiate with, hallucinate past, or prompt-inject its own kernel sandbox boundary.
The 6 Non-Negotiable Security Invariants
| Invariant | Guarantee | Enforcement Layer |
|---|---|---|
| 1. Self-Policy Lockout | An agent cannot weaken, modify, or override its own security boundary. | Read-only policy compilation & filesystem write denial. |
| 2. Human Transparency | Human developer workflows, credentials, and terminals remain completely unchanged. | Shadow workspace (macOS) / mount virtualization (Linux) — real files never modified. |
| 3. Process-Specific Isolation | Files are protected strictly from the agent process tree, not globally across the OS. | Mount namespaces & process-tree kernel tracking. |
| 4. Kernel-Enforced Layer | Enforcement lives strictly below the agent process, not in prompts or wrappers. | macOS Apple Seatbelt & Linux User Namespaces. |
| 5. Holistic Boundary | Filesystem, environment variables, IPC sockets, and network egress are unified. | Unified SecretHarbor capability broker. |
| 6. Measurable Claims | Security guarantees must be verifiable via live adversarial attack vectors. | shb doctor 18-vector automated regression suite. |
Kernel & Operating System Architecture
SecretHarbor implements native operating system primitives across supported platforms, avoiding heavyweight virtual machines or Docker-in-Docker overhead while delivering hardware-speed execution.
macOS Enforcement: Apple Seatbelt
On macOS (12.0+ Monterey and later), SecretHarbor leverages the Apple Seatbelt kernel subsystem (sandbox-exec and native libsandbox.dylib).
- Dynamic Scheme Compilation: Generates and compiles fine-grained Sandbox Scheme profiles (
(version 1) (deny default)...) tailoring exact filesystem and IPC capabilities per session. - Shadow Workspace Virtualization: Before launch, SecretHarbor creates an ephemeral mirror of the project. Non-secret files are hard-linked (so agent edits flow back to the real project), secret files are replaced with format-preserving synthetic fakes, and control-plane files (
secretharbor.yaml) are exposed read-only. The real.envon disk is never modified, so a crash orkill -9cannot leave fakes behind. - Whole-Tree Process Termination: When an agent session completes, SecretHarbor initiates a clean signal cascade (
SIGTERMfollowed bySIGKILLafter a 5-second grace period) to eliminate orphan background tasks. - GUI Terminal Decoupling & Desktop App Boundary: The SecretHarbor security boundary is scoped to the process tree rooted at
shb run. Desktop apps opened directly — by double-clicking, Spotlight, Dock, or any GUI launcher — start outside that tree and receive no protection. Bring a GUI app inside the boundary withshb run -d cursor-app(detached), or adopt a running one withshb adopt.
Linux Enforcement: Unprivileged User Namespaces & Landlock
On Linux (kernel 5.10+), SecretHarbor utilizes unprivileged user namespaces, mount isolation, and the Landlock LSM without requiring sudo or root privileges.
- User Namespaces (
CLONE_NEWUSER): Maps the agent to an unprivileged identity so no root capabilities are available inside the boundary. - Mount Isolation (
CLONE_NEWNS): Creates an isolated mount table where synthetic fakes are bind-mounted over real secret paths and denied files are masked. Host files are never changed. - IPC Isolation (
CLONE_NEWIPC): Prevents the agent from reaching host SysV IPC and abstract sockets outside its namespace. - Landlock LSM: Restricts filesystem access at the kernel LSM layer as a defense-in-depth layer beneath the namespace boundary.
- Memory Inspection Defense: Applies
prctl(PR_SET_DUMPABLE, 0)to prevent unauthorized memory attachment,ptraceinspection, and/proc/<pid>/memreading. - Sensitive Path Masking: Read-only masking over
/proc/kcore,/proc/sys, and/proc/self/environ.
Windows Developer Preview Architecture
On Windows (Windows 11 / Server 2022+), SecretHarbor executes inside a restricted developer preview environment utilizing Windows Job Objects, Restricted Security Tokens (with stripped privileges like SeDebugPrivilege), and Low Integrity Level execution.
Secret Virtualization Engine
The fatal flaw in traditional secret-stripping tools is that they break developer test runners. When a test suite (bun test, pytest, cargo test) executes, stripping API keys causes authentication errors, regex parser crashes, or syntax failures.
SecretHarbor solves this through Dual-Reality Capability Projection:
Synthetic secrets match the exact character length, entropy distribution, validation checksums, and prefix syntax of real credentials. Code linters, schema validators, and test harnesses continue running without crashing.
Synthetic Secret Generation Matrix
| Credential Type | Real Pattern (Human Only) | Synthetic Format-Preserving Fake (Agent Context) |
|---|---|---|
| Stripe Live Secret | sk_live_51Oz...94F1 |
sk_test_shb_fake_mocked00000000000000000 |
| PostgreSQL Database URI | postgres://prod_admin:p@ss@aws.rds:5432/app |
postgres://fake_agent:shb_sync@127.0.0.1:5432/test |
| AWS Access Key ID | AKIAIOSFODNN7EXAMPLE |
AKIAIOSFODNN7SHBFAKE |
| AWS Secret Access Key | wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY |
wJalrXUtnFEMI/K7MDENG/bPxRfiCYSHBEXAMPLE |
| OpenAI API Key | sk-proj-abc123realkey... |
sk-proj-shb_fake_mocked_key_00000000000000000000 |
| GitHub Token | ghp_realtoken123456789... |
ghp_shb_fake_mocked_token_000000000000000 |
| SSH Auth Socket | /var/run/ssh-agent.sock |
[Blocked / Dropped from Environment] |
Shadow Workspace & Mount Virtualization
In the default mode: fake, your real secret files are never modified. The agent runs inside a per-session virtualized view:
- macOS — Shadow Workspace: An ephemeral mirror of the project is created under the system temp directory. Non-secret files are hard-linked (so agent edits flow to the real project), secret files are replaced with format-preserving fakes, and
secretharbor.yamlis exposed read-only. - Linux — Mount Virtualization: Inside the agent's mount namespace, synthetic fakes are bind-mounted over the real secret paths; only sandboxed processes see them.
- Auto-Inject: Synthetic values from
.envare merged into the agent's process environment, soprocess.env.<KEY>is always defined. - Humans keep real values: Your editor, your shell, and
bun test/pytest/npm testrun outside the sandbox and see the real.env, even while an agent session is active.
Because the real files are never swapped, a crash, kill -9, or reboot cannot leave fakes on disk. shb restore remains available only for legacy in-place swap sessions from pre-shadow-workspace versions.
Secret Brokering: Separating "Read" from "Use"
Developers frequently encounter a dilemma: an agent must run an automated end-to-end integration test against an external service, but giving the agent access to the API token allows it to exfiltrate or log the token.
SecretHarbor resolves this by separating the capability to inspect from the capability to use:
- Agent Context: The agent process only holds the synthetic token:
STRIPE_KEY=sk_test_shb_fake_.... - Loopback Egress Proxy: Outbound HTTP requests to authorized destinations (e.g.,
api.stripe.com) pass through the local SecretHarbor capability broker. - In-Flight Header Replacement: The broker inspects the request, validates destination policy, and swaps the fake token with the real credential in-flight on the egress socket.
- Zero Agent Memory Exposure: The real secret is never loaded into the agent's process memory, stack, or environment variables.
Ambient Environment & File Descriptor Sanitization
When a developer launches an AI agent from their terminal, the parent shell's environment variables leak ambient credentials into child processes. SecretHarbor executes deep sanitization prior to process launch:
Environment Variable Sanitization
The parent environment is filtered against both automated heuristic patterns (regex scanning for keys matching *_KEY, *_SECRET, *_TOKEN, *_PASSWORD) and explicit policy overrides:
AWS_ACCESS_KEY_ID → Faked (AKIAIOSFODNN7SHBFAKE)
AWS_SECRET_ACCESS_KEY → Faked (wJalrXUtnFEMI/K7MDENG/bPxRfiCYSHBEXAMPLE)
DATABASE_URL → Faked (postgres://fake_agent:shb_sync@127.0.0.1:5432/test)
STRIPE_API_KEY → Faked (sk_test_shb_fake_mocked...)
SSH_AUTH_SOCK → Denied / Stripped
DOCKER_HOST → Denied / Stripped
KUBECONFIG → Denied / Stripped
Close-on-Exec (FD 3..1024) Protection
Parent shells often hold open file descriptors to private logs, sockets, or sensitive files. When a child process is spawned, POSIX standards inherit open descriptors unless FD_CLOEXEC is explicitly set. SecretHarbor iterates through all descriptors above standard I/O (FD 3 through 1024) and forcibly closes them before handing control to the agent.
Network Security & Domain Filtering
An agent with unconfined network egress can exfiltrate local source code or scan internal subnets. SecretHarbor configures transparent egress controls with three distinct protection presets:
| Preset | Internet Egress | Private Subnets (RFC 1918) | Cloud Metadata (169.254.169.254) |
|---|---|---|---|
| standard DEFAULT | Allowed (explicit domain denylist) | BLOCKED | BLOCKED |
| restricted STRICTER | Domain Allowlist Only (npm, GitHub, etc.) | BLOCKED | BLOCKED |
| strict AIRGAP | FULL NETWORK DENIAL | BLOCKED | BLOCKED |
Cloud Metadata & SSRF Defense
Cloud instance metadata services (169.254.169.254 on AWS, GCP, Azure, and DigitalOcean) hold IAM role credentials and node tokens. SecretHarbor drops all egress packets routed toward 169.254.169.254 regardless of the active preset.
Internal RFC 1918 subnets (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) are shielded to prevent rogue agents from scanning local LAN routers or intranet endpoints.
Local IPC & Docker Daemon Interception
Local Unix domain sockets represent a primary privilege escalation vector. An agent with read/write access to /var/run/docker.sock can spawn a privileged container mounted to the host root filesystem (-v /:/host), completely bypassing all OS security boundaries.
Giving an AI agent raw access to the Docker daemon is equivalent to granting passwordless root access to your machine. SecretHarbor blocks raw socket access by default.
Capability Leasing Model (shb lease)
When an agent task requires running a Docker container (e.g. docker run -p 5432:5432 postgres), SecretHarbor intercepts the connection and prompts the human developer for authorization:
- Approval Dialog: The developer inspects the exact command and flags.
- Time-Bound Lease: Approved leases grant temporary access (default 10 minutes) via a filtered socket proxy.
- Flag Sanitization: Dangerous arguments (such as
--privileged,--cap-add=ALL, and host root mounts-v /:/...) are automatically rejected.
Complete Command-Line Reference
SecretHarbor exposes a unified CLI surface (shb or alias secretharbor) designed for fast, human-friendly operation and scriptable CI/CD integration.
| Command | Arguments / Flags | Description |
|---|---|---|
shb init |
[path] [--yes] [--force] |
Initializes host integration, installs agent shims, configures shell PATH, and creates secretharbor.yaml. |
shb adopt |
[-y, --yes] |
Discovers unprotected running agents on the system, safely terminates them, and restarts them inside the sandbox. |
shb restart |
<agent-name> |
Cleanly restarts an active agent session inside a fresh kernel boundary. |
shb run |
[-d, --detach] <agent> [args...] | -- <command...> |
Explicitly starts an agent or command inside the boundary; -d runs it detached in the background (manual/debug fallback). |
shb status |
— |
Displays active protection status, platform capability tier, and running sandboxed sessions. |
shb sessions |
— |
Lists all currently active SecretHarbor sessions, process IDs, and process tree hierarchies. |
shb stop |
[session-id] |
Safely terminates an active agent session (graceful signal cascade, cleans up temporary sandbox state). |
shb config |
show | get | set | source | check | edit | diff |
Inspects effective configuration without exposing raw credentials. edit is strictly human-only. |
shb policy |
check | explain <resource> [--network] |
Explains why a file, environment variable, or domain was faked, denied, or allowed. |
shb secret |
list | status | test | set | delete |
Manages credentials in local AES-256-GCM vault. Never prints raw secrets to terminal stdout. |
shb env |
edit |
Opens the real .env in $EDITOR for safe live editing. A running session keeps its synthetic copy. |
shb restore |
[path] [--all] [--orphans] |
Restores real secret files for legacy in-place swap sessions (pre-shadow-workspace) or after an interrupted session. |
shb trust |
list | add | remove <tool> |
Maintains an advisory list of trusted tools and processes (metadata only; not yet enforced by the sandbox). |
shb doctor |
— |
Executes the 18-vector adversarial attack suite verifying security boundary integrity. |
shb guard |
on | off |
Enables or explicitly disables protection for the workspace (disabling requires interactive human confirmation). |
shb update |
[--check] [--version <ver>] [--dry-run] [--json] |
Checks for and installs verified SecretHarbor updates with cryptographic signature validation. |
shb version |
[--json] |
Displays version, platform, OS kernel, active sandbox driver, and policy specification version. |
shb logs |
[limit] |
Displays recent local redacted audit log events (default 20). |
shb help |
[command] |
Displays general usage or command-specific reference manual. |
Supported Coding Agents & Adapters
SecretHarbor is agent-agnostic. While agent shims and aliases provide seamless ergonomics, the boundary is enforced below the process tree regardless of which model, runtime, or IDE is active:
SecretHarbor's security boundary applies only to processes that are children of shb run. If you open Cursor, VS Code, or any other GUI application by double-clicking its icon, via Spotlight, or from the Dock, it starts outside the boundary and receives no protection — even if shb is installed.
Always launch desktop tools from the terminal:
# Protected — boundary applies to Cursor and all its agents
shb run -- cursor .
# Also protected after `shb init` registers the shim:
cursor .
# NOT protected — opened from Finder/Spotlight/Dock
# (double-clicking Cursor.app)
# Claude Code Native Launch (automatic shim after shb init)
claude
# Explicit launch with SecretHarbor runtime boundary
shb run -- claude
# Verify sandbox posture inside Claude Code session
$ shb status
# Launch Cursor Agent inside boundary
shb run -- cursor .
# If Cursor is already running without protection:
shb adopt --yes
# Google Antigravity Agent runtime integration
shb run -- agy
# Child subagents automatically inherit the kernel sandbox boundary
# Gemini CLI Agent execution
shb run -- gemini-cli
# OpenAI Codex runner
shb run -- codex run
# Aider terminal agent
shb run -- aider
# Cline VS Code extension agent
shb run -- cline
MCP (Model Context Protocol) Server Boundary Isolation
When an agent spawns child Model Context Protocol (MCP) servers (e.g. database connectors, filesystem tools, memory servers), those processes inherit the exact kernel boundary of the parent agent. MCP tools cannot circumvent the sandbox to access real credentials.
shb doctor & The 18 Adversarial Security Vectors
Security claims that cannot be tested are merely promises. shb doctor runs an automated, red-team attack suite simulating real-world exploit attempts directly against the running security boundary:
| # | Adversarial Attack Vector | Simulated Exploit Technique | Result |
|---|---|---|---|
| 01 | Direct Secret Read | cat .env / open(".env", O_RDONLY) |
PASS · FAKED |
| 02 | Python Interpreter Read | python3 -c "open('.env').read()" |
PASS · FAKED |
| 03 | Node Interpreter Read | node -e "require('fs').readFileSync('.env')" |
PASS · FAKED |
| 04 | Symlink Bypass | ln -s .env link.txt && cat link.txt |
PASS · BLOCKED |
| 05 | Path Traversal | cd subdir && cat ../.env |
PASS · FAKED |
| 06 | Copy Bypass | cp .env /tmp/leaked.txt |
PASS · FAKED |
| 07 | Rename Bypass | mv .env .env.bak / move out of tree |
PASS · BLOCKED |
| 08 | Real Secret Env Var Exposure | printenv / cat /proc/self/environ |
PASS · SANITIZED |
| 09 | SSH_AUTH_SOCK Privileged IPC | Connecting to host SSH_AUTH_SOCK |
PASS · STRIPPED |
| 10 | Privileged Docker Socket Access | Connecting to /var/run/docker.sock directly |
PASS · INTERCEPTED |
| 11 | DOCKER_HOST Privileged IPC Leakage | Querying injected DOCKER_HOST |
PASS · STRIPPED |
| 12 | Container Secret Directory Inspection | Inspecting /run/secrets/* |
PASS · MASKED |
| 13 | Sensitive Descriptor Leak (Close-on-Exec) | Reading inherited FD: cat <&3 / /proc/self/fd/3 |
PASS · CLOSED |
| 14 | Policy File Modification | rm / edit secretharbor.yaml from agent |
PASS · READONLY |
| 15 | Process Memory Tracing (ptrace) | ptrace(PTRACE_ATTACH) / /proc/<pid>/mem |
PASS · BLOCKED |
| 16 | Core Dump Restrictions | Triggering a core dump / PR_SET_DUMPABLE bypass |
PASS · BLOCKED |
| 17 | Network Egress Isolation | Raw outbound socket / SSRF to 169.254.169.254 |
PASS · DROPPED |
| 18 | Root Filesystem Escape | Mount / chroot escape from the sandbox | PASS · BLOCKED |
Configuration Specification (secretharbor.yaml)
Project policies are declared in secretharbor.yaml or .secretharbor/policy.yaml in the repository root:
# SecretHarbor Configuration File (v1)
# Documentation: https://secretharbor.dev/docs.html
version: 1
# Protection presets: standard | strict | permissive
# - standard: secret files faked, sensitive env sanitized, network allowed, escape denied
# - strict: all secrets denied, strict network denial, no escapes
# - permissive: obvious secrets faked, network allowed
protection: standard
# Default secret virtualization mode: fake | deny | allow
secrets:
mode: fake
# Exceptions to default secret handling
exceptions:
allow:
- .env.example
deny:
- .env.production
- secrets/**
# Outbound network domain policy (allowed by default; domains can be explicitly denied)
network:
mode: allow
# Optional: explicitly deny specific domains
# deny:
# - telemetry.example.com
# Local IPC endpoints and daemon protection
ipc:
unix_sockets:
mode: deny
abstract_sockets:
mode: deny
docker:
mode: approval # approval | deny | allow
# Sandbox escape controls (human approval required)
sandbox:
escape: deny
Zero-Telemetry Guarantee & Cryptographic Security
Security tools must not become security liabilities. SecretHarbor is engineered with an uncompromising privacy architecture:
- 100% Local Execution: SecretHarbor never transmits source code, file names, environment keys, credentials, or audit logs to remote telemetry endpoints or cloud services.
- Local AES-256-GCM Vault: Credentials managed via
shb secretare stored strictly on the local machine in~/.secretharbor/vault.encutilizing authenticated AES-256-GCM encryption with cryptographic keys derived from local machine salts or OS keychains. - Redacted Local Audit Logs: Operational audit trails are written strictly to
~/.secretharbor/audit.logwith automated real-time regex and entropy redaction. - Fail-Closed Principle: If the kernel sandbox or virtualization layer encounters an initialization error, the process terminates immediately rather than failing open into an unprotected state.