Summary
OpenBMB Internet of Agents has a code injection flaw in the Code Executor Tool's execute_code function, where manipulation of the filename or lang arguments can affect code handling. Because the attack can be initiated remotely, a reachable interface that accepts these arguments may expose the execution environment to attacker-controlled code.
Affected context
The issue is reported in the Code Executor Tool at im_client/agents/tools/code_executor.py in OpenBMB Internet of Agents, through commit 9d78e88e47160eb42ee1ee8538c05e1c2c47877a. It concerns how the filename and lang arguments are handled by execute_code. The project uses continuous delivery with rolling releases, so affected and fixed release boundaries are not specified.
Exploit preconditions
- Attack surface: A remotely reachable path that invokes the Code Executor Tool.
- Required access: The description does not specify whether authentication or other access controls are required.
- Trigger point: Processing of attacker-influenced
filenameorlangarguments byexecute_code. - Why exploitation is possible: Unsafe handling of these arguments can allow input to influence code execution.
Why this happens
The reported flaw is caused by inadequate handling of arguments that influence code execution. This aligns primarily with CWE-94: Improper Control of Generation of Code ('Code Injection'). It is also associated with CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component, reflecting the risk that input is interpreted by a downstream code-processing component rather than treated strictly as data.
Potential impact
- An attacker may be able to execute code in the context of the affected service.
- The service's data or runtime environment could be exposed or modified.
- Compromised execution could potentially be used to access resources available to the service.
General mitigation guidance
Mitigation generally focuses on keeping user-controlled values separate from executable code and restricting the capabilities of code execution features.
- Prefer fixed, allowlisted language identifiers and controlled filename handling over dynamically interpreted values.
- Validate inputs against a strict schema and reject unexpected values before they reach code-generation or execution components.
- Use APIs that pass data as data rather than constructing executable statements or commands from strings.
- Isolate execution in a restricted environment with least-privilege access, limited filesystem and network permissions, and resource controls.
- Apply secure-by-default access controls to remotely reachable execution functionality.
How teams detect issues like this
- Use static analysis to identify user-controlled arguments flowing into code generation, interpreters, or execution APIs.
- Review code paths that process
filenameandlang, including validation order and downstream use. - Monitor invocation logs for unusual argument values, unexpected execution patterns, and access to sensitive resources.
- Enforce policies requiring strict input validation and isolation for code execution features; automated code review tools may help flag risky data flows.

