CVE-2025-12638

8.0 HIGH

📋 TL;DR

This CVE describes a path traversal vulnerability in Keras 3.11.3's keras.utils.get_file() function when extracting tar archives. The vulnerability allows attackers to write files outside the intended extraction directory due to a symlink resolution bug during extraction. This affects any Keras installation that processes tar archives using the vulnerable get_file() function.

💻 Affected Systems

Products:
  • Keras
Versions: 3.11.3
Operating Systems: All platforms running Python
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects installations that use keras.utils.get_file() to extract tar archives from untrusted sources.

⚠️ Manual Verification Required

This CVE does not have specific version information in our database, so automatic vulnerability detection cannot determine if your system is affected.

Why? The CVE database entry doesn't specify which versions are vulnerable (no version ranges provided by the vendor/NVD).

🔒 Custom verification scripts are available for registered users. Sign up free to download automated test scripts.

Recommended Actions:
  1. Review the CVE details at NVD
  2. Check vendor security advisories for your specific version
  3. Test if the vulnerability is exploitable in your environment
  4. Consider updating to the latest version as a precaution

⚠️ Risk & Real-World Impact

🔴

Worst Case

Arbitrary file write leading to system compromise, privilege escalation, or remote code execution if combined with other vulnerabilities.

🟠

Likely Case

Arbitrary file write to sensitive locations, potentially enabling data corruption, denial of service, or persistence mechanisms.

🟢

If Mitigated

Limited to cache directory writes if proper sandboxing or containerization is implemented.

🌐 Internet-Facing: MEDIUM - Requires processing of attacker-controlled tar archives, which is less common in internet-facing applications.
🏢 Internal Only: MEDIUM - Internal systems processing user-uploaded archives or pulling from untrusted sources are at risk.

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: UNKNOWN
Unauthenticated Exploit: ✅ No
Complexity: MEDIUM

Exploitation requires the ability to supply a malicious tar archive to the vulnerable function.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 3.11.4 or later

Vendor Advisory: https://github.com/keras-team/keras/security/advisories

Restart Required: No

Instructions:

1. Update Keras using pip: pip install --upgrade keras
2. Verify the version is 3.11.4 or higher
3. No restart required as this is a Python library update

🔧 Temporary Workarounds

Disable tar extraction in get_file()

all

Avoid using keras.utils.get_file() with tar archives from untrusted sources.

# Modify code to use alternative extraction methods or validate archives

Use secure extraction wrapper

all

Implement a custom extraction function with proper security controls.

import tarfile
import os

def safe_extract(tar_path, extract_path):
    with tarfile.open(tar_path) as tar:
        for member in tar.getmembers():
            member_path = os.path.join(extract_path, member.name)
            if not os.path.realpath(member_path).startswith(os.path.realpath(extract_path)):
                raise ValueError('Path traversal attempt detected')
        tar.extractall(extract_path, filter='data')

🧯 If You Can't Patch

  • Avoid processing tar archives from untrusted sources with keras.utils.get_file()
  • Implement strict input validation and sandbox extraction to isolated directories

🔍 How to Verify

Check if Vulnerable:

Check if using Keras 3.11.3 and calling keras.utils.get_file() with tar archives.

Check Version:

python -c "import keras; print(keras.__version__)"

Verify Fix Applied:

Verify Keras version is 3.11.4 or higher and test tar extraction with malicious paths.

📡 Detection & Monitoring

Log Indicators:

  • Failed extraction attempts with path traversal errors
  • Unexpected file writes outside cache directories

Network Indicators:

  • Downloads of tar archives to Keras applications

SIEM Query:

Process execution logs showing keras.utils.get_file() calls with tar file arguments

🔗 References

📤 Share & Export