Skip to content
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 callback: Limit response body size to prevent excessive memory usage #138

Open
madflojo opened this issue Oct 13, 2024 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@madflojo
Copy link
Member

madflojo commented Oct 13, 2024

Limit response body size to prevent excessive memory usage

Reading the entire response body without limits can cause high memory consumption if the response is large, potentially leading to Denial of Service (DoS) attacks. Consider limiting the size of the response body read to prevent such issues.

Apply this diff to limit the response body size to 10 MB:

 body, err := io.ReadAll(response.Body)
+// Limit the response body to 10 MB
+body, err := io.ReadAll(io.LimitReader(response.Body, 10*1024*1024))

The above is a suggestion from CodeRabbit from a Pull Request Review, and I think it makes a lot of sense. I'm saving this to think about how I want to attack this: either a global max size, a definable size with the HTTP callback, or a combination of the two (probably this one).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

1 participant