Skip to content

look up descriptor by objclass in _getattr instead of eval - #762

Open
alhudz wants to merge 1 commit into
uqfoundation:masterfrom
alhudz:getattr-drop-eval
Open

look up descriptor by objclass in _getattr instead of eval#762
alhudz wants to merge 1 commit into
uqfoundation:masterfrom
alhudz:getattr-drop-eval

Conversation

@alhudz

@alhudz alhudz commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

_getattr reconstructs slot/getset/method descriptors on unpickle.

Repro: _getattr(object, '__doc__"].count("zz") or setattr(__import__("dill"),"_pwned",True) or object.__dict__["__doc__', "x'x'x'object'x") runs the injected setattr; a crafted pickle reducing to _getattr reaches the same eval on load.
Cause: the fast path eval(attr+'.__dict__["'+name+'"]') evaluates a string built from the pickled repr_str/name; the except branch already returns the identical descriptor via objclass.__dict__[name].
Fix: drop the eval branch and always resolve through objclass. repr_str is now unused but kept in the signature so existing pickles still load.

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