Skip to content

fix(sandbox): hide host secrets from sandboxed shell commands - #109

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/high-severity-issues-96b1
Draft

cursor[bot] wants to merge 1 commit into
mainfrom
cursor/high-severity-issues-96b1

Conversation

@cursor

@cursor cursor Bot commented Oct 4, 2026

Copy link
Copy Markdown

Bug and impact

With [sandbox] enabled = true (the example config), sandbox_exec ran sh -c with the agent process environment. Provider keys and channel tokens are loaded from that environment (ANTHROPIC_API_KEY, OPENAI_API_KEY, TAVILY_API_KEY, Telegram and Discord tokens).

printenv is not on the shell blocklist, and Landlock plus the network namespace do not hide environ. A prompt-injected or untrusted channel message that asks the agent to run printenv receives those secrets on the tool stdout, which is then sent back to the model and can be echoed to the chat.

Root cause

sandbox_exec called execl("/bin/sh", "sh", "-c", cmd) without replacing the environment inherited across fork.

Fix

Immediately before execl, the command child replaces its environment. It keeps PATH, LANG, LC_ALL, LC_CTYPE, TERM, and TZ, and sets HOME to the workspace when one is configured. API keys, bot tokens, and LD_* variables are not passed through.

Validation

  • Added test_command_does_not_inherit_host_secrets. It failed on the old binary (printenv printed leaked_via_env) and passes after the fix, including /proc/1/environ.
  • make test_sandbox and make test_shell passed.

Sandbox-off shell execution is unchanged. That path is documented as not a security boundary.

Open in Web聽View Automation聽

The command child inherited the agent environment, so printenv inside
sh -c returned provider API keys and bot tokens on the tool stdout
channel. Replace that environment with PATH, locale, and workspace HOME
before execl.

Co-authored-by: esadrianno <esadrianno@gmail.com>

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant