This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author demonia
Recipients demonia
Date 2021-04-12.13:17:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1618233428.41.0.905190325792.issue43813@roundup.psfhosted.org>
In-reply-to
Content
- Hello there, 2 days ago i discovered a DoS on http.server in python that allows me to take any python http.server down using less than 1k requests. i reported it to PSRT but they said i should report it here since http.server isn't for production. so here's the issue, in server.py http.server library has a really big value on the validation. and check if the first line of the request (method /path HTTP/VERSION) have more than 65k characters inside of it using `len()` function.

- In this case, the user is able to provide a method with 65k characters long and the server will accept it, if you send one request with this number of characters inside of the request using cURL. you will notice that the server could handle it. but after creating a big loop of 1k requests with the same characters. the server was taken down and didn't response again since it was trying to process this amount of data.

- Such an attack could be used to take down any python server running using http.server module. but since it's not for production like the documentations said the attack surface isn't that wide.

- To proof this issue, you can use this command while running your server on port 8080 or any port you just need to modify the command: for i in $(python3 -c "print('A\n'*10000)"); do curl -X $(python3 -c "print('A'*10000)") 'http://localhost:8080/404' ; done

- Then the server should be taken down after many requests, also, i managed to fix this issue from my side by adding characters validation on the code to avoid interacting with the long data many times. should i submit it here. or should i create a PR? PS, my fix doesn't change the main requestline validation int.
History
Date User Action Args
2021-04-12 13:17:08demoniasetrecipients: + demonia
2021-04-12 13:17:08demoniasetmessageid: <1618233428.41.0.905190325792.issue43813@roundup.psfhosted.org>
2021-04-12 13:17:08demonialinkissue43813 messages
2021-04-12 13:17:07demoniacreate