Keras: Improper Control of Dynamically-Managed Code Resources
CVE-2025-9905 is a high-severity improper control of dynamically-managed code resources vulnerability in Keras from Keras-team, with a CVSS 3.1 base score of 7.3 out of 10. It can be exploited with local access to the system by an attacker with a low-privileged account, but only if a user takes part, for example by opening a link or file. Affected Keras versions: 3.0.0 through 3.11.2. The record does not name a fixed version, so check the vendor advisory. There is no confirmed exploitation so far. EPSS estimates a 0.22% chance of exploitation within 30 days, which is low compared with other CVEs.
High severity with no evidence of exploitation so far.
What to do
- Check which version of Keras you run against the affected versions below, and install the vendor's latest release.
- Read the advisory on github.com for workarounds and exact fixed builds.
- Because the attack needs a user to take part, warn users about unexpected links and files related to this product until it is patched.
Affected products and versions
| Vendor | Product | Affected versions | Fixed in |
|---|---|---|---|
| Keras-team | Keras | 3.0.0 through 3.11.2 | Not stated |
Version data comes from the organisation that assigned the CVE. Confirm against the vendor advisory before deciding you are unaffected.
How the severity score breaks down
- Attack vector
- LocalThe attacker needs local access or must trick a user into running something.
- Attack complexity
- LowNo special conditions are needed; the attack works reliably.
- Privileges required
- LowA basic user account is enough.
- User interaction
- RequiredA user must take an action such as opening a file or link.
- Scope
- UnchangedImpact stays within the vulnerable component.
- Confidentiality
- HighAll data handled by the component can be read.
- Integrity
- HighData or code can be modified at will.
- Availability
- HighThe component can be taken down completely.
Vector: CVSS:3.1/AV:L/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:H. Scored by NVD.
| Scoring system | Score | Severity | Scored by |
|---|---|---|---|
| CVSS 4.0 | 7.3 | High | CNA (google.com) |
| CVSS 3.1 | 7.3 | High | NVD |
Official description
The Keras Model.load_model method can be exploited to achieve arbitrary code execution, even with safe_mode=True. One can create a specially crafted .h5/.hdf5 model archive that, when loaded via Model.load_model, will trigger arbitrary code to be executed. This is achieved by crafting a special .h5 archive file that uses the Lambda layer feature of keras which allows arbitrary Python code in the form of pickled code. The vulnerability comes from the fact that the safe_mode=True option is not honored when reading .h5 archives. Note that the .h5/.hdf5 format is a legacy format supported by Keras 3 for backwards compatibility.
Source: the CVE record as published by its numbering authority, via NVD and CVE.org.
The underlying weakness: Improper Control of Dynamically-Managed Code Resources
The product does not properly restrict reading from or writing to dynamically-managed code resources such as variables, objects, classes, attributes, functions, or executable instructions or statements.
How developers prevent this class of flaw
- For any externally-influenced input, check the input against an allowlist of acceptable values.
- Refactor the code so that it does not need to be dynamically managed.
More Improper Control of Dynamically-Managed Code Resources vulnerabilities (CWE-913)
Timeline
- CVE record published.
- CISA published its SSVC assessment (exploitation: none, automatable: no, technical impact: total).
- Record last changed materially (score, affected products, status or references).
References
Advisories
Patches and release notes
- github.com/keras-team/keras/pull/21602Issue Tracking
Other vulnerabilities in Keras
- 7.3 High severity
Recent Improper Control of Dynamically-Managed Code Resources vulnerabilities
- 9.1 Critical severity
- 9.9 Critical severity
- 7.5 High severity
- 9.8 Critical severity
- 8.5 High severity
- 8.8 High severity
Spotted an error? Tell us.