Keras: HDF5 links can disclose local file contents
Keras versions up to 3.14.0 mishandle HDF5 ExternalLinks in model files, so loading a malicious .h5, .weights.h5 or .keras file can read files from the victim's local filesystem. An attacker could disclose sensitive local file contents through the loaded model or the file editor.
keras-team/keras
Originally disclosed on huntr
A vulnerability in keras-team/keras versions <= 3.14.0 allows arbitrary local HDF5 file content disclosure due to improper handling of HDF5 ExternalLinks. The KerasFileEditor and keras.saving.load_weights functions bypass the safe_get_h5_group and safe_get_h5_dataset helpers, which are designed to reject ExternalLinks and SoftLinks. This results in automatic dereferencing of links to external HDF5 files, enabling attackers to disclose sensitive data from the victim's local filesystem. Specifically, KerasFileEditor extracts attributes and datasets from linked files into its internal structures, while keras.saving.load_weights loads weights from linked files into the user's model. This issue can be exploited by providing a malicious .h5, .weights.h5, or .keras file containing ExternalLinks.
From the GitHub Advisory Database (GHSA-m8wh-29wm-52mv, 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 KerasFileEditor and load_weights code paths do not call the safe_get_h5_group and safe_get_h5_dataset helpers, so HDF5 ExternalLinks are dereferenced instead of rejected.
Impact
An attacker could disclose sensitive data from the victim's local filesystem by supplying a malicious model file, though the text does not show a full end-to-end exploit.
What the attacker needed
Victim loads a malicious .h5, .weights.h5 or .keras file
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.
HDF5 is a file format used to store model weights, and it can contain links that point to other files on the same computer. Keras is supposed to block those links for safety, but two functions skip that check, so a booby-trapped model file can pull in data from elsewhere on the disk. Someone who opens such a file may unknowingly expose local file contents.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.