{"slug": "always-run-llm-code-in-a-sandbox", "title": "Always run LLM code in a Sandbox", "summary": "A blog post urges developers to always execute LLM-generated code inside a sandbox, warning that a popular open-source model could eventually be \"poison pilled\" with a backdoor that exfiltrates credentials from a user's session. The post recommends enabling Claude's `/sandbox` setting via `~/.claude/settings.json` alongside command approval, while noting that many things still run outside that sandbox, and describes using the E2B microVM provider to run generated log-parsing code in a throwaway cloud VM that is terminated after execution. The author argues that with attacks on AI systems growing, secure execution practices should be the default rather than optional.", "body_md": "on\n\n# Always run LLM code in a Sandbox\n\nThe biggest use of AI will be in offensive and defensive attacks. With the explosion of recent attacks secure practices is no longer optional.\n\nOne unlooked vector is that we trust our models way too much ! With the increasing popularity of open source models, it is just a matter of time before a popular open source model is poison pilled. What happens when an LLM *seems* to be useful but also has a backdoor that is exfiltrating crentials from your session ? The result will not be pretty.\n\nGetting into a habit of putting some safeguards while executing LLMs is prudent. Here are some ways to do that.\n\n# Sandboxing in Claude\n\nIf you use claude, a easy way is to sandbox it via the [`/sandbox`](https://code.claude.com/docs/en/settings-reference#sandbox-enabled) command. It runs all bash commands within a sandbox and cannot access directories outside of the current working directory. That along with always [requiring approval](https://code.claude.com/docs/en/permissions) for commands provides some layer of protection.\n\nBetter still, add it to your `~/.claude/settings.json` file, so it happens by default:\n\n```\n    \"sandbox\": {\n        \"enabled\": true\n    }\n```\n\nNOTE: This is not foolproof sandboxing. There are [many things](https://code.claude.com/docs/en/sandboxing#what-runs-outside-the-sandbox) that still run outside the sandbox.\n\n# Sandboxing via a microVM\n\nA much betterway would be to always run LLM generated code inside a microVM. These are use and throw and would never touch your localdev. e.g. lets say you want to write code to parse some log files and generate stats for the amount of data parsed, number of errors, info, debug lines etc. I used a microVM provider called [E2B](https://e2b.dev) to run it and provide me the result:\n\n```\npip3 install e2b anthropic\nexport E2B_API_KEY=...  ANTHROPIC_API_KEY=...\npython e2b_log_parser.py messy_app.log answer_key.json\n```\n\n`The actual code is not important here. Just ask your LLM to generate similar sample code.`\n\nThe python code essentialy used the e2b sdk, fired up a microVM in the cloud, generated code, executed it, did this in a loop until it got it right, then terminated the microVM. All without running anything on my local environment.\n\nThere are many other ways to leverage microVMs and I would encourage everyone to start looking at such security practices by default.\n\nIt’s ok to be paranoid !", "url": "https://wpnews.pro/news/always-run-llm-code-in-a-sandbox", "canonical_source": "https://jimmyislive.dev/posts/llm-sandbox/", "published_at": "2026-12-05 00:00:00+00:00", "updated_at": "2026-12-06 06:16:04.781260+00:00", "lang": "en", "topics": ["ai-safety", "ai-agents", "ai-tools", "developer-tools"], "entities": ["Claude", "E2B", "Anthropic"], "also_reported_by": [], "takeaway": "Run LLM-generated code in a throwaway microVM (the post uses E2B) or enable Claude's sandbox setting in ~/.claude/settings.json with command approval, since Claude's sandbox still leaves many operations running outside it.", "recommendation": {"advice": "Execute LLM-generated code in a disposable microVM or Claude's sandbox rather than your local environment, and require approval for commands, because a poisoned model could exfiltrate session credentials.", "playbook": "agent-security", "playbook_url": "https://wpnews.pro/playbooks/agent-security"}, "alternates": {"html": "https://wpnews.pro/news/always-run-llm-code-in-a-sandbox", "markdown": "https://wpnews.pro/news/always-run-llm-code-in-a-sandbox.md", "text": "https://wpnews.pro/news/always-run-llm-code-in-a-sandbox.txt", "jsonld": "https://wpnews.pro/news/always-run-llm-code-in-a-sandbox.jsonld"}}