# CVE-2026-76841: Xinference through 2.11.0 Remote Code Execution via Hardcoded trust_remote_code in Model Loaders

The Markdown version of <https://upatch.dev/cve/CVE-2026-76841>. Last updated 25 Nov 2026.

## At a glance

CVE-2026-76841 is rated High 8.7 (CVSS 4.0, CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X). It affects Xinference (xorbitsai) and was published on 24 Aug 2026. It is not in CISA's Known Exploited Vulnerabilities catalog. Its EPSS score is 1.0%: the estimated chance it is exploited in the next 30 days, as of 24 Nov 2026. The upatch `cve-2026-76841-xinference-block` mitigates it, and is vetted (merged into the registry).

A upatch is a signed BPF program that shirudo loads into a running Linux kernel to block the code path this CVE's exploit takes. It holds the line until the fix ships; it does not replace patching.

## The vulnerability

CVE-2026-76841 was published on 24 August 2026. Before version 2.12.0, Xinference (`xorbitsai/inference`) passes `trust_remote_code=True` unconditionally across six model loader call sites (`RerankModel._get_tokenizer` in `xinference/model/rerank/core.py`, `SentenceTransformerRerankModel.load` in `xinference/model/rerank/sentence_transformers/core.py`, `SentenceTransformerEmbeddingModel.load` in `xinference/model/embedding/sentence_transformers/core.py`, `FlagEmbeddingModel.load` in `xinference/model/embedding/flag/core.py`, and `PytorchModel._sanitize_model_config` and `PytorchModel._get_components` in `xinference/model/llm/transformers/core.py`) without offering a setting to disable it. A caller who registers and launches a custom model whose `tokenizer_config.json` or `config.json` contains an `auto_map` entry causes `transformers` to stage and import a Python file from the model directory through `transformers_modules`, running arbitrary Python code in the Xinference worker process.

### Official description

Xinference loads models with Hugging Face remote code execution unconditionally enabled, and before version 2.12.0 exposes no setting to disable it. Six loader call sites pass trust_remote_code=True as a literal or as an unconditional default: RerankModel.\_get_tokenizer in xinference/model/rerank/core.py, SentenceTransformerRerankModel.load in xinference/model/rerank/sentence_transformers/core.py, SentenceTransformerEmbeddingModel.load in xinference/model/embedding/sentence_transformers/core.py, FlagEmbeddingModel.load in xinference/model/embedding/flag/core.py, and two sites in xinference/model/llm/transformers/core.py where PytorchModel.\_sanitize_model_config and PytorchModel.\_get_components default the value to True. Because a caller with model launch access can register a model whose type is unknown and supply an arbitrary model path, the server reaches \_auto_detect_type and then AutoTokenizer.from_pretrained, which imports and executes Python declared by the model directory's own tokenizer_config.json auto_map, running attacker-supplied code with the privileges of the worker process. Version 2.12.0 gates every site behind allow_trust_remote_code and the XINFERENCE_TRUST_REMOTE_CODE setting, permitting remote code only for bundled built-in models.

## What the upatch does

Two BPF LSM programs return `-EPERM` to processes whose executable name starts with `python` when operating under a `transformers_modules` directory:

| Hook               | Refused                                                                                   |
| ------------------ | ----------------------------------------------------------------------------------------- |
| `lsm/inode_create` | Creating a `.py` file inside `transformers_modules` or up to five subdirectories below it |
| `lsm/file_open`    | Opening a `.py` file inside `transformers_modules` or up to five subdirectories below it  |

When `trust_remote_code=True` resolves an `auto_map` reference, `transformers` creates package directories and copies the target `.py` module under `HF_MODULES_CACHE/transformers_modules/` before importing it. Refusing `.py` creation and open under `transformers_modules` aborts dynamic module loading with `EPERM` before Python executes the module, including modules cached before the upatch was loaded. Each program checks the `.py` suffix first and returns immediately for all other files.

The `refused` per-CPU array counts refusals: key 0 for creates, key 1 for opens.

The policy: [`cve-2026-76841-xinference-block.bpf.c`](https://github.com/copper-helm/upatch-registry/tree/main/upatches/cve-2026-76841), 132 lines of BPF C attached at `lsm/inode_create` and `lsm/file_open`, licensed GPL-2.0 OR BSD-2-Clause.

## Side effects

- Any Python process on the machine that attempts to load a Hugging Face model or tokenizer requiring custom `auto_map` code from `transformers_modules` fails with `PermissionError`.
- Models and tokenizers implemented by built-in `transformers` classes (which do not stage `.py` files into `transformers_modules`) continue to load and run normally.

## Preemption model and cost

The programs keep no state beyond the per-CPU refusal counter updated with `__sync_fetch_and_add`, making them safe under all preemption models including preemptible RCU and `PREEMPT_LAZY`. Every file create or open that does not end in `.py` exits after reading the three-byte suffix of the target dentry name.

## Affected versions

Xinference versions before 2.12.0 (including 2.11.0) are affected; version 2.12.0 gates remote code execution behind `XINFERENCE_TRUST_REMOTE_CODE`.

The BPF program uses the four-argument `inode_create` LSM hook prototype (`idmap`, `dir`, `dentry`, `mode`) and `file_open`.

## How it was tested

On Xinference 2.11.0, the loaded upatch refused staging dynamic Python modules under transformers_modules when launching a custom rerank model with auto_map, while before and after loading Xinference staged probe_tokenizer.py.

- **Tested:** 25 Nov 2026
- **Target:** Xinference 2.11.0 on Python 3.12 with sentence-transformers and transformers, listening on 127.0.0.1:9997
- **Kernel:** 7.4-shirudo-ci-20261123
- **Architecture:** x86_64

### Results

| State           | Xinference stages probe_tokenizer.py under transformers_modules |
| --------------- | --------------------------------------------------------------- |
| Before loading  | reached                                                         |
| Upatch loaded   | blocked (EPERM)                                                 |
| After unloading | reached                                                         |

## How to apply

Build the upatch from source, sign it with your own shirudo key, and publish it to your own OCI registry. Machines that follow your upatch tree load it within about a minute.

Build and sign:

```sh
git clone https://github.com/copper-helm/upatch-registry
cd upatch-registry
tools/build <shirudo-checkout> <keys-dir> 1.0.0 upatches/cve-2026-76841
```

Publish and roll out:

```sh
shirudo bpm push build/packages/cve-2026-76841-1.0.0.bee oci://<registry>/<namespace>/cve-2026-76841 --keys-dir <keys-dir>
shirudo bpm tree append build/packages/cve-2026-76841-1.0.0.bee oci://<registry>/<namespace>/<tree> --tree-id <tree-id> --keys-dir <keys-dir>
```

## Review

- Contributors: romanlab.
- Reviewers: none recorded yet.

## Sources and links

- [Xinference repository](https://github.com/xorbitsai/inference)
- [Vulnerable loader in v2.11.0 (`xinference/model/rerank/core.py`)](https://github.com/xorbitsai/inference/blob/v2.11.0/xinference/model/rerank/core.py)
- [Issue #5023](https://github.com/xorbitsai/inference/issues/5023)
- [Pull request #5027](https://github.com/xorbitsai/inference/pull/5027)
- [VulnCheck advisory](https://www.vulncheck.com/advisories/xinference-through-remote-code-execution-via-hardcoded-trust-remote-code-in-model-loaders)

### Links

- [CVE-2026-76841 on upatch.dev](https://upatch.dev/cve/CVE-2026-76841) (this page, as HTML)
- [NVD](https://nvd.nist.gov/vuln/detail/CVE-2026-76841)
- [CVE.org](https://www.cve.org/CVERecord?id=CVE-2026-76841)
- [CWE-94](https://cwe.mitre.org/data/definitions/94.html)
- Upatch source: [upatches/cve-2026-76841](https://github.com/copper-helm/upatch-registry/tree/main/upatches/cve-2026-76841)

### More references from NVD (5)

- [github.com](https://github.com/xorbitsai/inference)
- [github.com](https://github.com/xorbitsai/inference/blob/v2.11.0/xinference/model/rerank/core.py)
- [github.com](https://github.com/xorbitsai/inference/issues/5023)
- [github.com](https://github.com/xorbitsai/inference/pull/5027)
- [vulncheck.com](https://www.vulncheck.com/advisories/xinference-through-remote-code-execution-via-hardcoded-trust-remote-code-in-model-loaders)
