-
Notifications
You must be signed in to change notification settings - Fork 52
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
Remediating a previously reported DoS #71
base: master
Are you sure you want to change the base?
Conversation
Reachable assertion DoS, affects most Nim web frameworks.
Is the assert there to avoid any potential major bugs, or is it just an artifact left over from development? Although httpbeast with the line deleted passes all tests, I want to make sure I'm not inserting any new bugs into the library. |
@the-emmon please be aware that |
@FedericoCeratto Hmm... If The only switches that seem to cause code to compile correctly are I may be missing something here. Would you be willing to verify my observation is accurate? |
@the-emmon - @FedericoCeratto is a bit wrong - You can verify this by checking the main Nim config file - https://github.com/nim-lang/Nim/blob/devel/config/nim.cfg#L56 - assertions are only disabled when |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this but I think we need to do something different here. This assertion failing indicates that the data sent by the client is invalid, so ideally we should respond to them accordingly instead of just ignoring the problem.
Can you change this to throw an exception an ensure it gets handled in the code which calls bodyInTransit? :)
After trying a handful of different approaches, including raising exceptions and sanitizing `Content-Length`, this seems to work the best. In addition to functional changes, the `trueLen` variable, set by the user-spoofable `Content-Length` header, has been renamed to `headerContentLength` to avoid confusion.
@Yardanico @dom96 After some reading, including all of the RFC documentation for HTTP 1.1, it seems like there is no great way to effectively respond to something like Because I was curious, I read documentation on how Apache deals with it. When given a larger header value than body data, Apache hangs and never replies, then kills the request after a certain amount of time... which is pretty much the same lousy solution that I proposed. Assuming Apache got it right and that's the best way to deal with an improper I greatly appreciate the time all of you have spent thus far in addressing this :) |
Hey @the-emmon, sorry for the late response from my side. Yeah, I would say that HttpBeast needs to handle timing out requests to be truly resilient to attacks. This is one of the reasons I still say to people to use HttpBeast/Jester behind nginx or another hardened HTTP server. The worry here is that we need to implement timeouts that won't affect the performance too much. We probably want a timeout per client and to have some efficient way to identify these clients and close their FD. |
Though seemingly small, this single line permits a CWE-617 DoS. With a request, an attacker can bring down any httpbeast-reliant framework, including Jester.
The vulnerability was found during secure code review, then triaged a few months ago by @FedericoCeratto.