Skip to content

SEC check the type of a bound method's owner when loading it - #571

Open
adrinjalali wants to merge 3 commits into
skops-dev:mainfrom
adrinjalali:sec/methodnode-constructed-type
Open

adrinjalali wants to merge 3 commits into
skops-dev:mainfrom
adrinjalali:sec/methodnode-constructed-type

Conversation

@adrinjalali

Copy link
Copy Markdown
Member

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 its obj node, but both come from schema.json, and several nodes build an object whose type does not follow their declared name: an object NdArrayNode always builds an ndarray, PartialNode a functools.partial, a non-namedtuple TupleNode a plain tuple. A file can therefore name a trusted owner for a method while obj builds an unrelated object, and getattr then reaches that object's attributes, e.g. ndarray.tofile, under the trusted name.

MethodNode._construct now checks the constructed object's module and class, computed the way method_get_state records 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 tofile vector (nothing is written), and a genuine bound method.

adrinjalali and others added 3 commits November 29, 2026 11:23
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

No deployments
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.

1 participant