GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Restrict pickle deserialization to safe types (CVE-2025-69872) by a2811057970 · Pull Request #364 · grantjenks/python-diskcache

Conversation

@a2811057970

@a2811057970 a2811057970 commented Jul 3, 2026

Copy link
Copy Markdown

Summary

Mitigates CVE-2025-69872 by restricting pickle deserialization to a hardcoded allowlist of safe built-in types. Arbitrary objects can no longer be deserialized from cache, preventing code execution via crafted pickle payloads.

Approach

This uses a SafeUnpickler with an allowlist-based find_class override — a fundamentally different approach to #361 (HMAC envelope). The key difference:

  • HMAC (Mitigate CVE-2025-69872: HMAC-verified pickle envelope #361): still deserializes arbitrary types once the signature is valid. An attacker with read+write access to the cache directory can read the auto-generated key file and forge payloads.
  • Allowlist (this PR): blocks dangerous types regardless of filesystem access. No key management, no env vars, no file creation.

What's allowed

int, float, str, bytes, bytearray, list, dict, tuple, set, frozenset, complex, range, slice, object, bool, None, collections.OrderedDict, collections.defaultdict, collections.deque, datetime.*, decimal.Decimal, fractions.Fraction, uuid.UUID

Everything else raises UnpicklingError on read.

Breaking change

This is intentionally a breaking change (version bumped to 6.0.0). Users caching custom types have two migration paths:

  1. Use JSONDisk for JSON-serializable data
  2. Subclass Disk and override get()/fetch() with a custom serializer

There is no opt-out by design — an escape hatch would just be cargo-culted by every downstream that hits an error.

Downstream compatibility

UnpicklingError inherits from pickle.UnpicklingError so libraries that catch pickle.PickleError (e.g. dvc-data's translate_pickle_error decorator) handle it gracefully.

Tests

  • All 179 existing tests pass unchanged
  • 26 new security tests covering: safe type round-trips, exploit blocking (os.system, eval, subprocess, __reduce__), cache integration, no-escape-hatch verification, FanoutCache/Deque/Index
  • isort and blue pass

Fixes CVE-2025-69872
Closes #357, #360, #362

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

lhotakj reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@a2811057970
Restrict pickle deserialization to safe types (CVE-2025-69872)
50dc1fb
BREAKING CHANGE: Pickle deserialization now only permits safe built-in
types (builtins, collections, datetime, decimal, fractions, uuid).
Arbitrary objects can no longer be deserialized from cache, preventing
code execution via crafted pickle payloads.

Users caching custom types should migrate to JSONDisk or a custom Disk
subclass. There is no opt-out mechanism by design.

- Add SafeUnpickler with allowlist-based find_class override
- Add UnpicklingError (inherits pickle.UnpicklingError) for downstream
  compatibility with libraries catching pickle.PickleError
- Support pickle protocols 0-5 via __builtin__, copy_reg, and _codecs
  allowlist entries
- Use frozenset values in SAFE_PICKLE_CLASSES to prevent runtime bypass
- Bump version to 6.0.0 (breaking change per semver)

This takes a different approach to PR grantjenks#361 (HMAC envelope). The HMAC
approach still allows arbitrary deserialization once the signature is
verified, meaning an attacker with read+write access to the cache
directory can read the auto-generated key file and forge valid
payloads. The allowlist approach blocks dangerous types regardless of
filesystem access.

Fixes: CVE-2025-69872
Closes: grantjenks#357, grantjenks#360, grantjenks#362
@a2811057970

a2811057970 commented Jul 3, 2026

Copy link
Copy Markdown
Author

@grantjenks would appreciate a review when you get a chance. This is a minimal alternative to #361 for CVE-2025-69872 — 150 lines of additive code vs 1000+ lines, with stronger security guarantees (blocks dangerous types even if the attacker has full cache directory access).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Jul 6, 2026
Fix CVE-2025-69872: restrict pickle deserialization to safe types mapped/python-diskcache#1
Merged
docs(#868k5bbdr): Add fork notice — temporary CVE fix until upstream merges mapped/python-diskcache#5
Merged
@vavsab

vavsab commented Jul 6, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Thanks @a2811057970 for this fix!

While waiting for this to be merged and released, we created a fork with the patch applied.

uv (overrides the transitive dep — no direct dependency needed):

[tool.uv]
override-dependencies = ["diskcache>=6.0.0"]

[tool.uv.sources]
diskcache = { git = "https://github.com/mapped/python-diskcache", tag = "v6.0.2" }

Poetry (only works if diskcache is a direct dependency):

[tool.poetry.dependencies]
diskcache = { git = "https://github.com/mapped/python-diskcache", tag = "v6.0.2" }

Poetry cannot override transitive dependencies by package name — if diskcache is pulled in transitively, use uv instead.

a2811057970 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Jul 14, 2026
Vulnerability CVE-2025-69872 #357
Open
dvc-data dependency python-diskcache has critical vulnerability treeverse/dvc#11068
Open
@grantjenks

grantjenks commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Thanks for putting this together. I don’t intend to merge this PR as written.

The central problem is that the change restricts deserialization but not serialization. DiskCache will still successfully write an unsupported object and then fail when the same version tries to read it. That is a particularly surprising failure mode for a cache.

This also breaks existing uses of the Django backend involving functions, model instances, querysets, HttpResponse, and cookies. The linked fork handles those failures by changing the existing tests to expect UnpicklingError; that documents the regression but does not resolve it. Successful testing with one DVC pipeline is useful, but it does not establish general compatibility.

A safe-by-default major release may be reasonable, but it would need at least synchronous rejection of unsupported writes, an explicit trusted-pickle option, honest migration guidance, and complete integration testing. I’m not comfortable adopting a no-opt-out policy or redefining DiskCache’s supported data model through this PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JiangJiyang

JiangJiyang commented Jul 31, 2026

Copy link
Copy Markdown

Thank you for the safe-unpickler fix.

We consume DiskCache transitively and are currently blocked by
CVE-2025-69872 / GHSA-w8v5-vhqr-4h9v in dependency-security gates.

Could a maintainer review and merge this PR, then publish a release containing
the fix? A released version is needed for downstream users to clear the OSV
advisory. I can test a release candidate if helpful.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@scttfrdmn scttfrdmn mentioned this pull request Aug 3, 2026
fix: serialize cache values as JSON instead of pickle treeverse/dvc-data#663
Open
@shi00 shi00 mentioned this pull request Aug 23, 2026
chore(security): renegotiate CVE-2025-69872 (diskcache) allowlist expiry to 2026-11-23 shi00/qTrading#536
Merged
19 of 38 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Vulnerability CVE-2025-69872

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@a2811057970 @vavsab @grantjenks @JiangJiyang
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.