/

CVE-2026-46517

Severity:

HIGH RISK

(7.8)

Remote Code Execution (CWE-94) via LMDeploy HF Loading

CVE-2026-46517

Deferred

Vulnerability type

Category:

Remote Code Execution via Untrusted Code Loading

CWE:

CWE-94, CWE-915, CWE-1188

Impact:

Remote Code Execution (Supply-Chain Compromise)

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 remote model code execution by hardcoding trust_remote_code=True when loading models from Hugging Face.

This behavior allows unreviewed, repository-supplied Python code to run automatically during model loading, enabling supply-chain remote code execution when an attacker can control or tamper with the upstream model repository.

Affected context

This vulnerability affects environments that use LMDeploy (up to and including 0.12.3) to download and serve models from remote repositories such as Hugging Face Hub.

The risk is most pronounced when:

  • Model repositories are not fully trusted or are controlled by third parties
  • There is no manual review of repository code prior to deployment
  • LMDeploy runs in environments with meaningful network, file system, or data access

Because trust_remote_code=True is hardcoded, users do not need to explicitly opt in before remote code from the model repository is executed.

Exploit preconditions

  • Attack surface: Model loading and deployment workflow that pulls models from remote repositories (e.g., Hugging Face Hub).
  • Required access: Ability to publish, modify, or tamper with the target model repository (legitimately or via repository compromise).
  • Trigger point: LMDeploy's model initialization step, where the toolkit automatically executes repository-provided Python code with trust_remote_code=True.
  • Why exploitation is possible: Hardcoded trust of remote repository code bypasses user consent and validation, allowing arbitrary Python to run as part of model loading without interactive approval.

Why this happens

The underlying issue is unconditional execution of untrusted remote code as part of the model loading process, which maps to CWE-94: Improper Control of Generation of Code ('Code Injection').

By hardcoding trust_remote_code=True, LMDeploy implicitly treats remote repository content as trusted, executable logic rather than as untrusted model data.

This design also aligns with CWE-915 (Improperly Controlled Modification of Dynamically-Determined Object Attributes) and CWE-1188 (Insecure Default Initialization of Resource), because dynamic model components are instantiated from remote code under insecure default settings without explicit user opt-in or restrictive sandboxing.

Potential impact

  • Remote code execution under the privileges of the LMDeploy process
  • Compromise of the host running LMDeploy, including access to local files and environment secrets
  • Lateral movement within the serving infrastructure or cluster if additional privileges are available
  • Exfiltration or tampering of sensitive model inputs, outputs, or training data
  • Supply-chain compromise of downstream systems that rely on the affected model service

General mitigation guidance

Effective mitigation focuses on treating remote model repositories as untrusted code sources and tightening defaults around execution:

  • Prefer loading models in a mode that does not execute remote repository code by default, and require explicit, documented opt-in where truly necessary.
  • Introduce a clear trust boundary between model weights (data) and model implementation (code), avoiding automatic execution of repository-provided Python where possible.
  • Run LMDeploy and related inference workloads with least privilege, using restricted filesystem access, minimized environment variables, and locked-down network egress.
  • Where execution of remote code cannot be avoided, consider sandboxing (containers, VMs, seccomp, or similar) to constrain potential RCE impact.
  • Establish an internal review process for any model repository whose code will be executed, treating it like third-party software with code review and provenance checks.

How teams detect issues like this

Detection typically combines code-level analysis with operational monitoring:

  • Use static analysis or configuration review to identify hardcoded trust_remote_code=True or equivalent unsafe defaults in model tooling and deployment scripts.
  • Add CI policy checks that flag or block merges when remote code execution flags are enabled without justification.
  • Implement runtime monitoring and logging around model loading paths, capturing when and from where code is fetched and executed.
  • Review infrastructure audit logs for unexpected outbound network connections, unusual file access, or process behaviors originating from LMDeploy containers or hosts.
  • Employ software composition analysis (SCA) and supply-chain scanning tools to identify components that automatically execute remote code as part of their normal operation.

Sources

SourceLink
github.comgithub.com/InternLM/lmdeploy/security/advisories/GHSA-9xq9-36w5-q796

Frequently asked

questions

Exploitability depends on who controls the model repository.

If an attacker can publish or alter a model that LMDeploy loads (for example via account compromise or malicious contribution), they can likely achieve code execution when the model is deployed.

No local access to the host is required.

The primary requirement is control over, or ability to tamper with, the remote model repository that LMDeploy is configured to load.

The safest pattern is to disable automatic trust of remote repository code, require explicit opt-in for any remote code execution, and run LMDeploy in a minimally privileged, constrained environment.

Conceptually, remote models should be handled as untrusted inputs, not as implicitly trusted code.

Treat model and dataset repositories as part of your software supply chain:

  • Avoid insecure default flags like always-on trust_remote_code.
  • Require documented approval for any feature that executes remote code.
  • Enforce least privilege, sandboxing, and code provenance checks for all third-party model sources.
Find out what's already
exploitable in your codebase.