{"schema":"threatline.record/2","record":{"id":"CVE-2026-61539","aliases":["GHSA-x2rj-828p-hx9m","PYSEC-2026-3946"],"summary":"Xinference vulnerable to remote code execution via unsafe `eval()` in Llama3 tool-call parsing","details":"### Summary\n\nXinference used Python's unsafe `eval()` function when parsing Llama3 tool-call output generated by a large language model. Because the model output can be influenced by attacker-controlled prompts sent to the chat completion API, a remote attacker can craft prompts that cause the model to return a Python expression. Xinference then evaluates that expression on the server while post-processing the tool-call result. In the tested default deployment, authentication was not enabled, so the vulnerability was exploitable by an unauthenticated remote attacker through the `/v1/chat/completions` endpoint.\n\n### Details\n\nUsers can interact with deployed models through Xinference's OpenAI-compatible `/v1/chat/completions` API. The request entry point is implemented in `xinference/api/restful_api.py`; non-streaming requests call the model instance's `chat()` method and return the inference result.\n\nWhen the Transformers backend is used, inference results flow through the batching logic in `xinference/model/llm/transformers/core.py`. Non-streaming chat results are handled by `handle_chat_result_non_streaming()`. If the request contains a `tools` field, Xinference calls `_post_process_completion()` to parse tool-call output from the model response.\n\nThe Llama3 tool-call parser is implemented in `xinference/model/llm/tool_parsers/llama3_tool_parser.py`. In affected versions, `extract_tool_calls()` parsed model output with `eval()`:\n\n```python\ndef extract_tool_calls(\n    self, model_output: str\n) -> List[Tuple[Optional[str], Optional[str], Optional[Dict[str, Any]]]]:\n    try:\n        data = eval(model_output, {}, {})\n        return [(None, data[\"name\"], data[\"parameters\"])]\n    except Exception:\n        return [(model_output, None, None)]\n```\n\nThe intended behavior was to convert a Python dictionary-like string generated by the model into a dictionary object. However, `eval()` executes the input as a Python expression, and `eval(model_output, {}, {})` is not a security sandbox. If an attacker can influence the model output through prompt injection or direct chat input, the attacker can cause the model to return an expression such as:\n\n```python\n__import__('os').system('touch /tmp/hacked')\n```\n\nWhen the expression reaches `eval()`, it is executed in the Xinference server process context. The harmless `touch /tmp/hacked` command can be replaced with other payloads, such as a reverse shell, malware download, sensitive file read, or lateral-movement payload.\n\n### Score\n\nSeverity: Critical\n\nCVSS v3.1: 10.0\n\nVector: `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H`\n\nRationale:\n\n- AV:N: the vulnerable API is remotely reachable over the network;\n- AC:L: exploitation only requires a crafted chat-completion request and tool-call parameter;\n- PR:N: the tested default configuration did not require authentication;\n- UI:N: no user interaction is required;\n- S:C: command execution can affect resources beyond the Xinference application boundary;\n- C:H/I:H/A:H: remote code execution can fully compromise confidentiality, integrity, and availability.\n\n### Credit\n\nThis vulnerability was discovered by:\n\n- XlabAI Team of Tencent Xuanwu Lab (xlabai@tencent.com)\n- Atuin Automated Vulnerability Discovery Engine\n- Guannan Wang (wgnbuaa@gmail.com), Zhanpeng Liu (pkugenuine@gmail.com), Guancheng Li (lgcpku@gmail.com)","categories":["Libraries & packages"],"product":"xinference","vendor":"xorbitsai","ecosystem":"pip","affected_ranges":[{"source":"GitHub Advisory Database","source_url":"https://github.com/advisories/GHSA-x2rj-828p-hx9m","source_modified_at":"2026-10-08T13:44:24Z","fetched_at":"2026-10-23T18:42:43.628194Z","package":{"ecosystem":"pip","name":"xinference"},"range":"<= 2.5.0"},{"source":"CVE List","source_url":"https://www.cve.org/CVERecord?id=CVE-2026-61539","source_modified_at":"2026-08-24T19:45:13.875Z","fetched_at":"2026-10-23T18:45:31.882637Z","product":"inference","vendor":"xorbitsai","versions":[{"version":"< 2.7.0","status":"affected"}],"defaultStatus":null},{"source":"OSV","source_url":"https://osv.dev/vulnerability/GHSA-x2rj-828p-hx9m","source_modified_at":"2026-09-10T12:25:27.471125692Z","fetched_at":"2026-10-23T18:42:43.628194Z","package":{"ecosystem":"PyPI","name":"xinference","purl":"pkg:pypi/xinference"},"ranges":[{"events":[{"introduced":"0"},{"fixed":"2.7.0"}],"type":"ECOSYSTEM"}],"versions":["0.0.0","0.0.1","0.0.2","0.0.3","0.0.4","0.0.5","0.0.6","0.1.0","0.1.1","0.1.2","0.1.3","0.10.0","0.10.1","0.10.2","0.10.2.post1","0.10.3","0.11.0","0.11.1","0.11.2","0.11.2.post1","0.11.3","0.12.0","0.12.1","0.12.2","0.12.2.post1","0.12.3","0.13.0","0.13.1","0.13.2","0.13.3","0.13.4","0.14.0","0.14.0.post1","0.14.1","0.14.1.post1","0.14.2","0.14.3","0.14.4","0.14.4.post1","0.15.0","0.15.1","0.15.2","0.15.3","0.15.4","0.16.0","0.16.1","0.16.2","0.16.3","0.2.0","0.2.1"]}],"fixed_versions":[{"source":"GitHub Advisory Database","source_url":"https://github.com/advisories/GHSA-x2rj-828p-hx9m","source_modified_at":"2026-10-08T13:44:24Z","fetched_at":"2026-10-23T18:42:43.628194Z","package":{"ecosystem":"pip","name":"xinference"},"version":"2.7.0"},{"source":"OSV","source_url":"https://osv.dev/vulnerability/GHSA-x2rj-828p-hx9m","source_modified_at":"2026-09-10T12:25:27.471125692Z","fetched_at":"2026-10-23T18:42:43.628194Z","package":{"ecosystem":"PyPI","name":"xinference","purl":"pkg:pypi/xinference"},"version":"2.7.0"}],"cvss":10,"severity":"Critical","kev":{"listed":false},"epss":{"probability":0.01226,"percentile":0.68624,"score_date":"2026-10-23"},"published_at":"2026-08-21T20:37:02.633Z","modified_at":"2026-10-08T13:44:24Z","provenance":[{"source":"GitHub Advisory Database","url":"https://github.com/advisories/GHSA-x2rj-828p-hx9m","fetched_at":"2026-10-23T18:42:43.628194Z","source_modified_at":"2026-10-08T13:44:24Z"},{"source":"CVE List","url":"https://www.cve.org/CVERecord?id=CVE-2026-61539","fetched_at":"2026-10-23T18:45:31.882637Z","source_modified_at":"2026-08-24T19:45:13.875Z"},{"source":"OSV","url":"https://osv.dev/vulnerability/GHSA-x2rj-828p-hx9m","fetched_at":"2026-10-23T18:42:43.628194Z","source_modified_at":"2026-09-10T12:25:27.471125692Z"},{"source":"EPSS","url":"https://api.first.org/data/v1/epss?cve=CVE-2026-61539","fetched_at":"2026-10-23T18:42:43.628194Z","source_modified_at":"2026-10-23"}],"sources":["GitHub Advisory Database","CVE List","OSV","EPSS"],"references":[{"source":"CVE List","url":"https://github.com/xorbitsai/inference/security/advisories/GHSA-x2rj-828p-hx9m","tags":["x_refsource_CONFIRM"]},{"source":"CVE List","url":"https://github.com/xorbitsai/inference/pull/4786","tags":["x_refsource_MISC"]},{"source":"CVE List","url":"https://github.com/xorbitsai/inference/commit/1b3d220f342ce68d34cec4586d9409d457dadc42","tags":["x_refsource_MISC"]},{"source":"CVE List","url":"https://github.com/xorbitsai/inference/releases/tag/v2.7.0","tags":["x_refsource_MISC"]},{"url":"https://github.com/advisories/GHSA-x2rj-828p-hx9m","source":"GitHub Advisory Database"}],"locations":[],"motoko_assessment":{"status":"requires_architecture_review","automatic_remediation":false},"cve_state":"PUBLISHED","ssvc":{"exploitation":"none","automatable":"yes","technical_impact":"total","assessed_at":"2026-08-24T19:45:03.839039Z"},"classification":{"method":"product-first software-layer rules","rules_version":"2.1","matched_on":"ecosystem","confidence":"heuristic","reviewed":false},"change_timestamp":"2026-10-08T13:44:24Z","content_hash":"196dee903d06ca3f56e6fa7a3d2dc744c0a5f81a397dd2c69c49199b43d02aed"}}
