AI Model-Loader `trust_remote_code` Order-of-Operations RCE Simulation (CVE-2026-22807)
by otakuliu · 2026-07-05
- Severity
- High
- CVE
- CVE-2026-22807
- Category
- misc
- Affected product
- AI inference/model-loading frameworks that resolve custom model classes via auto_map before validating trust_remote_code (pattern seen in vLLM/Transformers-style loaders)
- Affected versions
- Logic-pattern PoC; not tied to a specific upstream package version
- Disclosed
- 2026-07-05
- Patch status
- unpatched
Tags
Archive entry
intelseclab/poc-archiveMetadata
| Field | Value |
|---|---|
| Date Added | 2026-07-05 |
| Last Updated | 2026-01 |
| Author / Researcher | otakuliu |
| CVE / Advisory | CVE-2026-22807 |
| Category | misc |
| Severity | High |
| CVSS Score | Not specified in source |
| Status | PoC |
| Tags | vllm, huggingface, trust-remote-code, toctou, model-loading, supply-chain, python, code-execution |
| Related | N/A |
Affected Target
| Field | Value |
|---|---|
| Software / System | AI inference/model-loading frameworks that resolve custom model classes via auto_map before validating trust_remote_code (pattern seen in vLLM/Transformers-style loaders) |
| Versions Affected | Logic-pattern PoC; not tied to a specific upstream package version |
| Language / Platform | Python 3, no third-party dependencies required |
| Authentication Required | Local-only |
| Network Access Required | No |
Summary
This repository is a small, self-contained Python testbed (vulnerable_lib.py) that reproduces a class of AI supply-chain vulnerability found in model-loading frameworks: when a loader resolves a model’s Python class via a config.json’s auto_map field, it can end up importing (and therefore executing) attacker-controlled code before it ever checks whether trust_remote_code was set to False. The companion script (poc.py) builds a malicious “model” directory containing a config.json that points AutoModel at a malicious.py module, whose top-level code runs an arbitrary OS command supplied on the command line. Loading that model with trust_remote_code=False still results in the command executing, and only afterward does the loader raise its “remote code not allowed” exception — proving the security check happens too late to matter.
Vulnerability Details
Root Cause
MiniLLM.__init__() (in vulnerable_lib.py) calls _resolve_model_class() — which dynamically imports a Python file named in the model’s config.json auto_map — before checking self.trust_remote_code. Since Python executes top-level module code at import time, any code in the referenced file runs regardless of the later trust_remote_code check.
Attack Vector
- Attacker crafts a “model” directory with a
config.jsondeclaring"auto_map": {"AutoModel": "malicious.EvilModel"}. - Attacker plants a
malicious.pyin that directory whose top-level code callsos.system(<attacker command>). - Victim application loads the model directory via the vulnerable loader with
trust_remote_code=False, intending to reject untrusted code. - The loader imports
malicious.pyto resolve theAutoModelclass before the trust check runs, executing the attacker’s command; only after execution does the loader raiseRuntimeError("Aborted: Remote code not allowed!").
Impact
Arbitrary OS command execution on any system that loads an untrusted/third-party model directory through a loader with this ordering bug, even when the caller explicitly disables remote code execution.
Environment / Lab Setup
Target: Python 3.x, no third-party libraries needed (pure-stdlib simulation of the vulnerable loader)
Attacker: Same Python 3 interpreter, running poc.py locally
Proof of Concept
PoC Script
See
poc.pyandvulnerable_lib.pyin this folder.
| |
Running poc.py generates a dynamic_evil_model/ directory containing a rigged config.json and a malicious.py whose body runs the command passed on the command line (defaults to whoami). It then loads that directory via MiniLLM(model_path=..., trust_remote_code=False); the console shows the injected command’s output printed before the loader’s RuntimeError is raised, confirming the bypass.
Detection & Indicators of Compromise
Signs of compromise:
- OS commands or subprocesses observed originating from a model-loading/inference process, before any inference actually ran
- Untrusted model directories containing extra
.pyfiles referenced fromconfig.json’sauto_map - Loader logs showing a “remote code not allowed” rejection immediately after unexpected process activity (a sign the check ran too late)
Remediation
| Action | Detail |
|---|---|
| Primary fix | No vendor patch confirmed as of 2026-07-05 — monitor for advisory; loaders should validate trust_remote_code before resolving/importing any auto_map-referenced code |
| Interim mitigation | Never load third-party model directories with trust_remote_code=False assuming that setting alone is safe; vet and sandbox (container/VM, no network, restricted filesystem) any environment that loads untrusted model repositories |
References
Notes
Mirrored from https://github.com/otakuliu/CVE-2026-22807_Range on 2026-07-05.
| |