-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-134100: Fix UAF in PyImport_ImportModuleLevelObject #134117
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
Conversation
Not really sure how to add tests for this |
Use the repro from the issue for a test. |
Misc/NEWS.d/next/Core_and_Builtins/2025-05-16-17-25-52.gh-issue-134100.5-FbLK.rst
Outdated
Show resolved
Hide resolved
with self.assertRaisesRegex(KeyError, r"'a\.b+' not in sys\.modules as expected"): | ||
__import__(f"{loooong}.c", {"__package__": "a"}, level=1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with self.assertRaisesRegex(KeyError, r"'a\.b+' not in sys\.modules as expected"): | |
__import__(f"{loooong}.c", {"__package__": "a"}, level=1) | |
with self.assertRaisesRegex( | |
KeyError, | |
r"'a\.b+' not in sys\.modules as expected", | |
): | |
__import__(f"{loooong}.c", {"__package__": "a"}, | |
level=1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, with two little technicalities.
Misc/NEWS.d/next/Core_and_Builtins/2025-05-16-17-25-52.gh-issue-134100.5-FbLK.rst
Outdated
Show resolved
Hide resolved
Thanks @Nico-Posada for the PR, and @kumaraditya303 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
…ect` (pythonGH-134117) (cherry picked from commit 4e9005d) Co-authored-by: Nico-Posada <102486290+Nico-Posada@users.noreply.github.com>
GH-134171 is a backport of this pull request to the 3.14 branch. |
…ect` (pythonGH-134117) (cherry picked from commit 4e9005d) Co-authored-by: Nico-Posada <102486290+Nico-Posada@users.noreply.github.com>
GH-134172 is a backport of this pull request to the 3.13 branch. |
Decref after using
to_return
instead of before.PyImport_ImportModuleLevelObject
#134100