-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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
HTTP connection prematurely closed when unescaped space present in query string #13407
Comments
Using this bug it is possible to craft a denial of service attack when running Node behind an NGINX reverse proxy. NGINX treats the closed connection as though the server has gone offline. When requests crafted in this way are sent in rapid succession, NGINX may start returning HTTP 504 to all callers because there are "no live upstreams" left to service the request. The preferred behavior, in my opinion, would be to return an HTTP 400 instead of closing the connection. This seems to be the prevailing treatment on the interwebs. $ curl -v 'https://www.google.com/?s=foo &bar=baz'
> GET /?s=foo &bar=baz HTTP/1.1
> Host: www.google.com
> User-Agent: curl/7.51.0
> Accept: */*
>
< HTTP/1.0 400 Bad Request
< Content-Type: text/html; charset=UTF-8
< Referrer-Policy: no-referrer
< Content-Length: 1555
< Date: Fri, 02 Jun 2017 16:42:45 GMT
<
<!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
...
$ curl -v 'https://www.netflix.com?foo=bar &baz=qux'
> GET /?foo=bar &baz=qux HTTP/1.1
> Host: www.netflix.com
> User-Agent: curl/7.51.0
> Accept: */*
>
< HTTP/1.1 400 BAD_REQUEST
< Content-Length: 0
< Connection: Close
< |
Node.js won't do it for you but you can send a 400 response if you listen for the 'clientError' event on the server instance. There is an example in the documentation. |
Oh nice! Thanks! |
Is this is the correct way to handle this case? Or is it worth leaving this issue open? |
We're currently discussing whether to change the default behavior from 'close connection' to 'send 400 response and close connection'. This issue can stay open until that discussion is resolved. |
This was resolved in #15324 |
When handling an HTTP request with an unescaped space in the query string, the connection is prematurely closed.
Example
The text was updated successfully, but these errors were encountered: