LMDeploy Arbitrary Code Execution via Hardcoded trust_remote_code=True
LMDeploy versions 0.12.3 and older are vulnerable to arbitrary code execution (CVE-2026-46432) due to the application hardcoding `trust_remote_code=True` when loading HuggingFace models, allowing an attacker to execute arbitrary Python code during model initialization.
LMDeploy is vulnerable to arbitrary code execution because it hardcodes trust_remote_code=True in multiple HuggingFace model-loading call sites within lmdeploy/archs.py and lmdeploy/utils.py. This affects calls to AutoConfig.from_pretrained(), PretrainedConfig.get_config_dict(), and GenerationConfig.from_pretrained(). 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. This vulnerability affects lmdeploy versions 0.12.3 and earlier.
Attack Chain
- The attacker gains control over the
model_pathconfiguration used by lmdeploy. - The attacker sets the
model_pathto a malicious HuggingFace repository, such asattacker-org/malicious-model. - The lmdeploy serving process starts using the attacker-controlled model path via command-line argument (e.g.,
lmdeploy serve api_server attacker-org/malicious-model). - During model initialization, lmdeploy calls
AutoConfig.from_pretrained(),PretrainedConfig.get_config_dict(), orGenerationConfig.from_pretrained()withtrust_remote_code=True. - The HuggingFace Transformers library downloads Python code from the attacker’s repository.
- Transformers executes the downloaded Python code within the lmdeploy process.
- The attacker gains arbitrary code execution with the privileges of the lmdeploy serving process.
Impact
Successful exploitation of this vulnerability allows an attacker to execute arbitrary Python code during model initialization. The attacker can read files accessible to the lmdeploy process, access environment variables, model provider credentials, cloud credentials, and API keys, modify model-serving behavior, execute operating-system commands, access request data, cause denial of service, and pivot to internal services. This can lead to complete compromise of the lmdeploy server and potentially the wider network.
Recommendation
- Apply available patches as provided by the vendor. Upgrade to lmdeploy version 0.13.0 or later.
- As a workaround, ensure that the
model_pathconfiguration is sourced from a trusted source. - Monitor lmdeploy processes for unexpected file creations in
/tmpusing the marker file path from the provided proof of concept. - Deploy the Sigma rule
Detect Suspicious lmdeploy Model Loadingto detect potentially malicious model paths.
Detection coverage 2
Detect Suspicious lmdeploy Model Loading
highDetects suspicious model paths used with lmdeploy that may indicate an attempt to exploit the hardcoded `trust_remote_code=True` vulnerability (CVE-2026-46432)
Detect lmdeploy Trust Remote Code RCE Proof Marker File Creation
mediumDetects the creation of the marker file used in the lmdeploy trust_remote_code RCE proof of concept (CVE-2026-46432).
Detection queries are available on the platform. Get full rules →