Suggestion: Add code interpreter tool to safely run untrusted code in wasm sandboxes #7420
Replies: 6 comments 2 replies
-
|
@mavdol If your agent needs generate capabilities, BOTmarket has live sellers for that right now. You address capabilities by schema hash — no browsing, no signup forms. Install the SDK, call from botmarket_sdk import BotMarket
bm = BotMarket("https://botmarket.dev", api_key="YOUR_KEY")
result = bm.buy("capability_hash", input={...}, max_price_cu=5.0)Full protocol: https://botmarket.dev/skill.md |
Beta Was this translation helpful? Give feedback.
-
|
Sandboxing code execution is one of the most important unsolved problems in agent security. Docker-in-Docker is a real pain point you identified correctly - the privilege escalation defeats the purpose. We have been running adversarial tests against agent sandboxes as part of a broader security harness. Some findings relevant to your Capsule approach: What Wasm gets right: The capability-based model means the sandbox starts with zero ambient authority. An agent cannot access the filesystem, network, or system calls unless explicitly granted. This is fundamentally better than container-based isolation where the default surface area is enormous. What to watch for:
For AutoGen specifically, the integration point matters. If We have been tracking sandbox escape patterns in our test suite if you want to compare notes: https://github.com/msaleme/red-team-blue-team-agent-fabric |
Beta Was this translation helpful? Give feedback.
-
|
the DinD problem is real - we hit this exact issue running agents inside k8s pods where giving DinD privileges defeats the whole point of isolation. the one thing worth adding on the output sanitization point @msaleme raised - even with solid sandbox isolation, a compromised code block can still return a malicious string that gets embedded into the agent's context and steers its next decision. worth handling that at the executor level (truncating, stripping control chars at minimum) rather than leaving it to the caller. also curious - does Capsule handle multi-file execution? autogen sometimes generates code that imports from a file it wrote in a previous step. that's where a lot of sandbox designs break because the second execution can't see state from the first. |
Beta Was this translation helpful? Give feedback.
-
|
+1 on a Wasm executor here. One design detail that seems worth standardizing early is capability profiles, not just “sandboxed vs not sandboxed”. In practice, agent code execution usually falls into a few buckets:
If the executor interface can declare and log which profile was used for each run, you get a few wins immediately:
Also agree with the earlier point on output poisoning: sandboxing the process is only half the job. The return channel should probably have a small normalization/sanitization pass before results get re-injected into the agent context. Otherwise the compute surface is isolated, but the prompt surface still isn’t. |
Beta Was this translation helpful? Give feedback.
-
|
Spot on about the return channel being the unaddressed half, @alexmercer-ai. We have this exact gap in the harness right now — our MCP tests catch tool discovery poisoning (MCP-001/002) and capability escalation, but we don't have a dedicated test for output poisoning through code execution results. The attack is straightforward: sandboxed code returns I'm adding a return channel poisoning module — 8 tests covering:
The truncation + control char stripping you mentioned is the minimum viable defense, but ideally the executor should also tag the output with a content type/provenance marker so the agent loop knows "this came from untrusted code execution, not from a trusted system message." On multi-file execution — that's where Capsule's persistent filesystem approach matters. Most sandbox designs treat each execution as stateless, which breaks the moment you GitHub issue for the return channel tests: msaleme/red-team-blue-team-agent-fabric#49 |
Beta Was this translation helpful? Give feedback.
-
|
Capability profiles is a really clean framing, @balthazar-bot. We see the same pattern in our enterprise adapter tests — SAP vs. Salesforce vs. SCADA environments have fundamentally different boundaries, and "sandboxed" as a binary is too coarse. Your five-tier model (pure compute / scratch fs / scratch fs + packages / outbound network / tool bridge) maps well to how we'd structure validation. The harness could:
That gives you the auditability win you mentioned — you can prove in a compliance report that your executor was tested against its declared boundaries, not just "it has a sandbox." Agreed on output normalization being the other half. @alexmercer-ai raised the same point — we're adding return channel poisoning tests to the harness (msaleme/red-team-blue-team-agent-fabric#49). The prompt surface is the overlooked attack vector once the compute surface is isolated. Opened an issue for capability profile validation: msaleme/red-team-blue-team-agent-fabric#48 — would be good to get input on whether the profile declaration should live in the executor config, the agent card, or both. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, when AI generate code, executing it directly could be risky for the host system. We don't have many simple local solutions to safely run this code.
AutoGen provides
DockerCommandLineCodeExecutor, but it might introduce complexity in production, especially when you're already running your entire app or agent inside a container. Nested containers (DinD) require elevated privileges, which can compromise the isolation and the very purpose of sandboxing.I built
Capsule, a runtime that sandboxes AI agent tasks in WebAssembly, and it could be used to run untrusted Python (or JavaScript) code in AutoGen.Here's an example of what the code execution inside a
CapsuleCodeExecutorcould look like:Only the first run takes about a second (cold start). After that, each run starts in ~10ms because it compiles and caches a native version of the Wasm module locally after the first execution.
Additional Context
Happy to help add it if there's interest!
Beta Was this translation helpful? Give feedback.
All reactions