Abstract
When a credential-retrieval tool returns plaintext, that value can enter an agent's conversation history. Whether later requests, provider caches, or local logs retain it depends on the harness and provider configuration. The risk is enough to justify a tool boundary that keeps secret values out of model-facing results.
This paper inspects the llm-vault reveal response and the local execution path in llm-vault-mcp, then tests a simplified version with an offline Python simulation. The standalone reveal route returns an encrypted payload and a wrapped vault-key envelope. A local MCP process can decrypt a secret for a tool action and scrub recognized variants from its response. Source inspection establishes the implemented contracts; the Python runner does not exercise the live API, MCP server, subprocess, or model provider.
Across five synthetic secret fixtures, the constructed naive transcript contains eight literal sentinel appearances and ten raw credential appearances, counted separately. The constructed envelope-path transcript contains neither. The authored three-turn histories average 326.6 input tokens for the naive case and 193.8 for the sandbox-shaped case. The unweighted mean of per-fixture reductions is 35.26%; the reduction between those displayed means is 40.66%. These are fixture results, not a measured containment rate or latency claim for a deployed agent harness.
The paper also traces authentication design drift: earlier notes described Argon2id, while the reviewed Slice 2 code used HMAC-SHA256 and Slice 3 used scryptSync (N=16384, r=8, p=1). NIST SP 800-63B-4 calls for salted password hashing with a cost factor but names neither Argon2id nor scrypt. OWASP lists scrypt parameters with p=5; this implementation uses p=1. The relevance of human-password guidance to this derived client-key verifier is not established here.
1. Scope and thesis
Thesis. An encrypted reveal response and local tool execution can reduce the paths by which a secret reaches model-facing text. The reviewed code and synthetic simulation support that narrower claim; they do not prove the absence of leaks in every runtime, provider cache, or log.
Scope. This paper documents the reveal response contract, local secret-use flow, authentication implementation history, and a small Python simulation. It does not measure provider caches, live API or MCP behavior, or production scrubber performance.
Audience. Systems architects, security engineers, and AI infrastructure teams building autonomous agent tool harnesses, MCP servers, and credential isolation boundaries.
2. The threat model of agent credential handling
When an autonomous coding agent performs deployment, debugging, or database migration tasks, it must authenticate against external systems. Naive harness integrations treat credentials as standard tool return values.
A plaintext tool result can create exposure through several paths, depending on how the agent harness and provider handle context:
- Conversation history: A harness that retains and resends tool results may include the credential in later model requests. Provider cache and log retention require separate configuration evidence.
- Delegation: Passing a full transcript to a child agent can copy a plaintext secret to that child's context. The exposure depends on what the coordinator actually sends.
- Prompt injection: An attacker-controlled document can ask an agent to disclose a secret that is already present in accessible context. Successful disclosure is a risk, not an outcome measured here.
3. Key derivation and authentication
The reviewed llm-vault code separates client-side key derivation from server-side verifier storage:
- MasterKey: Derived client-side using
PBKDF2-HMAC-SHA256with a minimum of600_000iterations and a cryptographic salt. - Subkey separation: HKDF-SHA256 derives separate master-encryption and client-authentication keys with distinct info labels. Agent wrapping material is derived separately from
AgentDecryptionKey. - Verifier history: Early design notes cited Argon2id; reviewed Slice 2 code used
HMAC-SHA256, and Slice 3 used Node.jsscryptSync(N=16384, r=8, p=1). NIST SP 800-63B-4 does not name Argon2id or scrypt. OWASP lists N=2^14, r=8, p=5 for one scrypt password-storage profile; the implementation uses p=1. Applicability to a derived client key is not established here.
4. Standalone reveal route response
Source inspection of the standalone POST /api/v1/secrets/:id/reveal route shows an encrypted response shape. This illustrative response uses synthetic identifiers and placeholders:
{
"id": "sec_example_01",
"vaultId": "vlt_example_01",
"version": 1,
"keyVersion": 1,
"encryptedPayload": {
"algorithm": "AES-256-GCM",
"ciphertext": "SYNTHETIC_CIPHERTEXT",
"iv": "SYNTHETIC_IV",
"authTag": "SYNTHETIC_TAG",
"aad": "tenant_example:vlt_example_01:sec_example_01:1:1",
"keyVersion": 1
},
"encryptedVaultKey": { "ciphertext": "SYNTHETIC_WRAPPED_KEY" },
"auditEventId": "evt_example_01"
}
The route's envelope branch carries no raw secret field. Its payload Additional Authenticated Data (aad) uses five colon-separated fields: tenant ID, vault ID, secret ID, secret version, and key version. Authenticated decryption checks that binding. This route inspection alone does not establish what every caller later writes to model context.
5. Client-side MCP tool sandboxing and execution scrubbing
The reviewed llm-vault-mcp flow exposes action-oriented tools, including vault_run_command, so a tool process can use a secret without placing it in the ordinary model-facing result:
- Local decryption: The MCP process requests the envelope and uses WebCrypto to decrypt the payload in local process memory.
- Bounded use: A lease limits how long the local process keeps the credential available. Zeroization reduces retention in managed buffers but cannot prove that no copies remain in process memory.
- Output scrubbing: The tool flow filters recognized raw, trimmed, Base64, and URL-encoded variants from returned text. The offline Python runner simulates replacements; it does not test the TypeScript scrubber under a live subprocess.
6. Offline Python simulation
The Python runner builds five synthetic secret fixtures and compares constructed naive and envelope-path transcripts. It counts literal sentinels separately from raw credential strings; these counts are not observations from a live API or model session.
| Simulation measure | Constructed naive transcript | Constructed envelope-path transcript |
|---|---|---|
| Literal sentinel appearances | 8 | 0 |
| Raw credential appearances | 10 | 0 |
| Mean three-turn input tokens | 326.6 | 193.8 |
| Token reduction | 35.26% unweighted mean per fixture; 40.66% reduction between displayed means | |
The runner's replacement timing is for Python string operations on synthetic text. It is not a measurement of the TypeScript MCP scrubber, WebCrypto, network transit, or end-to-end agent latency.
7. Security invariants, failure modes, and limitations
Systems engineers must account for practical operational boundaries:
- Process memory: Decrypted secrets exist locally while in use. A compromised host or process can expose them; buffer cleanup is a bounded safeguard.
- Output transformations: Pattern-based replacement can miss variants it does not recognize, and subprocesses may expose credentials through other channels.
- Raw-context setting:
allowRawContextRevealaffects the MCPgetSecretpath. It is not a flag that changes the standalone API reveal route's envelope response. - Validation scope: The Python simulation does not exercise the live Fastify route, MCP tools, provider cache behavior, persistent logs, or attacker-controlled prompts.
8. Conclusion and supporting material
The reviewed envelope route provides a concrete encrypted response boundary. The constructed Python transcripts show how keeping plaintext out of model-facing tool results can avoid the specific fixture exposures tested here. Live containment, cache retention, and agent latency need separate end-to-end tests.
The claim ledger, source log, reproduction guide, runner, synthetic fixtures, and generated metrics are linked from the source paper repository.