/

CVE-2026-46432

Severity:

HIGH RISK

(7.8)

Code Injection (CWE-94) in LMDeploy Model Loading Logic

CVE-2026-46432

Deferred

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

Impact:

Remote Code Execution

Severity:

HIGH RISK

(7.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

LMDeploy versions 0.12.3 and earlier enable arbitrary code execution by hardcoding trust_remote_code=True when loading HuggingFace models.

If an attacker can influence the remote model repository or redirect model references, they can execute malicious Python code within the LMDeploy process.

Affected context

This vulnerability appears in LMDeploy environments that load models from HuggingFace or similar hubs using code paths where trust_remote_code=True is hardcoded.

It is most relevant in scenarios where model identifiers or repositories can be controlled, swapped, or tampered with by less-trusted parties, such as multi-tenant model hubs, shared experimentation environments, or automated pipelines that fetch models dynamically.

The issue manifests during model initialization, when LMDeploy invokes the underlying HuggingFace APIs that permit execution of remote Python code as part of model loading.

Exploit preconditions

  • Attack surface: Model loading and deployment workflows using LMDeploy.
  • Required access: Ability to control or tamper with the referenced model repository (e.g., publishing a malicious model, altering configuration, or influencing the model name/URL used by LMDeploy).
  • Trigger point: A vulnerable LMDeploy process loads a model via a call site that sets trust_remote_code=True, causing remote Python modules to be imported and executed.
  • Why exploitation is possible: Hardcoded trust of remote code bypasses local validation and treats repository-provided Python modules as inherently safe, allowing an attacker to embed arbitrary executable code in the model package.

Why this happens

The core issue stems from a code injection pattern where untrusted, remotely hosted Python code is implicitly treated as trusted application logic.

LMDeploy's model-loading integrations with HuggingFace hardcode trust_remote_code=True, instructing the library to execute Python modules that are shipped alongside the model.

This aligns with CWE-94: Improper Control of Generation of Code, because the application fails to restrict or validate code obtained from external sources before execution, effectively allowing attackers to inject arbitrary behavior through the model artifacts.

Potential impact

  • Execution of arbitrary Python code within the LMDeploy service or worker process.
  • Compromise of the host running LMDeploy, including access to environment variables, credentials, and attached data stores.
  • Unauthorized access to or exfiltration of model weights, prompts, user inputs, and inference outputs.
  • Lateral movement inside the broader hosting environment, depending on LMDeploy's runtime permissions.
  • Service disruption or sabotage, such as model backdooring, response manipulation, or denial-of-service behavior.

General mitigation guidance

Mitigation generally focuses on reducing trust in remote code and tightening the execution boundary between model data and application logic.

Common defensive patterns include:

  • Avoiding or disabling trust_remote_code semantics wherever possible, preferring pure data-only model formats that do not require executing arbitrary Python modules.
  • Restricting model sources to vetted, internally mirrored, or cryptographically verified repositories, and treating external model hubs as untrusted by default.
  • Introducing explicit allow-lists for model repositories or authors whose code is permitted to run in deployment environments.
  • Running LMDeploy in hardened, least-privilege sandboxes (e.g., containers with minimal filesystem and network access, reduced OS capabilities, and segregated secrets).
  • Separating model loading from critical infrastructure components so that compromise of one worker has limited blast radius.

How teams detect issues like this

Detection can focus on both source-level configuration and runtime behavior.

Useful approaches include:

  • Static analysis or grep-based checks that flag trust_remote_code=True usages in LMDeploy integrations, configuration scripts, or wrappers.
  • Code review practices that treat any remote code execution features in model loaders as security-sensitive and require explicit justification and architectural safeguards.
  • Policy-based enforcement in CI/CD pipelines that block deployments when disallowed flags or risky model-loading patterns are detected.
  • Runtime monitoring for anomalous behavior from LMDeploy processes, such as unexpected outbound network connections, file writes, or process spawning during or immediately after model loading.
  • Periodic inventory of deployed models and their sources to identify unapproved or newly added repositories with executable components.

Sources

SourceLink
github.comgithub.com/InternLM/lmdeploy/security/advisories/GHSA-m549-qq94-fvhg

Frequently asked

questions

It can be, if an attacker can publish or modify a model repository that LMDeploy will load, or can influence which remote model identifier is used. In tightly controlled environments where model sources and identifiers are strictly fixed and vetted, the practical exposure is reduced.

An attacker typically needs the ability to control or tamper with the model repository or reference used by LMDeploy. This might mean owning a model on a public hub that is later pulled into production, or compromising a repository that a pipeline relies on.

The safest pattern is to avoid executing remote code altogether: disable trust_remote_code semantics, treat models as data-only artifacts, and limit loading to formats that do not embed executable Python. Where code execution is unavoidable, restrict it to tightly controlled, reviewed, and internal repositories.

Treat model-loading paths as supply-chain entry points and apply standard secure software design: minimize trust in external artifacts, enforce explicit allow-lists for code execution, sandbox high-risk operations, and integrate automated checks that flag remote code execution features during development and deployment.

Find out what's already
exploitable in your codebase.