# CVE-2025-12638: Path Traversal Vulnerability in keras-team/keras via Tar Archive Extraction in keras.utils.get_file()

> Attackers can write arbitrary files outside the cache directory via path traversal in Keras get_file(), potentially leading to code execution.

- **Severity:** High 8.0 (`CVSS:3.0/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 28 Nov 2025
- **Updated:** 28 Nov 2025
- **Also known as:** AZL-71185, DEBIAN-CVE-2025-12638, UBUNTU-CVE-2025-12638

## What is CVE-2025-12638?

CVE-2025-12638 is a high-severity path traversal vulnerability in keras-team/keras, published on 28 Nov 2025. Any signed-in user can exploit it over the network, and only if a user opens a file or follows a link.

### Official description

Keras version 3.11.3 is affected by a path traversal vulnerability in the keras.utils.get_file() function when extracting tar archives. The vulnerability arises because the function uses Python's tarfile.extractall() method without the security-critical filter='data' parameter. Although Keras attempts to filter unsafe paths using filter_safe_paths(), this filtering occurs before extraction, and a PATH_MAX symlink resolution bug triggers during extraction. This bug causes symlink resolution to fail due to path length limits, resulting in a security bypass that allows files to be written outside the intended extraction directory. This can lead to arbitrary file writes outside the cache directory, enabling potential system compromise or malicious code execution. The vulnerability affects Keras installations that process tar archives with get_file() and does not affect versions where this extraction method is secured with the appropriate filter parameter.

Weakness: CWE-22 (Improper Limitation of a Pathname to a Restricted Directory)

## Which versions are affected by CVE-2025-12638?


## How do I fix CVE-2025-12638?

Apply the vendor's patch.

## Is CVE-2025-12638 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2025-12638 exists.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2025-12638 and fix it if it is affected.

What it is: CVE-2025-12638 is a high-severity path traversal vulnerability in keras-team/keras, published on 28 Nov 2025. Any signed-in user can exploit it over the network, and only if a user opens a file or follows a link.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2025-12638 exists.

Affected product: keras-team/keras. No package-level version data is available, so check the vendor advisory linked from the reference page.

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2025-12638/ (Markdown: https://insights.sbomify.com/CVE-2025-12638/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2025-12638
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2025-12638
- OSV: https://osv.dev/vulnerability/CVE-2025-12638

---
From sbomify Insights: https://insights.sbomify.com/CVE-2025-12638/
Summaries are generated and may contain mistakes; the official description above is the record.
