On the (In)Security of Loading Machine Learning Models
This paper reveals that despite the widespread adoption of machine learning model sharing, current frameworks and hubs offer inadequate security protections, often containing critical vulnerabilities that enable arbitrary code execution while misleading users into a false sense of safety.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
Imagine you've just bought a new, high-tech coffee machine. The box says, "Plug and Play! No assembly required!" You trust the label, plug it in, and press the button. But instead of brewing coffee, the machine suddenly decides to repaint your living room walls, steal your Wi-Fi password, and order 500 pizzas to your house.
That is essentially what this paper is about, but instead of coffee machines, it's about Machine Learning (ML) models.
In the world of AI, developers share "pre-trained models" (like the coffee machine) on platforms like Hugging Face or Kaggle. These are supposed to be ready-to-use tools that anyone can download and run. The paper argues that loading these models is currently as dangerous as downloading a random executable file from the internet, yet everyone treats them as safe data files.
Here is the breakdown of their findings using simple analogies:
1. The "Safe Format" Illusion
For a long time, people thought: "If a file is just data (like a JSON text file) and not code (like a program), it can't hurt us."
The researchers found this to be a massive lie.
- The Analogy: Imagine a "Safe" envelope that only contains a list of ingredients. You think, "Great, ingredients can't hurt me." But the person who wrote the list used a secret code where the word "Sugar" actually means "Open the front door."
- The Reality: The paper found that even "secure" formats (like Keras's
.kerasor Skops's.skops) are essentially disguised code. They look like data, but when the computer tries to read them, it executes hidden instructions. The researchers found six brand-new (0-day) vulnerabilities in these "secure" formats that allowed hackers to run any command they wanted on your computer.
2. The "Safe Mode" Trap
Many frameworks have a switch called safe_mode or weights_only. The documentation says, "Turn this on, and you are safe!"
- The Analogy: It's like a car with a "Child Lock" button. The manual says, "If you press this, the back doors won't open." But the researchers found that if you press the button while the car is already moving, or if you use a specific type of key, the lock doesn't work at all.
- The Reality:
- In Keras, turning on
safe_modedidn't stop hackers from making the model execute code. - In PyTorch, the
weights_onlymode (which only loads numbers, not code) is safer, but it forces you to write the code for the model yourself. If you download that code from a shady source, you are back to square one. - The "Legacy" Problem: Even if you use the new "safe" settings, the software often still supports old, unsafe file formats (like
.h5or.pkl) for backward compatibility. It's like buying a modern, secure house but leaving the back door wide open because you "might need to move a sofa through it later."
- In Keras, turning on
3. The "Security Scanner" Blind Spot
Platforms like Hugging Face have "security scanners" that check uploaded models for viruses before letting you download them. They give models a "Safe" or "Unsafe" label.
- The Analogy: Imagine a security guard at a club who checks your ID. If you have a fake ID that looks exactly like a real one, the guard lets you in. But if you walk in wearing a tuxedo (a different format), the guard doesn't even know what to do with you, so he just waves you through saying, "No issues found," because he doesn't have a checklist for tuxedos.
- The Reality: The researchers tested their malicious models against these scanners.
- The scanners missed the new attacks because they were looking for old tricks.
- When the scanners didn't recognize a file format (like the new
.skops), they often labeled it "Safe" simply because they didn't know what it was. This gave users a false sense of security.
4. The "Trust Me" Survey
The researchers asked 60+ AI practitioners, "How safe do you feel using these tools?"
- The Analogy: It's like asking people, "How safe do you feel crossing the street if there is a sign that says 'Pedestrian Crossing'?" Most people feel safe. But if the researchers then reveal that the traffic lights are broken and the cars are driving on the sidewalk, the feeling of safety vanishes.
- The Reality: When users saw a "Safe Mode" switch or a "Scanned by Hugging Face" label, their confidence skyrocketed. They felt 90% safer. The paper argues this is dangerous because it makes people lazy. They stop thinking critically and just trust the label, even though the underlying technology is full of holes.
The Big Takeaway
The paper concludes that there is no silver bullet.
- Models are Code: You must treat every downloaded AI model as if it were a program you wrote yourself. It can do anything your computer can do.
- Don't Trust the Label: Just because a file says "Safe" or "Scanned" doesn't mean it is.
- The Trade-off: To be truly secure, you have to give up flexibility. You have to restrict what the model can do, which makes it less useful.
In short: The AI world is currently sharing "loaded guns" disguised as "data files." Until the industry stops pretending these files are harmless and starts treating them with the same extreme caution as software code, downloading a model from the internet remains a risky gamble.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.