SIGN IN SIGN UP

[Security] Fix RCE vulnerability in RestrictedUnpickler MRO check (#79057)

The _is_safe_class() function only checked the class's own __dict__ for
dangerous magic methods (__reduce__, __reduce_ex__, __getstate__, __setstate__).
It did NOT check the method resolution order (MRO), allowing classes that
inherit these methods from parent classes to bypass the safety check.

This fix checks all classes in the MRO (except object, whose default
__reduce__ is safe for user-defined classes) for dangerous method definitions.
S
sevenan2 committed
afc8af2cf7b3f50734864f5423ee49ededc6327d
Parent: a754a90
Committed by GitHub <noreply@github.com> on 5/22/2026, 3:48:38 AM