Skip to content
RCE Disclosed report Advanced CVE-2026-1462

Keras has an untrusted deserialization vulnerability

The TFSMLayer class in Keras 3.13.0 loads attacker-controlled TensorFlow SavedModels during deserialisation of .keras models even when safe_mode is enabled. An attacker could achieve arbitrary code execution during model inference under the victim's privileges.

keras-team/keras

Originally disclosed on huntr

A vulnerability in the TFSMLayer class of the keras package, version 3.13.0, allows attacker-controlled TensorFlow SavedModels to be loaded during deserialization of .keras models, even when safe_mode=True. This bypasses the security guarantees of safe_mode and enables arbitrary attacker-controlled code execution during model inference under the victim's privileges. The issue arises due to the unconditional loading of external SavedModels, serialization of attacker-controlled file paths, and the lack of validation in the from_config() method.

From the GitHub Advisory Database (GHSA-4f3f-g24h-fr8m, CC BY 4.0).

The original report as published on the GitHub Advisory Database. Images and videos are our own copies; raw HTML is shown as text. View it on GitHub Advisory Database.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the TFSMLayer class unconditionally loads external SavedModels and serialises attacker-controlled file paths without validating them in from_config().

Impact

An attacker could execute arbitrary code during model inference under the victim's privileges, bypassing safe_mode.

What the attacker needed

Victim loads a malicious .keras model; safe_mode is enabled but bypassed

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 report has not been written yet. The Original tab links to the source.

Keras is a library for building machine learning models. When you load a saved model file, Keras has a 'safe mode' that is supposed to stop the file from running harmful code. This bug lets a malicious model file sneak in a second model that runs code when you use it, even with safe mode on.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More from keras-team/keras

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.