Skip to content

Prevent unbounded request body reads#759

Open
mikelolasagasti wants to merge 1 commit into
adnanh:masterfrom
mikelolasagasti:fix756
Open

Prevent unbounded request body reads#759
mikelolasagasti wants to merge 1 commit into
adnanh:masterfrom
mikelolasagasti:fix756

Conversation

@mikelolasagasti

Copy link
Copy Markdown

Add a -max-body-size flag with a 32 MiB default and allow 0 to preserve unlimited behavior. Return 413 for oversized requests and cover both rejection and normal request paths with tests.

Fixes #756

@moorereason

Copy link
Copy Markdown
Collaborator

I would set the default to 0 (unlimited) so that we don't introduce a breaking change.

A future major release could change the default to be non-zero.

@mikelolasagasti

Copy link
Copy Markdown
Author

I evaluated that as an option while creating the patch, but I think it's better to force a new release with the limitation by default.

Let's see if @adnanh review the patch and decides what's best. I don't mind to change if that allows this PR to be accepted.

@adnanh

adnanh commented Jul 20, 2026

Copy link
Copy Markdown
Owner

First, thanks for the contribution!

I agree with @moorereason, I've always tried hard to keep the default behavior consistent, even if it's not a good practice. The flag will be there, people can use it, we can recommend using it and maybe introduce a "this behavior will change in the future" warning, but it shouldn't definitely silently break after next release :-)

Add a -max-body-size flag to optionally limit request body reads and
return 413 for oversized requests.

Keep the default at 0 to preserve existing unlimited behavior, but warn
on startup when request body size is unlimited and document the
production recommendation to configure a positive limit.

Signed-off-by: Mikel Olasagasti Uranga <mikel@olasagasti.info>
@mikelolasagasti

Copy link
Copy Markdown
Author

Restored the unlimited default and added a warning at startup when maxBodySize is unlimited.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pre-authentication denial of service via unbounded request body read

3 participants