Originally published on sandscale.dev.
An agent that deploys code, queries a database or calls an API needs credentials. The usual shortcuts, a .env file in the repo, a key pasted into the prompt, a token in a shell history, put those credentials in places where they get copied. This post walks through how credentials leak in agent runs, what Sandscale's Vault and DLP each do about it, and which paths remain open.
Everything about Sandscale below comes from sandscale.dev as of 20 November 2026. Where the docs are silent, we say so.
How secrets leak in an agent run
Think of the places a credential can end up:
- The prompt. A person pastes a key to help the agent along, or the agent reads a file that contains one and includes it in the next model call. From there it sits in a provider's logs and your own transcripts.
- Tool-call arguments. The agent builds a command or an API call that includes the key inline.
-
Files and the repository. A
.envfile or a config with a token gets committed or copied. - Command output. A tool prints the environment, or a debug log echoes a header. The output returns to the model as context.
- Logs and traces. Your own telemetry records the above.
- Lingering validity. The credential still works long after the run that needed it.
No single control covers all six. Vault addresses the way a secret is delivered and how long it lasts. DLP addresses what leaves in prompts and tool calls. Neither inspects what the agent's own code does inside the box, and the end of this post is about that gap.
Vault: deliver the secret without the model seeing it
Sandscale's Vault works in three steps, as the site describes them:
- Store. You put a secret in Vault once, not in repos, prompts or environment files.
- Inject. It reaches the run in memory, never written to disk.
- End. It stops working when the run, session or lease ends.
A run references a secret and Vault injects it at run time. Vault comes with every plan, Free included.
Giving a sandbox a secret
The step-by-step guide shows the flow. First store the secret in Vault (the guide shows the steps; the value is read without echoing it). Then reference it when you start a sandbox. With the TypeScript SDK:
const box = await sandscale.sandboxes.create({
template: 'builtin:python',
vaultEnv: [{ name: 'DB_PASSWORD', path: 'secret/data/app/db', field: 'password' }],
});
The sandbox gets DB_PASSWORD in its environment. Your code never handles the value. In the docs' words, the path is "the mount, data, then the secret's path".
What the docs say happens to the value:
- Sandscale reads it as you, with your Vault permissions. If you may not read it, the start is refused with
vault_env_refusedand nothing starts. - It goes to the sandbox only. It is never in the API's answer, a log, the run's record or the audit log. The audit entry names the variables, not the values.
- A start can name up to 50 values.
- Build host leases can carry secrets too, and they end with the lease.
What an environment variable does and doesn't protect
The secret reaches the sandbox as an environment variable. That keeps it out of your code, the API answer and the logs. It does not hide it from code running inside the sandbox: any process in the box can read its environment, including a command the agent runs. If the agent runs env or printenv, or a script prints its configuration, the value appears in that command's output.
The agent over MCP
When an agent connects over Sandscale's MCP server, it can list the names of your Vault secrets but cannot read their values. Every call runs as the signed-in person and lands in the audit log with the tool, region, outcome and app, never the arguments. An agent can know that app/db exists and ask for a sandbox that references it, without ever receiving the password.
DLP: scan what leaves
Vault handles the case where you do it right. DLP handles the case where someone does it wrong. Per the DLP page:
- Scan. Each prompt and MCP tool call is checked against built-in patterns and your own.
- Block. A credential or other sensitive value stops the call.
- Record. What was found, and where, goes into the audit log. The value itself does not.
The headline claim on that page is that "a credential pasted into a prompt never reaches the model." It applies on every plan.
Two things worth being straight about. First, pattern matching can only catch what the patterns describe. The docs say checks use "built-in and your own patterns", so a secret in an unusual format, or one an agent has transformed, is outside what a pattern catches until someone adds one. Second, the page describes scanning of prompts and MCP tool calls. It does not say that output coming back from a command is scanned, or that files written to disk are scanned.
Putting the two together
| Leak path | What covers it, per the docs | What is not stated |
|---|---|---|
| Key pasted into a prompt | DLP scan blocks the call | Coverage for unusual formats: only through patterns |
| Key built into a tool call | DLP scans MCP tool calls | Scope beyond MCP tool calls |
Secret in repo or .env
|
Vault: store once, not in repos or environment files | Nothing stops someone writing a secret to a file |
| Secret echoed in command output | Not stated | Whether output is scanned |
| Secret in logs | Vault: values never in logs or run record; audit names variables only | Your own application logs inside the sandbox |
| Credential valid after the run | Vault: "stops working when the run, session or lease ends" | Not stated |
Habits that help, whatever the tooling
- Use short-lived credentials where the system you call supports them. A leaked token that expires within an hour is a smaller problem.
- Scope them narrowly. Give the agent a read-only database role for a read-only task.
- Do not put credentials in prompts. DLP is a safety net, not a plan.
- Review the audit log after the first few runs. It records what DLP found, where, never the value, and the variable names Vault injected.
- Assume anything the agent can read, it can print. Design for that: if a secret must never reach the model, ask whether the agent needs the secret at all, or whether a narrower service call would do.
- Route risky actions through approvals, so a person confirms before an agent uses a credential for something irreversible. See approvals and agent policy.
Where this leaves you
Vault keeps the secret out of your code, the API answer, the logs and the model's context in the normal path. DLP catches the abnormal path, a secret typed or built into a prompt or a tool call. Between them they cover the main leak paths that happen before code runs. They do not turn the agent's own commands into a safe place to hold a secret, so the sandbox boundary, narrow credentials and review still matter. For the isolation side, see our post on isolating agent-run code.
The audit log ties it together: every action is in a hash-chained log that every plan can read. Pricing shows what each plan includes; Vault and DLP are on all of them.
Top comments (0)