🐍🔥 CVE-2025–50472: Critical RCE Vulnerability in Modelscope’s ms-swift Library
The ms-swift library deserialises untrusted .mdl model files using pickle.load(), allowing an attacker to execute arbitrary code when a victim loads a malicious model. This could lead to data theft, backdoor injection, or full server compromise.
Heads up, machine learning engineers! A nasty vulnerability has been discovered in Modelscope’s ms-swift library.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The load_model_meta() function in ModelFileSystemCache uses pickle.load() to deserialise data from a .mdl file without validating that the file is trusted.
Impact
An attacker could steal sensitive data, inject backdoors into models, or take complete control of the server, and the compromise may be stealthy and hard to detect.
What the attacker needed
Victim loads a malicious .mdl file; attacker can supply the model file
The fix
The library should avoid using pickle.load() on untrusted data and instead use safer formats like JSON or apply strict input validation; no patch is confirmed in the text.
How it was found
- The attacker crafts a malicious .mdl file with a payload.
- The victim loads the malicious model during a training process.
- The pickle.load() function deserialises the untrusted data, executing the attacker's code.
- The attacker gains control of the machine while the training process continues normally.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Pickle is a Python tool that turns saved data back into objects, but it can also run code hidden in that data. If a program loads a model file from an untrusted source without checking it, an attacker can put harmful instructions inside the file. When the program opens it, the attacker's code runs on your machine.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.