upatch.dev

CVE-2026-76841

Xinference through 2.11.0 Remote Code Execution via Hardcoded trust_remote_code in Model Loaders

Refuses Hugging Face dynamic module creation and loading to mitigate Xinference remote code execution CVE-2026-76841.

High 8.7Vetted

EPSS 1.0%: the estimated chance this CVE is exploited in the next 30 days, as of 24 Nov 2026.

At a glance

CVE-2026-76841 is a high (CVSS 8.7) vulnerability in Xinference, published 24 August 2026. A vetted upatch, cve-2026-76841-xinference-block, blocks it on running Linux machines with shirudo until Xinference is upgraded.

Severity
High 8.7 CVSS 4.0
Chance of exploitation
1.0% in the next 30 days (EPSS, 24 Nov 2026)
Known exploited
No, not on CISA’s KEV list
Weakness
CWE-94
Affected software
Xinference (xorbitsai)
Upatch status
Vetted, merged into the registry
How to apply
Build, sign and roll out with shirudo

Overview

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.

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.

Sources

More references from NVD (5)

Mitigation

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.

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.

The policy

132 lines of BPF C, attached at lsm/inode_create and lsm/file_open.

// SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause

#include "vmlinux.h"
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h>
#include <bpf/bpf_core_read.h>

#define EPERM 1

char _license[] SEC("license") = "Dual BSD/GPL";

enum {
	REFUSED_CREATE,
	REFUSED_OPEN,
	NR_COUNTERS,
};

struct {
	__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
	__uint(max_entries, NR_COUNTERS);
	__type(key, __u32);
	__type(value, __u64);
} refused SEC(".maps");

static __always_inline void count(__u32 key)
{
	__u64 *value = bpf_map_lookup_elem(&refused, &key);

	if (value)
		__sync_fetch_and_add(value, 1);
}

static __always_inline bool ends_with_py(const struct dentry *dentry)
{
	const unsigned char *name = BPF_CORE_READ(dentry, d_name.name);
	__u32 len = BPF_CORE_READ(dentry, d_name.len);
	char tail[3] = {};

	if (!name || len < 4 || len > 255)
		return false;
	if (bpf_probe_read_kernel(tail, sizeof(tail), name + len - 3))
		return false;
	return tail[0] == '.' && tail[1] == 'p' && tail[2] == 'y';
}

static __always_inline bool is_transformers_modules(const struct dentry *dentry)
{
	const unsigned char *name = BPF_CORE_READ(dentry, d_name.name);
	const char want[] = "transformers_modules";
	char buf[21] = {};

	if (!dentry || BPF_CORE_READ(dentry, d_name.len) != 20)
		return false;
	if (bpf_probe_read_kernel(buf, 20, name))
		return false;
	for (int i = 0; i < 20; i++) {
		if (buf[i] != want[i])
			return false;
	}
	return true;
}

static __always_inline bool under_transformers_modules(const struct dentry *dentry)
{
	const struct dentry *cur = dentry;

	for (int i = 0; i < 6; i++) {
		const struct dentry *parent = BPF_CORE_READ(cur, d_parent);

		if (!parent || parent == cur)
			return false;
		if (is_transformers_modules(parent))
			return true;
		cur = parent;
	}
	return false;
}

static __always_inline bool current_is_python(void)
{
	struct task_struct *task = bpf_get_current_task_btf();
	const struct dentry *exe = BPF_CORE_READ(task, mm, exe_file, f_path.dentry);
	const unsigned char *name = BPF_CORE_READ(exe, d_name.name);
	__u32 len = BPF_CORE_READ(exe, d_name.len);
	const char want[] = "python";
	char buf[6] = {};

	if (!exe || !name || len < 6)
		return false;
	if (bpf_probe_read_kernel(buf, sizeof(buf), name))
		return false;
	for (int i = 0; i < 6; i++) {
		if (buf[i] != want[i])
			return false;
	}
	return true;
}

static __always_inline int earlier_verdict(int ret)
{
	return ret >= -4095 && ret < 0 ? ret : -EPERM;
}

SEC("lsm/inode_create")
int BPF_PROG(cve_2026_76841_create, const struct mnt_idmap *idmap,
	     struct inode *dir, struct dentry *dentry, umode_t mode, int ret)
{
	if (ret)
		return earlier_verdict(ret);
	if (!ends_with_py(dentry))
		return 0;
	if (!under_transformers_modules(dentry) || !current_is_python())
		return 0;
	count(REFUSED_CREATE);
	return -EPERM;
}

SEC("lsm/file_open")
int BPF_PROG(cve_2026_76841_open, struct file *file, int ret)
{
	const struct dentry *dentry = file->f_path.dentry;

	if (ret)
		return earlier_verdict(ret);
	if (!ends_with_py(dentry))
		return 0;
	if (!under_transformers_modules(dentry) || !current_is_python())
		return 0;
	count(REFUSED_OPEN);
	return -EPERM;
}

Process

How this upatch was written, checked and reviewed, from the registry’s history.

  1. 24 Aug 2026CVECVE published
  2. 25 Nov 2026Pull requestPull request #31 openedAdd CVE-2026-76841: Refuses Hugging Face dynamic module creation and loading to mitigate Xinferenceromanlab
  3. 25 Nov 2026MergeMerged #31romanlab
  4. 25 Nov 2026ReviewReviewedqodo-code-review[bot] (automated)

No human review is recorded on GitHub for this upatch yet.

Evidence

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
StateXinference stages probe_tokenizer.py under transformers_modules
Before loadingreached
Upatch loadedblocked (EPERM)
After unloadingreached
tools-test.log Output of tools/test --setup showing the probe reached before loading, blocked while the upatch was loaded, and reached again after unloading.
tools/test --setup, 2026-11-25T11:35:24Z
Target: shirudo test VM, Linux 7.4-shirudo-ci-20261123, x86_64, swtpm
cve-2026-76841
  setup   done         XINFERENCE_URL=http://127.0.0.1:9997 HF_MODULES_CACHE=/opt/upatch-payload/cve-2026-76841/hf-home/modules
  before  reached      Xinference staged probe_tokenizer.py under transformers_modules
  loaded  blocked      kernel refused staging dynamic module under transformers_modules (EPERM)
  after   reached      Xinference staged probe_tokenizer.py under transformers_modules
  PASS: reached before, blocked while loaded, reached again after

Use it

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
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
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>