-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
Security issue: how to avoid payload attacks for the HTTP server #9985
Comments
The So this is the job of whatever is reading the request body into memory. Arguably stdlib parsing things ( |
It might still be a good idea to install a limit in |
So, what's a reasonable default limit? |
Also |
Yeah, maybe
It should probably raise when a consumer tries to read over the limit.
What behaviour are you referring to? The signalling or the limiting itself? The limit can be set and disabled via server configuration. The signalling on enforced limit can't be overridden. You have to disable the limit instead. |
So, of course my actual point here is that there's a lot of application specific decision in here. |
I don't think so. Standalone webservers/load balancers like apache, nginx, traefik implement this. So it surely can work without application specific decisions. The only application specific setting is enabling this and the actual limit value. |
Of course, if you need more specific behaviour like dynamic limits based on request properties, you'll have to deactivate the server-wide configuration and implement your custom limit enforcement. But for most users, a standard behaviour with a good default value should really be all they need and it would be great to have this automatically included. |
This is very easy to implement or design: just check how Go (or any other web server) does it 😉 |
It seems Go's net/http server doesn't have this by default. You need to use MaxBytesReader in your handler. |
No need to have |
@j8r If you have an endpoint where you allow users to upload a file, you will most likely be using I think the way Go does it is great. You can control this in every endpoint you need it, probably only those that do stream a request somewhere... |
To clarify, that's why |
Shouldn't hitting a limit indicate an error rather than writing a truncated (possibly corrupt) file? |
To avoid payload attacks for the HTTP server, a configurable variable to limit the size of HTTP client body size is needed for each HTTP request. But I do not find it out from the
HTTP
module and all its sub-modules.There are
HTTP::MAX_REQUEST_LINE_SIZE
for request line andHTTP::MAX_HEADERS_SIZE
for headers already but none for request body yet.The well-known web frameworks
Kemal
,Amber
andLucky
in Crystal all use the std library for HTTP request parsing, and then they all have this security issue.I think this is a very important issue but it seems that no one has talken about it yet. Do I miss something for this issue?
How others fix this issue?
The text was updated successfully, but these errors were encountered: