The Dark Side of AI: Inside PyTorch’s Unpatched Vulnerabilities
Two PyTorch utility scripts load user-supplied files with pickle.load, so a malicious file can execute arbitrary code when analysed. An attacker who convinces a victim to open a crafted CUDA memory dump or flight recorder trace file could run commands on the victim's machine.
medium.com
Published on medium.com
In this blog post, I want to share some of the zero-days I found in Pytorch that Pytorch has refused to patch. I want my fellow developers and anyone else who uses Pytorch to remain safe, so I have decided to disclose them publicly on this blog.
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 scripts use pickle.load to deserialise untrusted files, which allows arbitrary code execution during deserialisation.
Impact
An attacker could execute arbitrary code on a victim's system if the victim analyses a malicious file, though the text notes PyTorch has refused to patch these issues.
What the attacker needed
Victim downloads a malicious file; victim runs the PyTorch analysis script
The fix
The scripts should avoid pickle and use a safe serialisation format, but the text says PyTorch has refused to patch.
How it was found
- Create a malicious pickle file that runs a command when loaded.
- Rename the file to match the expected naming pattern for flight recorder traces.
- Place the file in a directory that the tool will process.
- Run the PyTorch analysis script on the malicious file or directory.
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 Python's way of saving objects to a file, but loading a pickle file can run code. These PyTorch tools load files with pickle, so opening a file from someone else can let them run commands on your computer.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.