Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save gwpl/413f67d7ed44ee3bf3aba796c90d1b9d to your computer and use it in GitHub Desktop.

Select an option

Save gwpl/413f67d7ed44ee3bf3aba796c90d1b9d to your computer and use it in GitHub Desktop.
πŸ” *Network-Layer Credential Injection for Agent Sandboxes β€” The Phantom Token Pattern*
title πŸ” *Network-Layer Credential Injection for Agent Sandboxes β€” The Phantom Token Pattern*
timestamp 2026-05-12
post-on-telegram-url https://t.me/llmaitools/3847

πŸ” Network-Layer Credential Injection for Agent Sandboxes β€” The Phantom Token Pattern

Most agent security discussions centre on where secrets are stored. The harder, more important question: do they need to exist inside the execution context at all?

The phantom token pattern answers: no. A TLS-intercepting proxy on the egress path holds real credentials; agents receive only a session-scoped placeholder that's worthless outside the local proxy. Even a fully compromised agent sandbox leaks nothing actionable.

Threat model shift:

Storage hygiene (encrypt-at-rest, vault pull-on-start) β†’ Runtime isolation (credentials never materialise inside agent memory or filesystem)

This is architecturally identical to enterprise HTTPS inspection (Charles Proxy, corporate SSL appliances) β€” repurposed for agent VM egress.

───────────────────────────── 🧰 Self-hostable OSS β€” decision matrix

β–Έ Containerised agents, SDK-driven, fast deploy: β†’ Infisical agent-vault (MIT, launched Apr 2026) HTTP API :14321 + transparent MITM proxy :14322 | AES-256-GCM at rest | scoped per-session tokens | request logging | TS SDK @infisical/agent-vault-sdk (buildProxyEnv() targets Docker / Firecracker / E2B) | works with Claude Code, Cursor, Codex CLI out of the box

β–Έ Full VM isolation + strict network allowlist: β†’ matchlock Firecracker microVMs (<1s boot on Linux; Apple Virtualization.framework on macOS) | host-side MITM gateway | iptables/nftables DNAT :80/:443 β†’ host proxy | deny-by-default FQDN allowlist | ephemeral COW FS | strongest isolation in OSS set today

β–Έ Custom injection logic / roll-your-own: β†’ mitmproxy (MIT) request(flow) addon, match on flow.request.pretty_host, set flow.request.headers['Authorization'] β€” foundation layer for most of the above

β–Έ Hardened production runtime: β†’ NVIDIA OpenShell Safe/private runtime for autonomous agents; gateway as auth boundary; supervised egress routing; policy enforcement

β–Έ Secrets backend (K8s/Helm): β†’ Infisical self-hosted (Docker/Helm) + Cilium FQDN egress policies as defence-in-depth β€” agents physically can't reach unauthorised hosts even if proxy is bypassed

───────────────────────────── ☁️ Hosted / commercial reference points

β€’ SecretProxy.io β€” runtime secret isolation; the CISO framing is sharp: "changes whether secrets need to be present inside service memory at all" β€’ HashiCorp Boundary + Vault β€” JIT credential injection into sessions; dynamically generated creds, never seen by user β€’ Docker AI Sandboxes β€” credential injection for sandboxed agents; keys never exposed inside container β€’ exe.dev β€” network injection on egress; reference implementation for this pattern

───────────────────────────── πŸ— Multi-tenant platform design checklist

  1. Egress DNAT β€” iptables/nftables redirect :80/:443 inside VM netns before egress
  2. Per-session placeholder tokens β€” short-lived, scoped; full VM compromise β‡’ expired placeholder only
  3. FQDN-scoped injection β€” inject only for intended host; prevents credential exfil via attacker-controlled domains in "authorised-looking" requests
  4. Cilium FQDN egress policy as defence-in-depth alongside the proxy layer
  5. Scoped-session model β€” mint per-user/per-run token, pass proxy env into sandbox; master credentials never enter user-controlled compute

───────────────────────────── πŸ“š Community tracking: bureado/awesome-agent-runtime-security β€” curated list of credential injection tools, sandboxed runtimes, egress policy primitives. Space is moving fast, worth watching.

#AgentSecurity #AIAgents #LLMSecurity #Sandboxing #SecretsManagement #Kubernetes #ZeroTrust #mitmproxy #Firecracker

timestamp 2026-05-12
post-on-telegram-url https://t.me/llmaitools/3847

πŸ” Phantom Token / Network-Layer Credential Injection β€” OSS Shortlist & Design Playbook

The distinction that matters first:

Storage hygiene = secrets encrypted at rest, rotated, ACL'd. Runtime isolation = secrets never present in the execution environment β€” full VM compromise yields zero credential value.

Most teams solve the first. The pattern worth tracking solves the second.


How the TLS swap works: Local CA generated per sandbox β†’ CA trusted inside VM β†’ proxy terminates TLS from VM β†’ reads & rewrites Authorization header β†’ re-establishes fresh TLS to upstream. Identical to Charles Proxy / Zscaler SSL inspection, repurposed for agent egress. Same concept: you can't steal what was never there.


πŸ›  Self-hostable OSS β€” drop-in shortlist:

Infisical Agent Vault (MIT) β†’ github.com/Infisical/agent-vault HTTP API :14321 + transparent MITM proxy :14322. agent-vault run -- <agent> auto-injects HTTPS_PROXY + CA trust. AES-256-GCM at rest, scoped per-session tokens, full request logging. TS SDK (@infisical/agent-vault-sdk, buildProxyEnv()) for Docker / Firecracker / E2B. Works drop-in with Claude Code, Cursor, Codex. Docs: docs.agent-vault.dev β†’ Most complete drop-in today.

Matchlock (OSS) β†’ github.com/jingkaihe/matchlock Firecracker microVMs (<1s boot on Linux; Apple Virtualization.framework on macOS) + host-side MITM gateway. iptables/nftables DNAT redirects :80/:443 inside VM netns β†’ host proxy. FQDN allowlist deny-by-default, ephemeral COW FS. Agent sees a placeholder like SANDBOX_SECRET_a1b2c3d4; host swaps the real key only for permitted FQDNs. β†’ Strongest VM-level isolation in the OSS set.

NVIDIA OpenShell (OSS) β†’ github.com/NVIDIA/OpenShell | build.nvidia.com/openshell K3s cluster in a single Docker container. Gateway as control-plane auth boundary. Declarative YAML policies enforced at system level β€” agent cannot override. Supervised egress routing, Privacy Router for local inference routing before hitting frontier models. Part of NVIDIA Agent Toolkit. β†’ Best fit for hardened production runtimes and policy-heavy orgs.


πŸ”© Primitives to roll your own:

β€’ mitmproxy (MIT) β€” mitmproxy.org β€” Python request(flow) hook: check flow.request.pretty_host, set flow.request.headers['Authorization'] = f'Bearer {REAL_KEY}'. Foundation of most OSS impls above. β€’ Infisical core (MIT, Docker/Helm) β€” secrets backend + ACL; pair with mitmproxy for the injection layer. Helm-native for K8s. β€’ Cilium FQDN egress policies β€” K8s-level allowlisting so agents physically can't reach unauthorized hosts even if the proxy is bypassed. Defense-in-depth layer, not a substitute.


🏒 Hosted / commercial reference points:

β€’ exe.dev β€” network injection on egress; reference implementation for the pattern (docs.exe.dev/integrations) β€’ SecretProxy.io β€” docs.secretproxy.io β€” the CISO framing worth lifting verbatim: "changes whether secrets need to be present inside service memory at all β€” difference between storage hygiene and runtime isolation" β€’ HashiCorp Boundary + Vault β€” JIT credential injection into sessions; dynamically generated creds, never seen by operator. hashicorp.com/en/blog/prevent-secret-exposure-across-it-4-tools-and-techniques β€’ Docker AI Sandboxes β€” docs.docker.com/ai/sandboxes/security/credentials/ β€” credential injection for sandboxed agents; keys never exposed to container.


πŸ— Multi-tenant platform design checklist:

  1. Egress DNAT β€” redirect :80/:443 inside VM netns before egress; agent can't bypass at userspace
  2. Per-session placeholder tokens β€” short-lived, scoped; full VM compromise leaks only the placeholder
  3. FQDN-scoped injection β€” inject creds only for intended upstream host; blocks exfil to attacker-controlled lookalike domains in authorized-looking requests
  4. Cilium FQDN policy as second layer β€” even if proxy is misconfigured
  5. Scoped-session model (agent-vault pattern) β€” mint per-user/per-run token, pass proxy env into sandbox; master creds never enter user-controlled compute

⚑ Decision matrix:

Use case Tool
Containerized agents, SDK-driven Infisical Agent Vault
Full VM isolation + FQDN allowlist Matchlock (Linux/Firecracker)
Custom injection logic mitmproxy addon
Secrets backend only Infisical self-hosted
K8s multi-tenant Infisical (Helm) + Cilium
Hardened production runtime NVIDIA OpenShell

Community curated list (worth watching β€” space moving fast): β†’ github.com/bureado/awesome-agent-runtime-security

Formal multi-agent authorization threat model (arXiv, May 2026): arXiv:2605.05440

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment