Adding PUT functionality to http.server - Ideas - Discussions on Python.org
Adding PUT functionality to http.server Ideas cdiemel (Cdiemel) July 28, 2022, 5:36pm 1 The simple HTTP Server from the command line python3 -m http.server 80 only supports HEAD and GET requests. I believe it would be beneficial to also allow PUT requests to allow uploading to the folder where the http.server module was started. cdiemel (Cdiemel) July 28, 2022, 5:40pm 2 I have already pulled down the repository and made the changes locally and tested them to disallow directory traversal as well as allow saving into sub-folders.
When I went to created my pull request I was advised that a discussion needed to take place outside of the issue request. ericvsmith (Eric V. Smith) July 28, 2022, 6:16pm 3 I don’t think we want this functionality in the stdlib. The server is just for demo purposes, not to be seriously used. This seems too risky to me. 8 Likes steven.daprano (Steven D'Aprano) July 28, 2022, 10:11pm 4 Can you link to the PR please? cdiemel (Cdiemel) July 31, 2022, 12:56pm 5 Here is the link to the pull request.
GitHub - cdiemel/cpython-http-server-put: Add put/post to python http.server Security Concerns There is the possibility of trying to upload and run a reverse shell, however the simple HTTP server does not interpret any of the code, it reads it as text/bin then sends it out. I attempted to subvert the process and was only able to get it to serve me HTTP. I used the included PATH functionality and added a few checks in the PUT function to ensure that you cannot place files outside of the current DIR tree.
I tried various different versions of ../../ and ./../ and well as URL encoding to get files placed in odd places and was unable to get them outside of the directory tree I had created. I believe having PUT ability is no more risky than having GET ability and complements the already implemented GET function. cdiemel (Cdiemel) July 31, 2022, 1:03pm 6 (post deleted by author)