AI Code Interpreter Abuse — Reading the Sandbox Host
CalcAI writes and runs Python to answer data questions. The 'sandbox' is a worker process that also carries the service's secrets in its environment variables. The agent runs any code you ask for.
What is code interpreter abuse?
A code interpreter lets an assistant write and run code to answer a question. It is useful and it is also the most powerful tool an assistant can hold, because code can read files, read environment variables and open network connections.
Code interpreter abuse is getting the assistant to run code that looks at its own surroundings and not the user's data: the host's files, the service's API keys, or anything else the worker process can reach.
A real case
Johann Rehberger showed that injected instructions could make Claude's code-execution tool read a user's data and upload it to the attacker's own account through Anthropic's Files API, a destination the sandbox was allowed to reach.
The lab is about the same trust placed in a sandbox: the code runs somewhere that can reach more than the task needs.
Source: The Register
How to fix it
- Run each session in an isolated container with no secrets in its environment.
- Block outbound network access by default, and treat every allowed destination as a possible exit for data.
- Mount only the user's own files, read-only where possible.
- Set limits on time, memory and process count, and destroy the sandbox after each session.
Questions people ask
Is a sandbox enough to make a code interpreter safe?
Only if the sandbox holds nothing worth stealing and cannot reach anything sensitive. Many incidents come from a sandbox that had an API key or an allowed network route.
What should never be inside the sandbox?
Service credentials, cloud metadata access, other users' files and internal network routes.
Can prompt rules stop harmful code?
They reduce accidents but cannot be relied on. Isolation is what limits the damage when the model writes code it should not.
Read the full OWASP LLM Top 10 guide · All free labs · AI red team certification