Fix CVE-2025-69872: restrict pickle deserialization to safe types#1
Merged
Conversation
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
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…strictions Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
loopingrage
approved these changes
Jul 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Cherry-picks grantjenks#364 from upstream (unmaintained, owner not responding).
What changed
SafeUnpicklerreplacespickle.loadin exactly 3 call sites incore.py__reduce__-based RCE payloads regardless of filesystem permissionsmapped-diskcache, bumped to6.0.0v*tags, requiresPYPI_API_TOKENsecret)Breaking change
Users caching custom objects will get
UnpicklingErroron read. Migration: useJSONDiskor subclassDisk. For our use case (dvc-datacaches file metadata as dicts/primitives) the allowlist covers everything.🤖 Generated with Claude Code