Skip to content

A placeholder in a request body causes a block, but body substitution is off and you cannot set it from the CLI #1354

Closed

Description

@afrossard

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.body is false.

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

  • msb 0.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/messages

Expected 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.body has #[serde(default)]. Thus the default value is false. Only headers and basic_auth are true by default.
  • crates/cli/lib/commands/common.rs. The function parse_secret gives back only (env_var, hosts). The syntax ENV@HOST[,HOST...] has no field for the injection scopes. Thus a secret from the CLI always uses SecretInjection::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

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

  1. Do not block at a location where the injection is off for that secret. If injection.body is false, 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.

  2. 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

  1. appcypher commented on Aug 16, 2026

    @appcypher
    Member

    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:

    • allow controls where the real secret may be substituted
    • substitution controls where substitution may occur
    • passthrough controls which hosts may receive the placeholder unchanged

    so 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.

  2. added theissue type on Aug 16, 2026
  3. mogul commented on Aug 18, 2026

    @mogul

    @afrossard I am SO GLAD you posted this.

    GIF from the movie Zoolander. Mugatu screams: Doesn't anyone notice this? I feel like I'm taking crazy pills!
  4. michal-laskowski commented on Aug 28, 2026

    @michal-laskowski

    I have a case where

    When i don't use --secret in CLI everything is ok
    When i got any --secret i get:

    *   Trying 192.168.1.5:443...
    * ALPN: curl offers h2,http/1.1
    * TLSv1.3 (OUT), TLS handshake, Client hello (1):
    * SSL Trust Anchors:
    *   CAfile: /etc/ssl/certs/ca-certificates.crt
    *   CApath: /etc/ssl/certs
    * TLSv1.3 (OUT), TLS alert, decode error (562):
    * TLS connect error: error:0A000126:SSL routines::unexpected eof while reading
    * closing connection #0
    curl: (35) TLS connect error: error:0A000126:SSL routines::unexpected eof while reading
    
  5. added a commit that references this issue on Aug 30, 2026
    e448c00
  6. afrossard commented on Aug 30, 2026

    @afrossard
    Author

    thanks a lot @appcypher , I'll check it out.

  7. afrossard commented on Sep 21, 2026

    @afrossard
    Author

    I verified #1356 against v0.7.2, released on 2026-09-17.
    Thanks for the redesign. A passthrough option 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.

    • Without passthrough, the control request returns 401 because it reaches the real endpoint with the wrong auth. The placeholder request fails with curl: (56), an SSL read error, so the default blocks it as intended.
    • With passthrough=<host> scoped to one destination, both requests return 401, so the placeholder reaches that host.
    • I sent the placeholder request to a third host that is in neither allow nor passthrough. The sandbox blocked it, as in the first case, so passthrough doesn't leak the placeholder to other hosts.

    --help lists --secret-violation-action and no longer lists --on-secret-violation, which matches the docs.
    Two small doc gaps remain.
    --help shows the --secret syntax only as ENV[:OPTIONS]@HOST[,HOST...] and doesn't list the options that docs/sandboxes/secrets.mdx documents (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-terminate syntax.

    I couldn't find a host-side audit line with location= or action= for a blocked or passed-through placeholder.
    I checked the msb run --debug and --trace output 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.

  8. toksdotdev commented on Sep 22, 2026

    @toksdotdev
    Member

    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.

  9. toksdotdev commented on Oct 12, 2026

    @toksdotdev
    Member

    thanks for the detailed report and for verifying the passthrough changes.

    the remaining fixes are now merged:

    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.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions