/

CVE-2025-69872

Severity:

CRITICAL RISK

(9.8)

Code Injection / Unsafe Serialization in DiskCache

CVE-2025-69872

Deferred

Vulnerability type

Category:

Code Injection / Unsafe Serialization

CWE:

CWE-94, CWE-502

Impact:

Arbitrary Code Execution (Local/Adjacent via Cache Manipulation)

Severity:

CRITICAL RISK

(9.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

DiskCache (python-diskcache) uses Python's pickle module for serialization by default, allowing cached values to embed executable payloads.

If an attacker can write to the cache directory, they can plant malicious cache entries that trigger arbitrary code execution when a victim application later reads from the cache.

Affected context

This vulnerability affects Python applications that integrate DiskCache with its default pickle-based serializer and store cache data in locations where untrusted parties may gain write access.

The risk is most pronounced when:

  • Cache directories reside on shared or world-writable filesystems
  • Multiple users or services share the same cache path
  • Cache integrity is assumed but not enforced by the application

Exploit preconditions

  • Attack surface: Local or adjacent system level, via the filesystem that hosts the DiskCache cache directory.
  • Required access: Ability to create, modify, or replace cache files and directories used by DiskCache (e.g., through local user access, shared volume, or compromised service).
  • Trigger point: Any application code path that reads from DiskCache and deserializes cached objects using the default pickle-based serializer.
  • Why exploitation is possible: Pickle is a code-capable serialization format; deserializing attacker-controlled data can execute arbitrary Python code during unpickling, and DiskCache's default configuration trusts cache contents without integrity checks or isolation.

Why this happens

The core issue is the use of Python's pickle module as a default serialization mechanism for cache values without restricting who can write to the underlying cache store.

Pickle is inherently unsafe for untrusted data because it can embed object constructors and reduce functions that run code upon deserialization.

This maps to CWE-94: Improper Control of Generation of Code, as the application effectively allows untrusted serialized content to influence runtime behavior and execute attacker-specified operations when the cache is read.

Conceptually, the bug class is "unsafe, code-capable serialization of untrusted data" combined with implicit trust in the cache storage layer.

Potential impact

  • Execution of arbitrary Python code under the victim application's privileges
  • Reading, modifying, or deleting sensitive data accessible to the application
  • Installation of backdoors or persistence mechanisms within the application environment
  • Pivoting to other internal services or systems reachable from the compromised process
  • Complete takeover of the host user account running the affected application

General mitigation guidance

Effective mitigation focuses on reducing trust in cache storage and avoiding code-capable serialization formats for untrusted data:

  • Prefer non-executable serialization formats (e.g., JSON, msgpack, or custom safe encoders) instead of pickle for cache values.
  • Treat cache directories as sensitive assets and restrict write permissions to the application account only; avoid placing caches on shared or world-writable locations.
  • Introduce integrity protections (such as MACs or signatures) over cached content so that only data produced by trusted code is accepted.
  • Limit what types of objects are cached; favor simple, structured data instead of complex or callable objects that encourage pickle usage.
  • Run applications with least-privilege OS identities so that, even if cache-based code execution occurs, blast radius is constrained.

How teams detect issues like this

Organizations can look for this pattern by:

  • Static analysis rules that flag use of pickle (and libraries that wrap it by default) in contexts where data can be influenced by external or shared sources.
  • Code review checklists that question any use of executable serialization formats for caches, sessions, or IPC, especially when files are stored on shared volumes.
  • Configuration reviews ensuring that DiskCache (and similar libraries) are explicitly configured with safe serializers and that cache directories are not world-writable.
  • File integrity monitoring on cache directories to detect unexpected or untrusted modifications to cache files.
  • Use of automated dependency and configuration scanning tools that highlight packages with unsafe-by-default serialization behaviors.

Sources

SourceLink
github.comgithub.com/EthanKim88/ethan-cve-disclosures/blob/main/CVE-2025-69872-DiskCache-Pickle-Deserialization.md
github.comgithub.com/grantjenks/python-diskcache
access.redhat.comaccess.redhat.com/errata/RHSA-2026:36350
access.redhat.comaccess.redhat.com/errata/RHSA-2026:3713
access.redhat.comaccess.redhat.com/security/cve/CVE-2025-69872
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2439059
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2025/cve-2025-69872.json

Frequently asked

questions

Not directly in most setups. Exploitation typically requires the attacker to gain write access to the DiskCache directory, which is usually local or on a shared filesystem. However, remote compromise of another service that shares the cache storage can indirectly enable exploitation.

The attacker needs the ability to create or modify files in the DiskCache cache directory. This could come from a local user account, a misconfigured shared volume, or another compromised service that writes to the same cache location.

Replace pickle with a non-executable serialization format for all untrusted or potentially shared cache data, and ensure the cache directory is writable only by the trusted application user. Where possible, enforce integrity checks or tight filesystem permissions so only trusted writers can influence cache contents.

Adopt a design rule that code-capable serialization formats like pickle are never used on data that could be influenced outside a strictly controlled trust boundary. During design and code review, question assumptions about "internal" caches, enforce strict filesystem permissions, and standardize on safe serialization formats for configuration, caching, and inter-service data.

Find out what's already
exploitable in your codebase.