Aug 22, 2026·6 min read·39 visits
Unsafe use of Python's eval() in Xinference's Llama3 tool parser enables unauthenticated remote code execution via prompt injection. Upgrading to version 2.7.0 mitigates this risk by replacing eval() with json.loads() and ast.literal_eval().
CVE-2026-61539 is a critical remote code execution vulnerability in Xinference, an inference API framework for open-source LLMs. In version 2.5.0 and earlier, model-generated outputs representing Llama3 tool calls are passed directly to Python's built-in eval() function inside the parser components. By manipulating conversational input or injecting instructions, an attacker can influence the LLM to output a Python expression containing malicious system commands, resulting in unauthenticated remote code execution on the host. This vulnerability has been resolved in Xinference version 2.7.0.
Xinference is an open-source inference API framework designed for serving Large Language Models (LLMs), speech models, and multimodal models. In deployments running Llama3 models with tool calling enabled, the framework is exposed to a critical security flaw. Specifically, the component parsing model outputs handles tool call data unsafely.
The attack surface is accessible via the standard chat completion endpoints. When client requests prompt the model to invoke tools, the application processes the generated assistant response to extract tool arguments. Because the framework does not sanitize the string generated by the LLM before interpreting it, this architectural pattern creates an indirect pathway for executing operating system commands.
The vulnerability is classified under CWE-95: Improper Neutralization of Directives in Dynamically Evaluated Code. This issue allows unauthenticated remote attackers who can influence the LLM's output—either via direct API access or downstream prompt injection—to achieve code execution within the security context of the Xinference server process.
The root cause of CVE-2026-61539 resides in the dynamic interpretation of structured text using Python's built-in eval() function. When processing Llama3 tool calls, Xinference attempts to parse the text representation of a Python dictionary returned by the model. The application invokes eval(model_output, {}, {}) with the intent of converting the string into a native dictionary object.
While the developers passed empty dictionaries as the globals and locals arguments to restrict execution, this implementation does not establish a secure sandbox in Python. Python's runtime environment allows standard object attributes to be traversed to retrieve the built-in namespace. For example, expressions can utilize property accessors on basic literal objects, such as ().__class__.__bases__[0].__subclasses__(), to locate and invoke dangerous classes like subprocess.Popen or direct file handles.
Since Large Language Models generate text based on input prompts, the string passed to eval() is not entirely under the developer's control. An attacker can craft conversational inputs that influence or override the system instructions of the model. By manipulating the LLM into generating a Python expression containing malicious system calls instead of a valid JSON dictionary, the attacker triggers immediate execution of that payload when the server evaluates the generated string.
The vulnerable logic was present in two locations within the codebase: extract_tool_calls in xinference/model/llm/tool_parsers/llama3_tool_parser.py and _eval_llama3_chat_arguments in xinference/model/llm/utils.py. In both cases, the raw model output was evaluated directly using the native eval() sink.
Below is the vulnerable implementation in llama3_tool_parser.py:
# Vulnerable code pattern
def extract_tool_calls(self, model_output: str):
try:
# DANGEROUS: Executes arbitrary code contained within model_output
data = eval(model_output, {}, {})
return [(None, data["name"], data["parameters"])]
except Exception:
return [(model_output, None, None)]The corresponding patch replaces the dynamic interpreter sink with a secure parsing sequence using json.loads as the primary mechanism, and falling back to ast.literal_eval for Python-specific dictionary literals.
# Patched code implementation
try:
# Try JSON first (most common LLM output format)
data = json.loads(model_output)
except (json.JSONDecodeError, TypeError):
try:
# Fall back to ast.literal_eval for Python literal formats
# Unlike eval(), ast.literal_eval() only parses literal structures
data = ast.literal_eval(model_output)
except (ValueError, SyntaxError):
return [(model_output, None, None)]Using ast.literal_eval secures the application because the Abstract Syntax Tree parser processes only standard Python constants (such as strings, numbers, tuples, lists, dictionaries, booleans, and None). If the input contains a function call, class instantiation, or module import, the parser raises a ValueError immediately instead of compiling and executing the code.
Exploitation of this vulnerability requires the attacker to submit a request to the chat completion API that forces the LLM to output a malicious Python expression. The endpoint /v1/chat/completions must be configured to utilize tools, which registers the Llama3 tool parser as the active parser for the session.
The attacker constructs a system or user message using prompt injection techniques designed to bypass the model's instructions. The objective is to instruct the model to ignore its tool formatting constraints and output a specific Python command string. A conceptual payload instruction might command the model to generate a response like __import__('os').system('id') instead of the expected dictionary.
When the LLM yields the malicious response, the Xinference server intercepts the string and passes it directly to extract_tool_calls. The server then executes the string via eval(). Because the execution occurs under the permissions of the Xinference daemon, this leads to system command execution on the host container or server, facilitating unauthorized access or control.
The security impact of CVE-2026-61539 is categorized as critical, receiving a CVSS v3.1 base score of 10.0. The exploit allows unauthenticated network-based attackers to execute arbitrary system commands, compromising the confidentiality, integrity, and availability of the host operating system.
Because the scope is changed (S:C), an exploit not only compromises the logical environment of the Python application but also allows the attacker to execute commands in the underlying container or host operating system. This capability permits attackers to access sensitive data, including model weights, API keys for upstream services, and database credentials stored on the server.
Furthermore, if the Xinference container is deployed with high privileges or lacks proper network isolation, attackers can leverage the initial foothold to pivot into internal networks, escalate privileges on the host system, or disrupt inference services entirely.
The primary mitigation for this vulnerability is upgrading the Xinference installation to version 2.7.0 or later. This release replaces the vulnerable dynamic evaluation patterns with a safe combination of json.loads and ast.literal_eval, neutralizing the execution path entirely.
If upgrading is not immediately possible, administrators can apply manual modifications to llama3_tool_parser.py and utils.py by replacing the eval() statements with the safe parsing implementation shown in the patch details. Additionally, organizations should implement defense-in-depth measures to limit the potential impact of similar flaws.
API endpoints should be shielded from the open internet using reverse proxies and robust access control policies such as API keys or JWT authentication. Finally, the Xinference service must run under a dedicated, unprivileged operating system user account, and the container should use a read-only root file system with minimal system binaries to limit the impact of arbitrary command execution.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H| Product | Affected Versions | Fixed Version |
|---|---|---|
inference xorbitsai | <= 2.5.0 | 2.7.0 |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-95 |
| Attack Vector | Network |
| CVSS Score | 10.0 |
| Impact | Arbitrary Code Execution |
| Exploit Status | Proof-of-Concept |
| KEV Status | Not Listed |
The product receives input from an upstream component, but does not neutralize or incorrectly neutralizes code syntax elements before treating the input as an executable instruction, enabling an attacker to execute arbitrary code.
CVE-2026-109619 (PHP2Shell) is a critical Use-After-Free vulnerability in the core PHP engine caused by improper global state cleanup during out-of-memory exception handling across persistent worker requests.
In Python virtualenv prior to version 21.14.9, activation script generators and configuration writers use Path.exists() before writing files. Because Path.exists() resolves symbolic links, it returns False for dangling symlinks. Consequently, virtualenv skips unlinking pre-planted symbolic links or hard links, writing data directly to target locations outside the intended virtual environment directory.
A remote code execution vulnerability exists in Microsoft .NET due to untrusted data deserialization within the PresentationCore component. The flaw stems from implicit auto-conversion flags during clipboard data retrieval operations.
An out-of-bounds write vulnerability in Microsoft .NET Framework, .NET runtime, and Visual Studio allows unauthenticated remote attackers to execute arbitrary code via crafted pixel-shader bytecode or auto-converted clipboard payloads.
ASP.NET Core contains a thread deadlock vulnerability (CWE-833) that allows an unauthenticated remote attacker to cause a denial of service over the network by exhausting server thread pool resources.
CVE-2026-70035 is a high-severity Remote Code Execution (RCE) vulnerability in Microsoft .NET Framework, .NET runtime, and Visual Studio caused by improper handling during the deserialization of untrusted data (CWE-502). An unauthenticated attacker can execute arbitrary code within the context of the affected process by delivering a crafted serialized payload.