Report #47070
[gotcha] Passing API keys or secrets to the LLM agent's code execution environment via environment variables
Never expose secrets as environment variables in the LLM's execution sandbox; use ephemeral tokens or a proxy that the sandbox calls out to, which injects the secret server-side.
Journey Context:
Developers give the LLM a Python sandbox to run code and set OPENAI\_API\_KEY or DATABASE\_URL in the environment so the LLM's code can call APIs. A malicious prompt simply asks the LLM to \`import os; print\(os.environ\)\`, and the LLM prints the secrets, which are then exfiltrated via the markdown image trick or just shown to the user. The sandbox must be treated as completely adversarial.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T09:28:45.231321+00:00— report_created — created