-
Notifications
You must be signed in to change notification settings - Fork 102
Enforce size limit on POST /api/fleet/uploads
#6159
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
base: main
Are you sure you want to change the base?
Conversation
|
This pull request does not have a backport label. Could you fix it @ycombinator? 🙏
|
pzl
left a comment
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.
looks good
pointed out a few places where names or messages were unclear if it was describing large files (.i.e. a file itself being like 3GB with config set lower, and either rejecting file body bytes above that; or when reading this json file-description payload, looking at file.size property and rejecting for that limit). Whereas this is the limit placed on the total JSON payload body of file metadata / header.
The diff in isolation is clear which is being addressed, but down the road I can see this being an easy mixup, which thing is "too large": the file contents itself or the start / header payload.
Co-authored-by: Michel Laterman <82832767+michel-laterman@users.noreply.github.com>
michel-laterman
left a comment
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.
Do we also want to use the config vars for upload finailize and chunks?
Co-authored-by: Michel Laterman <82832767+michel-laterman@users.noreply.github.com>
Sure, I think this makes sense. Will update PR. |
Implemented request body size limit for upload finalize API in 3fbd7c7. For the upload chunk API, I'm seeing this check already: fleet-server/internal/pkg/api/handleUpload.go Lines 130 to 131 in acc7110
Do we need/want to do more? |
|
@pzl, should we allow for users to specify a custom value for file chunk size? |
Probably not a good idea without specific reason. This size was chosen quite specifically. A non-exhaustive list of concerns:
|
What is the problem this PR solves?
// Please do not just reference an issue. Explain WHAT the problem this PR solves here.
This PR prevents request bodies of arbitrarily large size to be sent to the
POST /api/fleet/uploadsAPI.How does this PR solve the problem?
// Explain HOW you solved the problem in your code. It is possible that during PR reviews this changes and then this section should be updated.
This PR checks the size of the request body sent to the
POST /api/fleet/uploadsAPI and, if it exceeds the configured limit, rejects the request, responding with an HTTP 413 Request Entity Too Large status code. By default, the limit is configured to 5MiB but can be overridden in the Fleet Server input configuration via theserver.limits.upload_start_limit.max_body_byte_sizesetting.How to test this PR locally
Design Checklist
Checklist
./changelog/fragmentsusing the changelog toolRelated issues