You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
EOF occurred in violation of protocol starting Python3.10 on large requests #110467
Looking a bit more closely, sending a body using a GET request is not supported by the HTTP standard. www.google.com is just forcefully closing the socket at some point because the request cannot be valid. The cutoff appears to be between 100KB and 1MB. While it could be interesting to look at the difference between Python 3.9 and Python 3.10 (and the version of OpenSSL used), nothing seems wrong here.
In urllib3, sending multiple gigabytes of data over OpenSSL is part of our test suite, and it does work well on Linux. (We do have an issue with that test being slow on macOS.)
To help understand the difference between Python3.9 and Python 3.10, SSLKEYLOGFILE can be used to decrypt the TLS traffic. I am using requests because it is convenient to use.
orange@32thread-server:~/project/pythonssleof$ python3.9 main.py
START send http.client.HTTPSConnection
[Errno 32] Broken pipe
START send requests.post
END send requests.post
orange@32thread-server:~/project/pythonssleof$ python3.10 main.py
START send http.client.HTTPSConnection
EOF occurred in violation of protocol (_ssl.c:2426)
START send requests.post
HTTPSConnectionPool(host='google.com', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:2426)')))
orange@32thread-server:~/project/pythonssleof$
Hello,
It seems that it is rather the right situation for an error to occur in the above test case situation.
Python 3.9 also encountered errors when sending large amounts of data to Google with HTTPS Connection. However, 'requests' does not cause an error. Python 3.10 is error in both transmission methods. This is not an error that occurred in python3.10, but simply seems to have failed to deal with exceptions in the implementation of requests or urlib3 as the type of exception changed.
In this regard, I think the problem is that requests in python3.9 version did not return the exception. Even in python 3.9, the data sent by the user through requests would have been interrupted without being fully transmitted. Users should also be aware that their data has not been sent successfully. This is vulnerable to tls truncation attack.
I think the original python 3.9 error format changed from 3.10 is the cause of the issue now. I need to investigate why the error type changed from 3.10. I'll check if there's a good reason for the change or if it's simply a side effect by the upgrade and upload the investigation back here.
Activity
hugovk commentedon Oct 6, 2023
This issue tracker is for CPython. This looks like a bug in either https://github.com/psf/requests or https://github.com/urllib3/urllib3, please report to one of their trackers.
3asm commentedon Oct 6, 2023
My mistake. Here is the same issue without
urllib3orrequests:No issue on Python3.9, crashes on 3.10 onward with the following statck trace:
hugovk commentedon Oct 8, 2023
Thanks, reopening as reproducible using the stdlib.
pquentin commentedon Oct 8, 2023
Is the same version of OpenSSL used with Python 3.9 and Python 3.10?
pquentin commentedon Oct 8, 2023
Looking a bit more closely, sending a body using a GET request is not supported by the HTTP standard. www.google.com is just forcefully closing the socket at some point because the request cannot be valid. The cutoff appears to be between 100KB and 1MB. While it could be interesting to look at the difference between Python 3.9 and Python 3.10 (and the version of OpenSSL used), nothing seems wrong here.
In urllib3, sending multiple gigabytes of data over OpenSSL is part of our test suite, and it does work well on Linux. (We do have an issue with that test being slow on macOS.)
pquentin commentedon Oct 8, 2023
The Python 3.10 release notes also mention changes around ssl.OP_IGNORE_UNEXPECTED_EOF that seem relevant.
3asm commentedon Oct 10, 2023
To help understand the difference between Python3.9 and Python 3.10,
SSLKEYLOGFILEcan be used to decrypt the TLS traffic. I am usingrequestsbecause it is convenient to use.The secrets.log can then be opened Wireshark, in Edit > Preferences > Protocols > TLS and set in (Pre)-Master-Secret log filename.
From the traffic, the TLS does break on Python 3.10.
narayanacharya6 commentedon Nov 6, 2023
Is there a way to solve this other than moving to a version of Python other than 3.10?
keepworking commentedon Jan 5, 2024
result :
Hello,
It seems that it is rather the right situation for an error to occur in the above test case situation.
Python 3.9 also encountered errors when sending large amounts of data to Google with HTTPS Connection. However, 'requests' does not cause an error. Python 3.10 is error in both transmission methods. This is not an error that occurred in python3.10, but simply seems to have failed to deal with exceptions in the implementation of requests or urlib3 as the type of exception changed.
In this regard, I think the problem is that requests in python3.9 version did not return the exception. Even in python 3.9, the data sent by the user through
requestswould have been interrupted without being fully transmitted. Users should also be aware that their data has not been sent successfully. This is vulnerable to tls truncation attack.ankitmaloo commentedon Jan 19, 2024
Now that this won't be picked up, is there a way we can circumvent it?
Like they have done here: websocket-client/websocket-client#942
I encountered the error while using Google API python client as it uses http.Client under the hood.
keepworking commentedon Jan 23, 2024
I think the original python 3.9 error format changed from 3.10 is the cause of the issue now. I need to investigate why the error type changed from 3.10. I'll check if there's a good reason for the change or if it's simply a side effect by the upgrade and upload the investigation back here.
15 remaining items
Bump Pulp squeezer to latest version
Bump Pulp squeezer to latest version
Bump Pulp squeezer to latest version
Bump Pulp squeezer to latest version
Bump Pulp squeezer to latest version
Bump Pulp squeezer to latest version
Bump Pulp squeezer to latest version
Bump Pulp squeezer to latest version
Bump Pulp squeezer to latest version
Bump Pulp squeezer to latest version
Bump Pulp squeezer to latest version
Bump Pulp squeezer to latest version
Bump Pulp squeezer to latest version
Bump Pulp squeezer to latest version
Add retry/backoff to YouTube credential check for transient SSL failures