Repository navigation
Description
Summary
microsandbox blocks a request when all of these conditions are true:
- The request body contains the placeholder of a secret.
- The request goes to a host that is not in the allow-list of that secret.
SecretInjection.bodyisfalse.
SecretInjection.body is false by default. You cannot set it from the msb CLI.
When body is false, microsandbox cannot put the real secret into a request body. Thus the placeholder in the body is only text. It is not a secret. The block does not stop a leak, but it stops the request.
The guest does not get the cause of the block. The guest gets only this error:
curl: (56) ... unexpected eof while reading
The effect is small for a tool that sends one request. The effect is large for an AI agent. An agent sends all of the conversation history in each request. If the history contains the placeholder one time, microsandbox blocks all of the requests after that. The user must start a new session.
Environment
msb0.6.8- Host: Zorin OS 18.1, Linux 7.0.0-28-generic, x86_64
- Guest image: Debian trixie (
ghcr.io/afrossard/container-base:0.0.9-agent) - Guest program: an AI agent CLI that sends requests to
api.anthropic.com
This is the launch command in short form:
msb run --net public \
--secret [email protected],api.github.com \
--on-secret-violation block-and-log \
<image> -- <command>
api.anthropic.com is not in the allow-list of the secret.
How to repeat the problem
Send two requests to the same host. The two requests are the same, but only the second request contains the placeholder in the body.
# A: control. The body does not contain the placeholder.
curl -sS -o /dev/null -w 'http=%{http_code}\n' --max-time 15 \
-X POST -H 'content-type: application/json' \
--data '{"harmless":"text"}' \
https://api.anthropic.com/v1/messages
# B: the same request. The body contains the placeholder.
# In the guest, $GH_TOKEN holds the placeholder, not the secret.
curl -sS -o /dev/null -w 'http=%{http_code}\n' --max-time 15 \
-X POST -H 'content-type: application/json' \
--data "{\"harmless\":\"$GH_TOKEN\"}" \
https://api.anthropic.com/v1/messagesExpected result: microsandbox sends both requests. Body substitution is off. Thus the placeholder is only text, and no secret can go to the host.
Actual result:
--- the guest env holds the placeholder ---
GH_TOKEN=$MSB_GH_TOKEN
--- A: control. The body does not contain the placeholder. ---
http=401
curl_exit=0
--- B: the same request. The body contains the placeholder. ---
http=000
curl_exit=56
curl: (56) OpenSSL SSL_read: OpenSSL/3.5.6: error:0A000126:SSL routines::unexpected eof while reading, errno 0
Request A gets HTTP 401. This is correct, because the request has no API key. It also shows that the connection works.
Request B fails. The body is the only difference between A and B.
This is the host log for request B:
WARN microsandbox_network::secrets::handler: secret violation: placeholder detected for
disallowed host action=block-and-log secret_env_var=GH_TOKEN placeholder=$MSB_GH_TOKEN
protocol=http/1.1 sni=api.anthropic.com host=api.anthropic.com method=POST
path=/v1/messages location=body match_form=raw guest_dst=160.79.104.10:443 http2_stream_id=
The log shows location=body.
Why we think the block is not correct
We read these two files at main (cb7568f690b4):
packages/microsandbox-types/rust/lib/domain.rs:2016.SecretInjection.bodyhas#[serde(default)]. Thus the default value isfalse. Onlyheadersandbasic_autharetrueby default.crates/cli/lib/commands/common.rs. The functionparse_secretgives back only(env_var, hosts). The syntaxENV@HOST[,HOST...]has no field for the injection scopes. Thus a secret from the CLI always usesSecretInjection::default().
So for each secret that you make with the CLI, microsandbox cannot put the secret into a request body. But microsandbox finds the placeholder at location=body and blocks the request.
microsandbox looks for the placeholder in more locations than it can write the secret to. The block does not use this difference.
What we tested and removed as causes
- The network is good. Request A goes to the same host, the same port, and the same TLS session. It gets HTTP 401 immediately.
- DNS and egress are good. A and B run in the same sandbox at the same time. Only the body is different.
- TLS interception and CA trust are good. Request A uses the same interception path.
- The problem is not temporary. We saw it in two different agent sessions, some hours apart. We can also cause it at any time with the two commands above.
- The problem does not correct itself. All retries fail while the placeholder stays in the history. The client of the agent tries 10 times and then stops.
- This is not issue macOS libkrun guest egress fails with curl (56) unexpected eof on a Zscaler force-tunneled host #1344. Issue macOS libkrun guest egress fails with curl (56) unexpected eof on a Zscaler force-tunneled host #1344 has the same
curl (56)error, but the cause is the egress of the host. Here the egress is good, and the body causes the failure.
Effect on users
Usually the user does not type the placeholder. An AI agent reads a file that gives information about the --secret mechanism. For example, the notes of a project. The file content then goes into the conversation history of the agent. The client sends the history in each subsequent request. microsandbox then blocks each of these requests.
The agent looks like it stopped. It retries, it uses all of its retries, and then it shows a connection error. The error points to the network, not to a policy decision.
The guest does not get the deny events (see #691). Thus there is no data in the guest to help you find the cause. We examined this problem as a network fault for a long time before we found the warning on the host.
What we suggest
-
Do not block at a location where the injection is off for that secret. If
injection.bodyisfalse, microsandbox cannot substitute the secret in the body. Thus it is safe to send the request. It is satisfactory to write the event to the log. But it is not necessary to close the connection. -
If you use the same detection for all locations on purpose, let the guest see the cause of the block. At the moment the guest gets only a connection reset. This is related to issue Capture & expose network policy deny events #691.
A related limit in the CLI
ViolationPolicy.passthrough(hosts=[...]) gives the correct policy. It sends the placeholder to the given hosts and keeps block-and-log for the other hosts. The test fixture of the SDK uses api.anthropic.com as its example.
But --on-secret-violation accepts only four words. The word passthrough becomes Passthrough(vec![HostPattern::Any]). This is the all-hosts form. The Rust builder controls this form with passthrough_all_hosts(i_understand_the_risk).
Thus a CLI user has only two choices: block all hosts, or send the placeholder to all hosts. The user cannot set the scoped policy. If you prefer, we can put this in a different issue.
Activity
fix: reword msb secret placeholder out of two committed files (#88)
appcypher commentedon Aug 16, 2026
hey. dug into this some more. the current behavior is intentional. disabling body substitution does not make a secret placeholder inert. we still block it because placeholders can reveal which secrets a workload expects, and request bodies are often logged or retained downstream.
that said, the existing passthrough control is too broad for this use case. i have created a pr #1356 to separate the policies cleanly:
allowcontrols where the real secret may be substitutedsubstitutioncontrols where substitution may occurpassthroughcontrols which hosts may receive the placeholder unchangedso if body substitution is disabled, a placeholder in the body still blocks by default. it only passes through when that destination is explicitly listed under
passthrough.this keeps the secure default while supporting the behavior you need without enabling passthrough globally.
mogul commentedon Aug 18, 2026
@afrossard I am SO GLAD you posted this.
fix: Avoid literal $MSB_ proxy token
fix: Avoid literal $MSB_ proxy token (#324)
fix(sbx): stop the every-attach re-attach heal-loop noise on sbx 0.38 (…
michal-laskowski commentedon Aug 28, 2026
I have a case where
When i don't use --secret in CLI everything is ok
When i got any --secret i get:
feat(secrets): redesign substitution policy (#1356)
afrossard commentedon Aug 30, 2026
thanks a lot @appcypher , I'll check it out.
afrossard commentedon Sep 21, 2026
I verified #1356 against
v0.7.2, released on 2026-09-17.Thanks for the redesign. A
passthroughoption scoped to a single secret is the CLI option we were missing.I reran the repro from this issue in a real guest.
It sends a control request and a request that carries the placeholder.
I used a throwaway placeholder, not a real credential.
passthrough, the control request returns 401 because it reaches the real endpoint with the wrong auth. The placeholder request fails withcurl: (56), an SSL read error, so the default blocks it as intended.passthrough=<host>scoped to one destination, both requests return 401, so the placeholder reaches that host.allownorpassthrough. The sandbox blocked it, as in the first case, sopassthroughdoesn't leak the placeholder to other hosts.--helplists--secret-violation-actionand no longer lists--on-secret-violation, which matches the docs.Two small doc gaps remain.
--helpshows the--secretsyntax only asENV[:OPTIONS]@HOST[,HOST...]and doesn't list the options thatdocs/sandboxes/secrets.mdxdocuments (body,no-headers,no-query,no-body,passthrough=HOST).In
secrets.mdx, one example in the "Let selected hosts receive the placeholder" accordion still uses the old--on-secret-violation block-and-terminatesyntax.I couldn't find a host-side audit line with
location=oraction=for a blocked or passed-through placeholder.I checked the
msb run --debugand--traceoutput and the persisted per-sandbox logs (runtime.log,kernel.log,exec.log).Those logs contain only VM, device-emulation, and CLI orchestration traces.
If the audit line exists, where should we look for it?
If it doesn't exist yet, it may be worth its own issue.
A passing curl doesn't tell you which policy allowed the request, and that auditability was a goal of this redesign.
I didn't reproduce the separate
curl (35)report about self-signed hosts in this thread, and I have no opinion on it.toksdotdev commentedon Sep 22, 2026
i was able to track down the root cause. some nifty edge cases for backward compat weren't handled after the redesign. i should get out a fix for this tomorrow.
docs: keep the msb secret placeholder out of reference docs, template…
docs(cli): list secret options in command help (#1828)
docs(cli): list secret options in command help (superradcompany#1828)
feat(network): return JSON policy denials by default (#1825)
toksdotdev commentedon Oct 12, 2026
thanks for the detailed report and for verifying the passthrough changes.
the remaining fixes are now merged:
--secretoptions in CLI help.these will be available in the next release. placeholders still block by default unless the destination is allowed through scoped passthrough.
we’re tracking audit events separately in #691, so closing this one.