0

I received a burp scan result from my Rails app (hosted on heroku) that indicates that server is vulnerable to client-side desync attacks. The scan report reads as follows;

The server appears to be vulnerable to client-side desync attacks. A POST request was sent to the path '/get_started' with a second request sent as the body. The server ignored the Content-Length header and did not close the connection, leading to the smuggled request being interpreted as the next request.

The proposed remediation is as follows;

You can resolve this vulnerability by patching the server so that it either processes POST requests correctly, or closes the connection after handling them. You could also disable connection reuse entirely, but this may reduce performance. You can also resolve this issue by enabling HTTP/2.

I tried to opt for the solution of closing all requests to the server after handling them to prevent connection reuse. I tried this in a config file below;

class CloseConnectionMiddleware
  def initialize(app)
    @app = app
  end

  def call(env)
    if env['REQUEST_METHOD'] == 'POST'
      status, headers, body = @app.call(env)
      headers['Connection'] = 'close'
      [status, headers, body]
    else
      @app.call(env)
    end
  end
end

Rails.application.config.middleware.insert_before Rack::Sendfile, CloseConnectionMiddleware

The above seems to work on development but not in production (heroku) and I am stuck on finding a solution. I am looking for a solution that fits any of the proposed solutions in the report. Close the connection after handling the requests to disable connection reuse entirely or enabling http/2 in rails.

3
  • 1
    The issue is very likely not in your code, and you probably can't fix it in code. It's more like proxy configuration that allows HTTP request smuggling (another name of the same thing that might help you find a solution). In short, there's likely a proxy that relays information to your app server, and that proxy handles content-length and/or transfer-encoding differently than your app server (puma?). I think it's easiest to solve this in the proxy configuration, the proxy should close connections if you are ok with the performance degradation. Commented Mar 27, 2023 at 23:37
  • That code doesn't do anything to remedy the problem. You're sending an outgoing HTTP request to example.com which will do nothing except make your server start slightly slower. It has nothing to do with closing incoming http connections from the client. Commented Mar 28, 2023 at 11:23
  • Is it possible you are running on an old version of Puma? It seems that request smuggling issues were fixed a little while back as described at github.com/puma/puma/security/advisories/GHSA-h99w-9q5r-gjq9 Commented Apr 10, 2023 at 12:39

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.