Skip to content

GHSA-26c4-7vv6-867j CVE-2026-12480 PYSEC-2026-3629

Keras: HDF5 virtual datasets can disclose local files

Medium PyPI
Severity
5.5 / 10
Medium · CVSS 3.0
Exploit chance (EPSS)
0.19%
Chance of exploitation in the next 30 days. Higher than 8.72% of scored vulnerabilities.
Known exploited
No
Not in CISA's catalog
Weakness
CWE-73 External Control of File Name or Path
Fix
3.12.3
Upgrade keras to this version or later

Description

Keras versions up to and including 3.13.2 are vulnerable to an arbitrary HDF5 file read due to an incomplete fix for CVE-2026-1669. The vulnerability resides in the H5IOStore._verify_dataset() and file_editor.py methods, which fail to check the dataset.is_virtual property of HDF5 datasets. This allows an attacker to craft a malicious .keras model archive or .h5 weights file containing a Virtual Dataset (VDS) that references external HDF5 files on the victim's filesystem. When the victim loads the model using keras.models.load_model() or keras.saving.load_model(), the external file is transparently read, leading to potential information disclosure. Fixed in versions 3.12.3 and 3.15.0.

Affected versions

PyPI

PackageVulnerableFixed in
keras
< 3.12.3
3.12.3
keras
>= 3.13.0, < 3.15.0
3.15.0
keras
< 3.12.3
>= 3.13.0, < 3.15.0
3.12.3
3.15.0

How to fix

Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.

keras PyPI → 3.12.3

pip
pip install --upgrade "keras>=3.12.3"
poetry
poetry add "keras>=3.12.3"
uv
uv add "keras>=3.12.3"

Severity breakdown

CVSS 3.0 5.5

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

Attack vector
Local
Attack complexity
Low
Privileges required
None
User interaction
Required
Scope
Unchanged
Confidentiality
High
Integrity
None
Availability
None

Weakness

CWE-73: External Control of File Name or Path

The product allows user input to control or influence paths or file names that are used in filesystem operations.

How to prevent it
  • Architecture and Design: When the set of filenames is limited or known, create a mapping from a set of fixed input values (such as numeric IDs) to the actual filenames, and reject all other inputs. For example, ID 1 could map to "inbox.txt" and ID 2 could map to "profile.txt". Features such as the ESAPI AccessReferenceMap provide this capability.
  • Architecture and Design, Operation: Run your code in a "jail" or similar sandbox environment that enforces strict boundaries between the process and the operating system. This may effectively restrict all access to files within a particular directory. Examples include the Unix chroot jail and AppArmor. In general, managed code may provide some protection. This may not be a feasible solution, and it only limits the impact to the operating system; the rest of your application may still be subject to compromise. Be careful to avoid CWE-243 and other weaknesses related to jails.
  • Architecture and Design: For any security checks that are performed on the client side, ensure that these checks are duplicated on the server side, in order to avoid CWE-602. Attackers can bypass the client-side checks by modifying values after the checks have been performed, or by changing the client to remove the client-side checks entirely. Then, these modified values would be submitted to the server.
  • Implementation: Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does. When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and conformance to business rules. As an example of business rule logic, "boat" may be syntactically valid because it only contains alphanumeric characters, but it is not valid if the input is only expected to contain colors such as "red" or "blue." Do not rely exclusively on looking for malicious or malformed inputs. This is likely to miss at least one undesirable input, especially if the code's environment changes. This can give attackers enough room to bypass the intended validation. However, denylists can be useful for detecting potential attacks or determining which inputs are so malformed that they should be rejected outright. When validating filenames, use stringent allowlists that limit the character set to be used. If feasible, only allow a single "." character in the filename to avoid weaknesses such as CWE-23, and exclude directory separators such as "/" to avoid CWE-36. Use a list of allowable file extensions, which will help to avoid CWE-434. Do not rely exclusively on a filtering mechanism that removes potentially dangerous characters. This is equivalent to a denylist, which may be incomplete (CWE-184). For example, filtering "/" is insufficient protection if the filesystem also supports the use of "\" as a directory separator. Another possible error could occur when the filtering is applied in a way that still produces dangerous data (CWE-182). For example, if "../" sequences are removed from the ".../...//" string in a sequential fashion, two instances of "../" would b
  • Implementation: Use a built-in path canonicalization function (such as realpath() in C) that produces the canonical version of the pathname, which effectively removes ".." sequences and symbolic links (CWE-23, CWE-59).
  • Installation, Operation: Use OS-level permissions and run as a low-privileged user to limit the scope of any successful attack.
  • Operation, Implementation: If you are using PHP, configure your application so that it does not use register_globals. During implementation, develop your application so that it does not rely on this feature, but be wary of implementing a register_globals emulation that is subject to weaknesses such as CWE-95, CWE-621, and similar issues.
  • Testing: Use tools and techniques that require manual (human) analysis, such as penetration testing, threat modeling, and interactive tools that allow the tester to record and modify an active session. These may be more effective than strictly automated techniques. This is especially the case with weaknesses that are related to design and business rules.

References

Timeline

  1. Published
  2. Last updated by the source
  3. Latest EPSS score
AdvisorySeverityWhy it's related
GHSA-74m6-m3xx-3vmj
Keras model loading is vulnerable to denial of service through HDF5 shape bombs
Medium Also affects keras
GHSA-m8wh-29wm-52mv
Keras: HDF5 links can disclose local file contents
Medium Also affects keras
GHSA-v2w2-w228-c444
Keras: TorchModuleWrapper can deserialize unsafe PyTorch pickle data
High Also affects keras
GHSA-58hv-7753-xmfq
Keras: tar extraction permits symlink-based path traversal
Medium Also affects keras
GHSA-5gwj-m78q-7pq3
Keras: Lambda deserialization can bypass safe mode and execute code
Critical Also affects keras
GHSA-gh82-f9x8-5frx
Keras: DiskIOStore permits path traversal through crafted layer names
Medium Also affects keras
GHSA-hqp4-2352-xf5r
Keras archive extraction utilities allow path traversal and arbitrary file writes
High Also affects keras
GHSA-4f3f-g24h-fr8m
Keras has an untrusted deserialization vulnerability
High Also affects keras
Is this in your code?

MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.

Check your repos with MergeHarbor