Advisory Database
  • Advisories
  • Dependency Scanning
  1. pypi
  2. ›
  3. keras
  4. ›
  5. CVE-2026-0897

CVE-2026-0897: Keras vulnerable to DoS via Malicious .keras Model (HDF5 Shape Bomb Causes Petabyte Allocation in KerasFileEditor)

May 6, 2026

Keras’s model loader (KerasFileEditor) unsafely loads user-supplied .keras model files containing HDF5-based weight files without performing any validation on HDF5 dataset metadata. An attacker can craft a .keras archive containing a valid model.weights.h5 file whose dataset declares an extremely large shape (e.g. (50_000_000, 50_000_000)), but stores only a few bytes. The .keras file remains small (100–400 KB) because HDF5 with gzip compression stores minimal data. During model loading, Keras executes: python result[key] = value[()] # loads entire dataset into memory value[()] instructs h5py to allocate RAM proportional to the dataset’s declared shape – in this case 8.88 PiB of memory. This results in: Immediate memory exhaustion Python / TensorFlow crashes Jupyter kernel kill System instability Full Denial of Service on any workload that processes untrusted .keras models This allows an attacker to crash any environment or pipeline that loads .keras models, including MLOps backends, training services, model upload endpoints, or automated pipelines.

References

  • github.com/advisories/GHSA-mgx6-5cf9-rr43
  • github.com/keras-team/keras
  • github.com/keras-team/keras/commit/7360d4f0d764fbb1fa9c6408fe53da41974dd4f6
  • github.com/keras-team/keras/commit/f704c887bf459b42769bfc8a9182f838009afddb
  • github.com/keras-team/keras/pull/21880
  • github.com/keras-team/keras/pull/22081
  • github.com/keras-team/keras/security/advisories/GHSA-mgx6-5cf9-rr43
  • nvd.nist.gov/vuln/detail/CVE-2026-0897

Code Behaviors & Features

Detect and mitigate CVE-2026-0897 with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →

Affected versions

All versions starting from 3.0.0 before 3.12.1, all versions starting from 3.13.0 before 3.13.2

Fixed versions

  • 3.12.1
  • 3.13.2

Solution

Upgrade to versions 3.12.1, 3.13.2 or above.

Impact 7.5 HIGH

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H

Learn more about CVSS

Weakness

  • CWE-770: Allocation of Resources Without Limits or Throttling

Source file

pypi/keras/CVE-2026-0897.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Sat, 09 May 2026 00:20:06 +0000.