My first PoC — CVE-2025-1550: Arbitrary Code Execution in K
Keras allows arbitrary command execution when loading a malicious model with safe_mode=False, because Lambda layers can contain custom code that runs on load. An attacker could trick a victim into loading such a model and execute any command on their machine.
Published on medium.com
So, for my final capstone project as a requirement in Cyber Nachama Bootcamp. I have to find and exploit a real vulnerability.
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
Likely the design allows Lambda layers to execute arbitrary code when safe_mode is disabled, and users may disable it without understanding the risk.
Impact
An attacker could execute arbitrary commands on a victim's machine if the victim loads a malicious model with safe_mode disabled.
What the attacker needed
Victim loads a malicious model; safe_mode is disabled; attacker can deliver the model file
The fix
The issue was fixed in newer Keras versions; users should never disable safe_mode and should update Keras.
How it was found
- Set up a virtual machine with Ubuntu 24.04.3 and install Python 3.10 from an added apt repository.
- Create a virtual environment and install Keras 2.15.0 and TensorFlow.
- Write a script that builds a model with a Lambda layer containing a command to create a file, and saves it with safe_mode=False.
- Run the script to generate the malicious model file.
- Load the malicious model with safe_mode=False to trigger the command execution.
- Load the same model with safe_mode=True to confirm it is blocked.
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.
Keras is a tool for building AI models. It has a feature that lets models include custom code, which is normally blocked for safety. If you turn off that safety setting, loading a model can run any command on your computer, like deleting files or installing malware.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.