-
-
Notifications
You must be signed in to change notification settings - Fork 32k
UAF on fut->fut_{callback,context}0
with evil __getattribute__
in _asynciomodule.c
#125984
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
fut->fut_callback0
and an evil call_soon
in _asynciomodule.c
fut->fut_callback0
with evil call_soon
in _asynciomodule.c
should be an easy fix, just incref fut->fut_callback0 before usage here cpython/Modules/_asynciomodule.c Lines 412 to 418 in 417c130
|
Ah so there was an issue here as well! I wondered how to trigger it but I haven't considered the |
Might have to split this off into a broader issue (or just rename this one). Just figured out you can also corrupt fut_context0 (and possibly fut_loop if you can somehow get its refcount down to 0 before it calls call_soon). Here's a PoC with a UAF on fut_callback0 and fut_context0 import asyncio
class EvilLoop:
def call_soon(*args, **kwargs):
# might crash before this point
print(args, kwargs)
def get_debug(self):
return False
def __getattribute__(self, name):
if name == "call_soon":
x = lambda: ...
x.get_debug = lambda: False
fut.__init__(loop=x) # resets basically everything
print("returning get_soon fn after calling __init__")
return object.__getattribute__(self, name)
def __del__(self):
print("deleted", self)
class TrackDel:
def __init__(self, name):
self.name = name
def __del__(self):
print("deleted", self.name, self)
fut = asyncio.Future(loop=EvilLoop())
cb = TrackDel("cb obj")
ctx = TrackDel("ctx obj")
fut.add_done_callback(cb, context=ctx)
del cb, ctx
fut.set_result("kaboom") Output
You can see cb and ctx both got deleted but then get given to us as args we can access in |
fut->fut_callback0
with evil call_soon
in _asynciomodule.c
fut->fut_{callback,context}0
with evil call_soon
in _asynciomodule.c
fut->fut_{callback,context}0
with evil call_soon
in _asynciomodule.c
fut->fut_{callback,context}0
with evil __getattribute__
in _asynciomodule.c
I've opened a PR just for the callback/context and evil |
…o an evil `loop.__getattribute__` (#126003)
… due to an evil `loop.__getattribute__` (pythonGH-126003) (cherry picked from commit f819d43) Co-authored-by: Bénédikt Tran <[email protected]>
… due to an evil `loop.__getattribute__` (pythonGH-126003) (cherry picked from commit f819d43) Co-authored-by: Bénédikt Tran <[email protected]>
Closing since completed and backported. |
… due to an evil `loop.__getattribute__` (python#126003)
… due to an evil `loop.__getattribute__` (python#126003)
Crash report
What happened?
Originally posted by @Nico-Posada in #125970 (comment)
Not sure I'll be able to work on it today, so anyone's free to take on it.
Traceback
Linked PRs
fut->fut_{callback,context}0
due to an evilloop.__getattribute__
#126003fut->fut_{callback,context}0
due to an evilloop.__getattribute__
(GH-126003) #126043fut->fut_{callback,context}0
due to an evilloop.__getattribute__
(GH-126003) #126044The text was updated successfully, but these errors were encountered: