-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
Use-after-free in _asyncio_Future_remove_done_callback() of _asynciomodule.c #73149
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
There are two cases of use-after-free in the new Modules/_asynciomodule.c in the release candidate for Python 3.6, but I'm filing these together because it's the same underlying issue. In both cases in this file where the unsafe For example, this script can trigger the vulnerability for
On an ASAN build we can see that there is indeed a UAF occurring:
|
Oh, this is a release blocker. I'll take a look later today. |
I think the bug is only in _asyncio_Future_remove_done_callback, since future_schedule_callbacks makes a slice first, which cannot be mutated. I'm attaching a patch. Inada, would you be able to take a look? |
yselivanov, ah I think you're right. I misread that function after I noticed the issue in the first one. |
The bug requires to have an "evil" class which is unlikely in an application. I don't think that it's a release blocker. |
I see three options:
My favorite option is to work on a new list. |
Inada-san, thanks for the review. You're right, we need to fix another edge-case. I'll upload a new patch tomorrow. Victor, fourth option we should go with is to commit the attached patch (with Inada-san review comment fixed). I guess it's up to Ned if he want to cherry-pick the patch to Python 3.6. I agree that the bug is very unlikely to appear in any real-world code. |
_asyncio_Future_remove_done_callback() is still wrong with bpo-28963.patch: what if an evil __eq__() methods inserts or remove directly items of the future callbacks list? By design, it's not safe to iterate on a list if the body of the list calls arbitrary Python code. (I don't know how exactly, but everything in Python is possible, see the gc module to retrieve private fields of a C objecct.) |
This doesn't sound like a showstopper issue so I think it can wait for 3.6.1. |
3.6.0 had been released? |
I will in a couple of days. |
Misc/NEWS
so that it is managed by towncrier #552Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: