Kagex/Guides
Zero-LeakSecurity & Zero-Trust · 6 min read

Ghost Secrets Vault: Keeping API Keys & Tokens Out of AI Sandbox RAM

Even if prompt injection compromises an AI agent inside the VM and inspects every byte of /proc or environment memory, real API secrets never exist inside guest RAM.

Placeholder form
sbxph_<name>_<hex>
TLS CA
Per-daemon ECDSA P-256 local CA
Leak defense
scrubReader + cleartext drop + raw input reject
Store host secrets & bind to allowlisted domains
# Store secret safely on host (0600); never copied raw into VMs
sandboxctl secret set OPENAI_API_KEY --hosts api.openai.com
sandboxctl secret set-git GITHUB_TOKEN --repos codewithevilxd/* --branches 'sbx/*'

# Attach placeholders cleanly when starting a sandbox:
sandboxctl create -w ~/code/app --secrets OPENAI_API_KEY,GITHUB_TOKEN

Key Engineering Points · Ghost Secrets Vault & Zero-Leak Proxy

All 10 key points →
  • 1Real API tokens and credentials stay encrypted/stored solely on the host with 0600 permissions under daemon data roots.
  • 2Sandboxes receive only synthetic harmless placeholder tokens formatted as sbxph_<name>_<hex>.
  • 3Outbound HTTPS requests targeting approved secret hosts terminate TLS cleanly at a per-daemon ECDSA P-256 local CA proxy.
  • 4Host egress proxy swaps real credentials in transit strictly when both host allowlist and secret destination rules match.
  • 5Echoed secrets inside upstream HTTP response bodies or debug headers are redacted automatically back into placeholders via scrubReader.
  • 6Cleartext HTTP requests attempting to carry secret placeholders are dropped immediately before touching the wire.

Host-Side Substitution & Response Scrubbing

When the VM calls https://api.openai.com with Bearer sbxph_..., the host egress proxy terminates TLS via a local ECDSA P-256 CA, swaps the real key solely for verified host patterns, and scrubs echoed secrets via scrubReader before returning HTTP responses.

Exfiltration Prevention Across Channels

If an attacker attempts to curl an unauthorized webhook or downgrade to cleartext HTTP carrying a placeholder, Kagex drops the request. Commands, stdin, env vars, and synced files containing raw secret values are rejected up front.

Inspect this architecture live in 3D

Step through MCP ingress, Ghost Secrets, CoW blades, and run sandboxctl commands interactively in your browser.

Frequently Asked Questions

No. Printing env or reading memory inside the VM only reveals sbxph_..., which is invalid outside the host egress proxy.