Keras: DiskIOStore permits path traversal through crafted layer names
The DiskIOStore.make method in Keras 3.14.0 builds directory paths from user-supplied layer names without blocking parent-directory sequences. An attacker could craft a malicious Keras model that, when saved or loaded, writes files or creates directories outside the intended temporary working directory.
keras-team/keras
Originally disclosed on huntr
A path traversal vulnerability exists in keras-team/keras version 3.14.0, specifically in the DiskIOStore.make method within the Keras 3 model saving and loading library. This vulnerability arises from the improper handling of user-provided layer names, which are used to construct directory paths without sanitizing for parent directory components (..). While forward slashes (/) are restricted in layer names, directory traversal sequences are not. This allows an attacker to craft a malicious Keras model that, when saved or loaded, can escape the intended temporary working directory and perform unauthorized file system operations, such as creating directories or writing files in arbitrary locations.
From the GitHub Advisory Database (GHSA-gh82-f9x8-5frx, CC BY 4.0).
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 layer name is joined into a filesystem path without rejecting parent-directory components, so '..' segments escape the intended working directory.
Impact
An attacker could create directories or write files in arbitrary locations on the filesystem, limited to what the Keras process is permitted to access.
What the attacker needed
Crafted Keras model file; victim saves or loads the model
The fix
Layer names should be sanitised to reject parent-directory components before being used in filesystem paths.
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.
When a program saves a model, it uses the layer names to make folder names. If a name contains '..', which means 'go up one folder', the program can be tricked into writing outside its own folder. This is called path traversal, and it lets someone put files in places they should not reach.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.