lua-http icon indicating copy to clipboard operation
lua-http copied to clipboard

Invalid request causes infinite loop on http.server

Open 1WHISKY opened this issue 10 months ago • 0 comments

Sending a malformed request to any http.server will cause it to indefinitely call the onstream function. How to replicate:

  1. run any http.server e.g. examples/server_hello.lua
  2. create the request: echo -e -n "GET / HTTP/1.1\r\n\r\n\r\n" > request The file will look like this:
$ hexdump -C request 
00000000  47 45 54 20 2f 20 48 54  54 50 2f 31 2e 31 0d 0a  |GET / HTTP/1.1..|
00000010  0d 0a 0d 0a                                       |....|
  1. send the request: nc 127.0.0.1 80 < request

The request will show up in the lua stdout and the server will respond as usual. However you will see that the connection in netcat has not been closed yet. If you now terminate netcat by pressing ctrl+c the server will indefinitely call the onstream callback.

Unfortunately I could not find a way to prevent this or block the request from outside the module. To me it looks like the server is still waiting for data?

1WHISKY avatar Feb 10 '25 22:02 1WHISKY