Executive brief
Keras, a popular machine learning library, contains a vulnerability in how it handles model saving and loading. An attacker can create a specially crafted AI model that, when opened or saved by a user, performs unauthorized file operations outside of the intended folder. This could allow an attacker to create malicious directories or overwrite files on the user's system, potentially leading to data loss or system instability.
Technical details
A path traversal vulnerability exists in Keras (specifically version 3.14.0 and other affected ranges) within the `DiskIOStore.make` and `DiskIOStore.get` methods. The root cause is improper sanitization of user-provided layer names, which are used to construct directory paths. While forward slashes are restricted, directory traversal sequences (e.g., '..') are not neutralized. An attacker can craft a malicious Keras model with specific layer names that, when processed during saving or loading, escape the temporary working directory to create directories or write files in arbitrary locations. The vulnerability is addressed in versions 3.12.3 and 3.15.0 by implementing path resolution checks using `resolve_sub_path`.
Affected products
- Keras Team Keras < 3.12.3, >= 3.13.0, < 3.15.0
Timeline
- 2026-06-01: other: Pull request submitted to fix the issue
- 2026-06-02: patched: Fix merged into master branch
- 2026-06-22: disclosed: CVE-2026-12479 published
- 2026-06-26: advisory: Security release v3.12.3 published
References
- https://huntr.com/bounties/188836b9-12fc-49c7-8dbf-04f60fe33743
- https://github.com/keras-team/keras/pull/23017
- https://github.com/keras-team/keras/commit/d8caeb58cc9e61ea092445dc7a20908ca8d693e2
- https://github.com/keras-team/keras/releases/tag/v3.12.3
- https://github.com/keras-team/keras/releases/tag/v3.15.0