lmdeploy hardcodes trust_remote_code=True in multiple HuggingFace model-loading call sites.
The affected code paths are in:
lmdeploy/archs.py
lmdeploy/utils.py
The vulnerable call sites pass trust_remote_code=True into HuggingFace Transformers APIs such as AutoConfig.from_pretrained(), PretrainedConfig.get_config_dict(), and GenerationConfig.from_pretrained().
Because the model path is supplied by the operator or deployment configuration, 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.
Successful exploitation results in arbitrary code execution with the privileges of the lmdeploy serving process.
Confirmed affected:
lmdeploy <= 0.12.3
The issue was verified on v0.12.3 and on main.
Confirmed call sites:
lmdeploy/archs.py:154
AutoConfig.from_pretrained(..., trust_remote_code=True)
lmdeploy/archs.py:157
PretrainedConfig.get_config_dict(..., trust_remote_code=True)
lmdeploy/utils.py:225
GenerationConfig.from_pretrained(..., trust_remote_code=True)
The vulnerable pattern is:
AutoConfig.from_pretrained(model_path, trust_remote_code=True)
and:
GenerationConfig.from_pretrained(path, trust_remote_code=True)
The risk is that trust_remote_code=True is enabled unconditionally. Users are not required to explicitly opt in through a CLI flag or configuration option.
0.0.100.0.110.0.120.0.130.0.140.1.00.10.00.10.10.10.20.11.0+42 more0.13.0Exploitability
AV:LAC:LPR:LUI:NScope
S:UImpact
C:HI:HA:HCVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H