Secret Injection Patterns for Isolated Agent VMs
Isolating agents requires per-VM credentials kept outside the process environment.

With Firecracker micro-VM isolation, each AI agent has its own guest kernel. Secret Injection Patterns for Isolated Agent VMs explains why that boundary also needs per-agent identity, controls on credential delivery, and limits on outbound access. The central rule is simple. Isolate the agent’s execution, but keep high-value credentials out of its reach wherever possible.
Why isolated agent VMs create a different secret-management problem than ordinary cloud services
A conventional web service can fetch secrets at startup for a narrow, known process. An agent combines secret access, code execution, and outbound network calls in a process whose behavior can change after reading external content. Malicious instructions in a README file, git commit message, or MCP server response can redirect that process without changing its permissions. The resulting request still comes from an authorized role, so ordinary RBAC cannot distinguish the developer’s intent from an attacker’s instruction.
Microsoft’s OpenClaw security guidance divides the agent boundary into identity, execution, and persistence. Credential protection must account for all three because an agent can use tokens, execute tools, and preserve changes across runs. In a per-user architecture such as Maritime’s, where each agent runs in an isolated Firecracker micro-VM, each VM may also hold a distinct user’s credentials. A cross-tenant leak can thus expose another account’s data as well as one service’s configuration.
How do you give each AI agent its own isolated kernel without containers
Containers share the host kernel, so a vulnerability in that kernel can bypass namespace isolation and expose other tenants. A Firecracker micro-VM instead has its own guest kernel behind a hardware-enforced memory boundary controlled by the hypervisor. Compromising that guest kernel does not, by itself, compromise sibling VMs. Crossing the outer boundary requires a hypervisor exploit, which presents a smaller attack surface than the shared host kernel.
That separation gives secret-delivery controls a foundation outside the agent’s execution environment. Firecracker combines its VM boundary with controls including seccomp filtering, cgroups, namespaces, and a jailer process. These controls provide defense in depth alongside the hardware boundary. They also do not stop a compromised agent from reading secrets that its own permissions already allow it to read.
Maritime places each agent inside its own Firecracker micro-VM on bare metal, with a persistent disk and a real kernel. Its snapshot-restore scheduling separates an agent’s persistent workspace from the need for continuously running compute. For secret management, the important distinction is between execution isolation and credential isolation.
Environment variable injection: when it is acceptable and when it is not
Environment injection places values in the agent process’s environment at boot. It is easy to use for non-sensitive configuration, including region, log level, and feature flags. It is unsuitable for high-value credentials in an agent that executes code or reads untrusted content. A long-lived API key, a database password, and an OAuth refresh token all fall into that category.
A compromised MCP server can return instructions that tell the agent to read and exfiltrate AWS_SECRET_ACCESS_KEY, database connection strings, or API tokens. Because the process already possesses these values, no additional authorization decision stands between the malicious instruction and the credential. This is ambient authority, where permissions are inherited. For agents with full process execution, including those hosted in Maritime’s micro-VM architecture, a private kernel does not make readable environment variables safe from the agent itself.
Short-lived bootstrap tokens can be used in this limited case if they are exchanged right away for scoped credentials. Read-once values can also fit when they are consumed and discarded before external content reaches the agent. Where environment injection is necessary, the values should enter at boot inside the micro-VM boundary rather than through a shared orchestrator environment. Clearing them after use cuts the time they stay exposed, but long-lived credentials still do not belong there.
Mounted file and in-memory tmpfs delivery: isolating secrets from the executable environment
File-based delivery separates credential storage from the process environment. At startup, an init process fetches secrets from a secret manager and writes them into a tmpfs mount inside the VM. The agent receives read access only to the specific paths it needs, under the narrowest possible file permissions. The improvement is scoped access rather than automatic inheritance through the executable environment.
The memory-only constraint matters because a persistent volume can outlive the VM session. Tmpfs creates no ordinary files on the persistent block device, and its contents disappear when the mount is removed or the VM is destroyed. But Linux kernel documentation says that tmpfs can swap pages to disk under memory pressure. A memory-only delivery claim therefore depends on whether swap is enabled.
File permissions remain the enforcement layer inside the guest. An agent that can read a credential file can still disclose its contents, so tmpfs reduces persistence and exposure without making the secret inaccessible to its intended consumer. In the boot-time pattern, rotation means re-injecting the replacement at the next boot, with no persistent file copies to find. The distinction is important for agents whose workspace disks intentionally survive across sessions.
Vsock-based injection and the vsock channel's security properties
Vsock moves secret delivery away from the process environment and onto a host-to-guest communication channel. In the QEMU/KVM arrangement described in the notes, the host’s vhost-vsock backend works with a virtio-vsock device exposed to the guest. Secrets moving through that channel stay out of view when the process environment is inspected.
The channel and the destination nevertheless provide different guarantees. Purpose-built agent VM images can combine vsock delivery with tmpfs storage, so one mechanism transports the secret and the other holds it in memory. This avoids injecting the value into the agent’s environment. It does not mean that a secret becomes unreadable after delivery if the agent has permission to read its destination.
The useful security property is separation of delivery from ordinary application state. The separation between kernel and user-space helps only while the privilege boundary between them holds. Vsock is therefore complementary to narrow file permissions and memory-only storage. Keeping the real credential outside the VM altogether requires a different pattern.
The phantom token pattern: structural credential protection for agents that can be fully compromised
A proxy on the host holds the real credential, while the agent gets only a per-session phantom token. For each downstream call, the proxy validates that token, substitutes the real credential, and forwards the request. The privileged material never crosses into the VM.
This does more to guard against credential extraction than environment, file, or channel controls. Even a fully compromised agent cannot disclose a real credential it has never held. Its phantom token has no value outside the proxy, although the compromised agent may still attempt calls through that proxy.
An MCP gateway works the same way: it validates agent identity, checks policy, and injects the needed secret into the outgoing tool request. The real secret stays out of the agent’s prompts, logs, and memory. The tradeoff is that proxy availability sits on the critical path, and proxy security becomes a trust anchor. This is an appropriate tradeoff for high-value credentials when used with the delivery patterns above.
Per-agent identity and OAuth token exchange for multi-tenant secret isolation
When every agent uses the same master credential through a proxy, that shared authority allows one tenant’s malicious content to redirect an agent toward another tenant’s data. Per-user vaulting narrows the scope by keeping each end user’s credentials in a separate collection referenced when a session is created. The agent definition can stay the same while the credential context changes for each user.
OAuth 2.0 Token Exchange, defined in RFC 8693, supports exchanging an inbound user token for an audience-bound downstream token. The issued token’s aud claim names the service it is for, and that service must validate the audience. Where tenant APIs have distinct audiences, a token issued for one tenant’s API is rejected by another’s audience validation. The claim does not itself encode a universal tenant-isolation rule, so the guarantee depends on the service and tenant mapping.
Each user can then grant scoped, revocable access tied to their own account. Revoking that access does not require rotating a master credential shared across the fleet. Maritime’s per-user VM model works with this separation and still needs it. The VM boundary isolates execution, while per-session identity and token exchange isolate credential authority.
Identity-based dynamic credential retrieval: fetching secrets at the moment of use rather than at boot
Boot-time delivery leaves a credential available throughout the session, even when no tool needs it. Just-in-time retrieval instead authenticates the workload when a specific call requires access. The authentication mechanism can be an IAM role, a signed attestation, or a platform-issued token. The retrieved secret is a separate, short-lived credential used for the downstream operation.
That distinction separates the trust anchor from the material being rotated. Workload identity establishes which VM is asking, while the secret store’s authorization policy determines what it may receive. A compromised VM retains a security-sensitive workload identity without automatically bypassing that policy. Dynamic retrieval narrows exposure rather than making an authorized, compromised workload harmless.
A short-lived credential can expire after the call or after a short TTL, limiting an extracted token’s usefulness. The benefit is greatest when credentials are absent between operations. This pattern also requires the secret store to be reachable from inside the VM. Egress policy must therefore allow the credential endpoint and approved tool destinations while restricting other outbound traffic.
Prompt injection as a credential-harvesting vector and the detection layer that complements VM isolation
These controls restrict what a successful injection can reach, but they do not prevent external content from redirecting an agent. An attacker may still induce an authorized tool call without ever extracting a credential. A phantom token protects the underlying secret, and audience binding constrains its destination, but the requested action may still depart from the user’s intent. Detection addresses that remaining instruction boundary.
The prompt-shield research describes a Tool-Result Boundary Gate that intercepts tool results before they enter the agent’s planning loop. Detection at that point can identify malicious instructions before they influence another tool call or credential request. The research also describes how subtle indirect instructions can slip through when they lack explicit override language. Detection is therefore a signal layer above structural controls.
A boundary gate and honeypot detectors can provide signals that trigger session termination before a credential-touching call. Their architectural role is to interrupt suspicious behavior within the agent’s existing authority. Isolation remains necessary when detection misses an attack, while detection remains useful when an attack needs no escape from the VM.
Putting the patterns together: a deployment model for agents that need real isolation
The deployment model combines one VM per user, one identity per VM, and one credential scope per session. Firecracker supplies the execution boundary, while egress filtering restricts access to credential endpoints and approved tools. A phantom-token proxy or MCP gateway retains high-value credentials outside the guest. Per-session exchange binds downstream access to its intended audience, and just-in-time retrieval limits the lifetime of credentials that must enter the VM.
Within that boundary, environment variables carry non-sensitive configuration or tightly constrained bootstrap values. Vsock and tmpfs provide a separate delivery path for secrets that must be available locally. A tool-result gate then inspects external content before it can steer another operation. Each layer handles a different way things can go wrong, so a complete credential-security system needs more than one layer.
Persistence also needs to remain distinct from ephemerality. Maritime’s snapshot-restore model preserves VM memory and disk state while allowing idle agents to stop consuming running compute. Preserving memory state is not the same as destroying a tmpfs mount, so sleep cannot be treated as credential disposal. The credential lifecycle must match whether the platform destroys, suspends, or restores the agent’s state.
For developers, this architecture offers a choice of platform primitives without requiring them to implement every layer. The VM host supplies execution isolation, the credential proxy protects privileged material, and the gateway applies identity and policy at tool boundaries. With those responsibilities in place, the agent can retain broad working capabilities without inheriting equally broad credential access. The goal is autonomy inside a narrow authority boundary.


