Skip to content

Hook pickle Python fallbacks (GHSA-fphw-536r-4p88) - #307

Merged
thomas-chauchefoin-tob merged 3 commits into
masterfrom
fix-GHSA-fphw-536r-4p88
Jul 29, 2026
Merged

Hook pickle Python fallbacks (GHSA-fphw-536r-4p88) #307
thomas-chauchefoin-tob merged 3 commits into
masterfrom
fix-GHSA-fphw-536r-4p88

Conversation

@thomas-chauchefoin-tob

Copy link
Copy Markdown
Collaborator

Lib/pickle.py defines _load/_loads/_Unpickler unconditionally and shadows load/loads/Unpickler with the _pickle C 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!

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.

@arpitjain099 arpitjain099 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 cases

Nothing blocking.

@thomas-chauchefoin-tob

Copy link
Copy Markdown
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 always_check_safety() since fickling.hook is a better API.

@thomas-chauchefoin-tob
thomas-chauchefoin-tob merged commit 1991a6f into master Jul 29, 2026
11 checks passed
@thomas-chauchefoin-tob
thomas-chauchefoin-tob deleted the fix-GHSA-fphw-536r-4p88 branch July 29, 2026 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants