In this article
The fix propagates safe_mode into legacy model deserialization; a trusted-looking file extension or compile=False does not establish a safe loading path.
Keras’s September 19, 2025 advisory identifies a gap in how the legacy HDF5 full-model loader handled safe_mode. The public loading function accepted the argument, but the affected legacy branch did not pass it into model reconstruction. A caller could therefore request restricted behavior without receiving it on that path.
Keep the format and version scope explicit
The original Keras advisory, associated with CVE-2025-9905, concerns full models loaded from files ending in .h5 or .hdf5. The reviewed affected range begins with 3.0.0 and ends before the patched 3.11.3 release. This historical boundary is specific to the advisory, rather than a general statement about every HDF5-consuming library.
The reported attack uses serialized model behavior that can execute during loading with the permissions of the application process. It does not require a later prediction call. This is not evidence that every HDF5 tensor file contains executable behavior: the full-model configuration and reconstruction path are central to the issue.
Follow the actual loading branch
The affected public loader delegated legacy files to another function without forwarding safe_mode. That differs from the newer model-format branch, so a single argument visible in application code did not establish uniform handling across formats.
The official loading reference describes safe_mode in terms of unsafe lambda deserialization and warns about disabling it. Its format-oriented description should be read alongside the implementation and release version. An API signature alone cannot prove that a particular legacy branch applies the option.
The patch adds propagation and a scope
The actual fixing pull request forwards safe_mode from the public loader into the HDF5 loader. The legacy reconstruction then enters a safe-mode scope while rebuilding model configuration. This is more specific than merely adding a warning or rejecting every legacy file.
The patch also adds regression coverage for lambda deserialization through that path. Those tests describe the intended protection for the reported case; they do not authenticate all custom objects or establish that every possible model-loading behavior is harmless. A patched loader and a trusted model source still answer different questions.
Compilation and tensor loading are separate decisions
The compile option controls whether a reconstructed model is compiled. Turning it off is not a substitute for guarding configuration deserialization, which happens while the model is being rebuilt. Likewise, a workflow that loads only compatible weights has a different input contract from loading a complete saved model.
The artifact-validation guide explains why serialization, code dependencies and provenance should be recorded separately. For a legacy model, preserve whether the file contains the full architecture, which custom objects are supplied, and which loader version actually handles it. A matching extension is not a complete trust decision.
Validate the migration with known models
A practical update record identifies the application runtime and any background conversion environment, retains supported patched dependencies and checks accepted reference artifacts. Compare architecture, weights and representative outputs after loading rather than assuming successful deserialization proves functional equivalence.
The reproducible-stack guide supports that record. If a historical model needs additional trusted code, document that dependency explicitly. The advisory establishes a concrete missing propagation step and remediation boundary; it does not justify disabling restrictions simply because an unfamiliar file otherwise fails to open.
Earn rental income from GPUs
Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.