GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||
GeezerVison is showing github.com — Restrict pickle deserialization to safe types (CVE-2025-69872) by a2811057970 · Pull Request #364 · grantjenks/python-diskcache ConversationSummaryMitigates 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. ApproachThis uses a
What's allowed
Everything else raises Breaking changeThis is intentionally a breaking change (version bumped to 6.0.0). Users caching custom types have two migration paths:
There is no opt-out by design — an escape hatch would just be cargo-culted by every downstream that hits an error. Downstream compatibility
Tests
Fixes CVE-2025-69872
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
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
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
|
There was an error while loading. Please reload this page.
|
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 [tool.poetry.dependencies] diskcache = { git = "https://github.com/mapped/python-diskcache", tag = "v6.0.2" } Poetry cannot override transitive dependencies by package name — if |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
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. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thank you for the safe-unpickler fix. We consume DiskCache transitively and are currently blocked by Could a maintainer review and merge this PR, then publish a release containing |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Vulnerability CVE-2025-69872
There was an error while loading. Please reload this page.