Hook pickle Python fallbacks (GHSA-fphw-536r-4p88) - #307
Merged
Conversation
Lib/pickle.py defines _load/_loads/_Unpickler unconditionally and only shadows load/loads/Unpickler with the _pickle versions on a successful import. The underscore names stay bound to working unpicklers, calling them would bypass the hook.
There was a problem hiding this comment.
Looks good. Routing everything through _patch_entry_points is much better than the six hand-synced assignments - that's basically why the underscore ones got missed.
One thing: setUp calls run_hook(), so the test only covers that path, and the advisory was about always_check_safety. They share the patch function now so it's fine today, but nothing pins it. Maybe:
def test_always_check_safety_covers_all_entry_points(self):
hook.remove_hook()
hook.always_check_safety()
# same casesNothing blocking.
Collaborator
Author
|
Thanks! They have always been exactly the same, so I won't add a test for it. The most likely scenario would be a deprecation of |
arpitjain099
approved these changes
Jul 29, 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.
Lib/pickle.pydefines_load/_loads/_Unpicklerunconditionally and shadowsload/loads/Unpicklerwith the_pickleC implementation on a successful import. The underscore-prefixes ones remain bound to working unpicklers, so calling them could bypass the hook. Patch them too.Thanks to @arpitjain099 for the report!