LMDeploy vulnerable to arbitrary code execution via eval() of untrusted quant_dtype in model config loading
### 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 `quantization_config.quant_dtype` value. When a user loads the model with lmdeploy, the `quant_dtype` is passed to `eval(f'torch.{quant_dtype}')` without any validation. ### Details **Vulnerable code** ([permalink](https://github.com/InternLM/lmdeploy/blob/17ed9e5/lmdeploy/pytorch/config.py#L620)): ```python quant_dtype = eval(f'torch.{quant_dtype}') # line 620 ``` The `quant_dtype` value comes from the model's `quantization_config` in its HuggingFace config. When a model specifies `quant_method: awq`, the AWQ branch processes the config but does NOT override `quant_dtype`, allowing the malicious value to reach the `eval()` call. **Attack vector:** An attacker publishes a HuggingFace model with: ```json { "quantization_config": { "quant_method": "awq", "quant_dtype": "float16, __import__('os').system('id')" } } ``` Note: The `_update_torch_dtype` method at line 53 has a whitelist check, but that's for `torch_dtype`, NOT `quant_dtype`. The `quant_dtype` at line 620 has no validation whatsoever. ### PoC ```python """ PoC: eval() RCE in lmdeploy via malicious quant_dtype 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.p
GHSA-3hmm-rh5q-gwwr
Primary source · Revision 1
Imported from structured advisory data. Source references identify upstream records or fields; verify affected versions and your deployed configuration.
Security context
Source reference: osv:GHSA-3hmm-rh5q-gwwr
lmdeploy
Source reference: /affected/0/package/name
- Affected versions
- 0.12.1
Source reference:
/affected/0/versions0.12.2Source reference:
/affected/0/versions - Fixed versions
- 0.12.3
Source reference:
/affected/0/ranges - Prerequisites
- Not stated in this record
Structured affected-version data
Original package identities and version rules from this source.
[
{
"ranges": [
{
"type": "ECOSYSTEM",
"events": [
{
"introduced": "0.12.1"
},
{
"fixed": "0.12.3"
}
]
}
],
"package": {
"name": "lmdeploy",
"purl": "pkg:pypi/lmdeploy",
"ecosystem": "PyPI"
},
"versions": [
"0.12.1",
"0.12.2"
],
"database_specific": {
"source": "https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/09/GHSA-3hmm-rh5q-gwwr/GHSA-3hmm-rh5q-gwwr.json"
}
}
]- Related CVEs
- CVE-2026-33625
Source reference:
/aliases
Publisher severity
high
Source reference: /database_specific/severity
- Event
- #62577 · Revision 1
- Added to Heist Feed
- Publisher date
PYSEC-2026-4078
Revision 2
LMDeploy vulnerable to arbitrary code execution via eval() of untrusted quant_dtype in model config loading
### 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 `quantization_config.quant_dtype` value. When a user loads the model with lmdeploy, the `quant_dtype` is passed to `eval(f'torch.{quant_dtype}')` without any validation. ### Details **Vulnerable code** ([permalink](https://github.com/InternLM/lmdeploy/blob/17ed9e5/lmdeploy/pytorch/config.py#L620)): ```python quant_dtype = eval(f'torch.{quant_dtype}') # line 620 ``` The `quant_dtype` value comes from the model's `quantization_config` in its HuggingFace config. When a model specifies `quant_method: awq`, the AWQ branch processes the config but does NOT override `quant_dtype`, allowing the malicious value to reach the `eval()` call. **Attack vector:** An attacker publishes a HuggingFace model with: ```json { "quantization_config": { "quant_method": "awq", "quant_dtype": "float16, __import__('os').system('id')" } } ``` Note: The `_update_torch_dtype` method at line 53 has a whitelist check, but that's for `torch_dtype`, NOT `quant_dtype`. The `quant_dtype` at line 620 has no validation whatsoever. ### PoC ```python """ PoC: eval() RCE in lmdeploy via malicious quant_dtype 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.p
Imported from structured advisory data. Source references identify upstream records or fields; verify affected versions and your deployed configuration.
Security context
Source reference: osv:PYSEC-2026-4078
lmdeploy
Source reference: /affected/0/package/name
- Affected versions
- 0.12.1
Source reference:
/affected/0/versions0.12.2Source reference:
/affected/0/versions - Fixed versions
- 0.12.3
Source reference:
/affected/0/ranges - Prerequisites
- Not stated in this record
Structured affected-version data
Original package identities and version rules from this source.
[
{
"ranges": [
{
"type": "ECOSYSTEM",
"events": [
{
"introduced": "0.12.1"
},
{
"fixed": "0.12.3"
}
]
}
],
"package": {
"name": "lmdeploy",
"purl": "pkg:pypi/lmdeploy",
"ecosystem": "PyPI"
},
"versions": [
"0.12.1",
"0.12.2"
],
"database_specific": {
"source": "https://github.com/pypa/advisory-database/blob/main/vulns/lmdeploy/PYSEC-2026-4078.yaml"
}
}
]- Related CVEs
- CVE-2026-33625
Source reference:
/aliases
Publisher severity
No explicit severity was provided.
- Event
- #62578 · Revision 2
- Added to Heist Feed
- Publisher date