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
buffer overflow in socket.recvfrom_into #64445
Comments
recvfrom_into fails to check that the supplied buffer object is big enough for the requested read and so will happily write off the end. I will attach patches for 3.4 and 2.7, I'm not familiar with the backporting procedure to go further but all versions since 2.5 have this bug and while very highly unlikely it's technically remotely exploitable. Quickie trigger script, crash on interpreter exit: --------- BEGIN SEGFAULT --------- import socket
r, w = socket.socketpair()
w.send(b'X' * 1024)
r.recvfrom_into(bytearray(), 1024) |
Everything before 2.7 is already out of even security maintenance, so you've already checked off everything it will get fixed in. |
New changeset 87673659d8f7 by Benjamin Peterson in branch '2.7': New changeset 715fd3d8ac93 by Benjamin Peterson in branch '3.1': New changeset 9c56217e5c79 by Benjamin Peterson in branch '3.2': New changeset 7f176a45211f by Benjamin Peterson in branch '3.3': New changeset ead74e54d68f by Benjamin Peterson in branch 'default': New changeset 37ed85008f51 by Benjamin Peterson in branch 'default': |
One test fails on FreeBSD 9.0 and 6.4: ====================================================================== Traceback (most recent call last):
File "/usr/home/db3l/buildarea/3.x.bolen-freebsd/build/Lib/test/test_socket.py", line 259, in _tearDown
raise exc
File "/usr/home/db3l/buildarea/3.x.bolen-freebsd/build/Lib/test/test_socket.py", line 271, in clientRun
test_func()
File "/usr/home/db3l/buildarea/3.x.bolen-freebsd/build/Lib/test/test_socket.py", line 4690, in _testRecvFromIntoSmallBuffer
self.serv_conn.send(MSG*2048)
BrokenPipeError: [Errno 32] Broken pipe |
Perhaps the test is sending an infeasibly large message. If you remove the '*2048' does it pass? (I set up a FreeBSD 9.2 amd64 VM but all tests are passing here). |
MSG*1024 passes. I did not look at this issue: Would changing the value to 1024 |
The send part of the test doesn't matter, since what's being tested happens before any reads. The MSG multiplier should be removed completely, since none of the other tests do that. Patch attached. |
New changeset 5c4f4db8107c by Stefan Krah in branch '3.3': New changeset 9bbc3cc8ff4c by Stefan Krah in branch 'default': New changeset b6c5a37b221f by Stefan Krah in branch '2.7': |
Thanks Ryan. As you say, the original segfault is also triggered with the |
I just came across https://www.trustedsec.com/february-2014/python-remote-code-execution-socket-recvfrom_into/ . Now I wonder why this bug was neither reported to PSRT nor get a CVE number. It's a buffer overflow... I'm going to contact MITRE right away. |
Branch status: Vulnerable (last release prior to patch): Fixed (latest release post patch): So my reading is that 2.7.7 needs to be brought forward, and source only releases of 3.1.6 and 3.2.6 should be published. It also sounds like there's a missing trigger that automatically notifies PSRT when someone else classifies a bug as a security bug. |
Confirming the fix is in the 3.3.4 tag: http://hg.python.org/cpython/file/7ff62415e426/Lib/test/test_socket.py#l4539 And the 3.4rc1 tag: http://hg.python.org/cpython/file/5e088cea8660/Lib/test/test_socket.py#l4708 |
This issue has already been assigned CVE-2014-1912 Reference: http://www.openwall.com/lists/oss-security/2014/02/12/16 |
We don't currently have the capability to set an email trigger when the type is set to security. That should be submitted as a request on the meta tracker. (It will require a new reactor, which is easy, and a tweak to the database schema, which I don't offhand remember how to deploy, but it shouldn't be hard.) |
Is there an ETA for a 2.7.7 release with this fix? |
I notified security@python.org and waited for the go-ahead (from Guido I think) before opening this bug. If today is the first that the PSRT is hearing about this, then the issue is broader than just the bugtracker. |
Yes, your message reached PSRT on Jan 12th. |
Sorry, you are right and I was wrong. :( Your mail *was* delivered to PSRT. But it failed to reach me because I was having issues with my @python.org account. The server-side spam filter is now deactivated and I receive all mails again. |
A recently posted proof of concept exploit got a lot of attention: https://www.trustedsec.com/february-2014/python-remote-code-execution-socket-recvfrom_into/ I suggest some Python core developer should clarify here whether people running some publically available python based web service |
recvfrom_into() is hardly ever used, including in the stdlib itself. |
Antoine Pitrou:
Thank you for the quick clarification. Best regards, Peter. |
Can somebody backport the fixes for the test breakages to 3.1 and 3.2 please, it seems they were forgotten. The original CVE fix includes changes to test_socket.py so I cant imagine security-only-fix policy applies. Thanks! |
New changeset c25e1442529f by Stefan Krah in branch '3.1': New changeset e82dcd700e8c by Stefan Krah in branch '3.2': |
Thank you Stefan |
Note: 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: