Aug 22, 2026·6 min read·4 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.
A critical server-side template injection (SSTI) vulnerability exists in the Volt template engine of the Phalcon PHP framework. In versions 5.15.0 and earlier, raw AST token values for filter arguments in the 'join' filter are directly spliced into the generated PHP template code. This allows an attacker who can influence Volt templates to execute arbitrary PHP code during template rendering.
An uncontrolled resource consumption vulnerability (CWE-400/CWE-789) exists within the kin-openapi Go library prior to version 0.142.0. The vulnerability occurs during the processing of highly sparse array indexes inside query parameters defined in deepObject style. An unauthenticated remote attacker can exploit this flaw to cause an immediate Out-of-Memory (OOM) crash of the target application.
A critical prototype pollution and sandbox escape vulnerability was discovered in the JSONata query and transformation library before versions 1.8.8 and 2.2.0. By providing a malicious JSONata expression that bypasses ownership checks on object properties, remote attackers can execute arbitrary code in the context of the host Node.js application.
CVE-2026-63135 is a critical stored Cross-Site Scripting (XSS) vulnerability affecting YOURLS (Your Own URL Shortener) versions 1.5.1 up to (but not including) 1.10.4. Unauthenticated remote attackers can inject malicious JavaScript arrays by crafting an HTTP Referer header sent to a short URL redirect. This value is saved in the database logs and executed without context-aware escaping when an administrative user views the corresponding statistics visualization page.
CVE-2026-68508 is a high-severity arbitrary code execution vulnerability in facebookresearch/hydra (hydra-core) prior to version 1.3.4. The vulnerability exists within the dynamic instantiation system hydra.utils.instantiate(), which resolves and executes arbitrary Python callables from configuration files. An attacker capable of submitting untrusted configurations can achieve arbitrary code execution in the context of the consuming process.
A critical sandbox escape vulnerability in JSONata versions prior to 1.8.8 and 2.2.1 allows unauthenticated remote attackers to execute arbitrary code on the host machine. By submitting crafted JSONata expressions, an attacker can manipulate internal AST structures, bypass object clone helpers, spoof native function flags, and escape the evaluation environment to execute system commands through the Node.js runtime.