Repository navigation
SEC check the type of a bound method's owner when loading it - #571
Open
adrinjalali wants to merge 3 commits into
Open
adrinjalali wants to merge 3 commits into
adrinjalali wants to merge 3 commits into
Conversation
MethodNode compared its declared type only with the declared type of its obj node. Several nodes build an object whose type does not follow their declared name, so a file could name a trusted owner while obj built e.g. a numpy array, and getattr then reached that object's attributes. Check the constructed object against the declared type before the attribute lookup.
Builds a crafted file that writes with ndarray.tofile under a trusted Pipeline name and loads it with the audit's own untrusted list, checking the load is refused and nothing is written. Test from gistrec's fix in the GHSA-xjg8-v5p3-f976 private fork. Also mention the ValueError and credit gistrec in the changelog. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Reference Issues/PRs
Extends the fix for CVE-2025-54413.
What does this implement/fix? Explain your changes.
MethodNode.__init__compares its declared__module__/__class__with the declared ones of itsobjnode, but both come from schema.json, and several nodes build an object whose type does not follow their declared name: an objectNdArrayNodealways builds an ndarray,PartialNodeafunctools.partial, a non-namedtupleTupleNodea plain tuple. A file can therefore name a trusted owner for a method whileobjbuilds an unrelated object, andgetattrthen reaches that object's attributes, e.g.ndarray.tofile, under the trusted name.MethodNode._constructnow checks the constructed object's module and class, computed the waymethod_get_staterecords them, against the declared type before the attribute lookup. Genuine bound methods, including ones inherited from a class in another module, still load.Any other comments?
Regression tests cover a tuple owner, the object-array
tofilevector (nothing is written), and a genuine bound method.