/

CVE-2026-61539

Severity:

CRITICAL RISK

(10.0)

Code Injection (CWE-95) in Xinference LLM Tool Parser

CVE-2026-61539

Deferred

Vulnerability type

Category:

Code Injection

CWE:

CWE-95

Impact:

Unauthenticated Remote Code Execution

Severity:

CRITICAL RISK

(10.0)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A critical code injection vulnerability in Xinference allows attacker-influenced Llama3 tool-call output to be evaluated as Python code. An unauthenticated remote attacker may craft a prompt that causes the model-generated expression to execute commands in the Xinference server process context when tool-enabled chat requests are processed.

Affected context

The vulnerability occurs in Xinference deployments that expose the chat completions API with tool-calling support enabled and use the affected Llama3 tool-output processing path. Risk arises when model-generated tool-call arguments are treated as executable Python expressions during non-streaming or post-processed completion handling, rather than being parsed strictly as data.

Exploit preconditions

  • Attack surface: The remotely accessible /v1/chat/completions API
  • Required access: No authentication may be required when the endpoint is exposed without access controls
  • Trigger point: Processing a tool-enabled chat completion and extracting Llama3 tool calls
  • Attacker influence: A crafted prompt can influence model-generated tool-call output
  • Why exploitation is possible: The resulting expression is passed to Python eval() without sufficiently restricting its contents or execution behavior

Why this happens

The underlying flaw is the use of dynamic Python evaluation on data derived from model output. In the affected tool parser and completion-processing paths, an attacker can influence a generated expression that is subsequently evaluated as executable code. This behavior maps to CWE-95: Improper Neutralization of Directives in Dynamically Evaluated Code, because input that should remain data is interpreted as Python instructions.

Potential impact

  • An attacker may execute arbitrary commands in the Xinference server process context
  • The attacker could access or alter data available to that process
  • The affected service may be used to compromise connected model, storage, or network resources
  • Service availability could be disrupted through unauthorized process activity
  • Credentials or secrets accessible to the service may be exposed

General mitigation guidance

Mitigation generally focuses on eliminating dynamic evaluation of model- or user-influenced content.

Common defensive patterns include:

  • Replacing eval() with strict, data-only parsing and explicit schema validation
  • Allowing only predefined tool names, argument types, and structured values
  • Treating model output as untrusted input regardless of the model's source or deployment
  • Applying authentication, authorization, rate limits, and network restrictions to inference endpoints
  • Running inference workers with least privilege and limiting filesystem, credential, and network access
  • Separating model-serving processes from sensitive control-plane resources

How teams detect issues like this

Detection programs commonly look for:

  • Static-analysis findings involving eval(), dynamic execution, or equivalent interpreter APIs
  • Data-flow paths from HTTP request content or model output into evaluation functions
  • Code-review signals where tool-call arguments are converted into executable expressions
  • Tests that submit adversarial or unexpected tool-call structures and verify that they remain inert data
  • API policy checks confirming that tool-enabled inference endpoints require appropriate authentication and authorization

Automated code-review and software-composition tools may help identify dynamic execution patterns, but findings should be validated against the complete request-to-parser data flow.

Sources

SourceLink
github.comgithub.com/xorbitsai/inference/commit/1b3d220f342ce68d34cec4586d9409d457dadc42
github.comgithub.com/xorbitsai/inference/pull/4786
github.comgithub.com/xorbitsai/inference/releases/tag/v2.7.0
github.comgithub.com/xorbitsai/inference/security/advisories/GHSA-x2rj-828p-hx9m

Frequently asked

questions

Yes, when an attacker can reach the affected chat completions endpoint and tool-enabled processing is available. The described condition does not require local file access or shell access before exploitation.

Not necessarily. An unauthenticated attacker may exploit the issue when the inference API is exposed without effective authentication or authorization controls.

The safest pattern is to remove dynamic evaluation from the tool-call pipeline and parse model output as strictly validated data using an allowlisted schema.

Treat all model-generated content as untrusted, prohibit interpreter evaluation of generated strings, enforce endpoint access controls, and run inference services with minimal privileges.

Find out what's already
exploitable in your codebase.