Python: fix(core): restrict unpickler module-prefix allowlist to types only - #5923
Merged
Evan Mattson (moonbox3) merged 4 commits intoJul 30, 2026
Conversation
Contributor
Author
|
@microsoft-github-policy-service agree |
Contributor
There was a problem hiding this comment.
Pull request overview
Tightens the Python checkpoint restricted unpickling boundary by preventing agent_framework.* and openai.types.* module-prefix allowlisting from returning non-type globals (e.g., functions/modules), mitigating gadget chains that can pivot via builtins.getattr.
Changes:
- Updates
_RestrictedUnpickler.find_classto resolve globals under allowed prefixes and permit them only if they are actualtypeobjects. - Adds a dedicated
UnpicklingErrormessage for blocked non-type globals from allowed prefixes.
HaoJun (White-Mouse)
force-pushed
the
fix/restricted-unpickler-non-type-globals
branch
from
June 2, 2026 16:52
f514068 to
04d425a
Compare
Contributor
|
HaoJun (@White-Mouse) thanks for your contribution. Is there an open issue we can link to? Additionally, please help to fix the merge conflict. |
HaoJun (White-Mouse)
force-pushed
the
fix/restricted-unpickler-non-type-globals
branch
from
July 10, 2026 05:17
04d425a to
b996da1
Compare
Contributor
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||
HaoJun (White-Mouse)
force-pushed
the
fix/restricted-unpickler-non-type-globals
branch
from
July 14, 2026 12:56
e255fd1 to
1bc4077
Compare
HaoJun (White-Mouse)
force-pushed
the
fix/restricted-unpickler-non-type-globals
branch
from
July 15, 2026 04:50
1bc4077 to
9dd038e
Compare
Contributor
|
Quick ping on this - let me know if you need help getting it across the finish line. Thank you. |
# Conflicts: # python/packages/core/agent_framework/_workflows/_checkpoint_encoding.py
Evan Mattson (moonbox3)
temporarily deployed
to
github-app-auth
July 30, 2026 10:35 — with
GitHub Actions
Inactive
Evan Mattson (moonbox3)
temporarily deployed
to
github-app-auth
July 30, 2026 10:36 — with
GitHub Actions
Inactive
Evan Mattson (moonbox3)
temporarily deployed
to
github-app-auth
July 30, 2026 10:38 — with
GitHub Actions
Inactive
Evan Mattson (moonbox3)
approved these changes
Jul 30, 2026
Evan Mattson (moonbox3)
enabled auto-merge
July 30, 2026 10:39
Eduard van Valkenburg (eavanvalkenburg)
approved these changes
Jul 30, 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.
Motivation & Context
The restricted checkpoint decoder allows framework and OpenAI SDK types by module prefix. The previous implementation returned any global from those modules, and the allowlisted
builtins.getattrcould also traverse attributes on an allowed type. Together, those behaviors allowed a crafted pickle to reach a non-type callable such as_RestrictedUnpickler.__init__.__globals__["pickle"].loadsbefore the post-deserialization type check.This change tightens that defense-in-depth path while preserving the checkpoint format and supported type reconstruction.
Description & Review Guide
type. During restricted unpickling,builtins.getattris replaced with a resolver that only permits type-to-type attribute lookup. Regression tests cover non-type globals, legitimate nested-type lookup, and the fullgetattr/__globals__/inner-pickle.loadschain.pickle.UnpicklingError.getattrreplacement and whether the regression coverage captures the expected nested-type reconstruction cases.Related Issue
Fixes #7432
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.