Repository navigation
Conversation
Contributor
Pull request changelogAppAddedChangedDeprecatedRemovedFixedSecurityWebsiteAddedChangedDeprecatedRemovedFixedSecurityHostingAddedChangedDeprecatedRemovedFixedSecurity |
|
This pull request is closed, so it cannot be queued. Reopen it to get the box back. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix(api): enforce payload size limits in the shared readers
What
Two related bugs in
apps/labrinth/src/util/routes.rs:read_limited_from_payloadcheckedbytes.len() >= capbefore appending thenext chunk, so the last chunk could take the body past the cap by up to one chunk
(an image upload capped at 1 MiB could land above 1 MiB).
read_typed_from_payloadhad no cap at all. It buffered the entire request bodyinto
BytesMutbefore deserialising, andPOST /v3/reportis the caller, so areport body was read without any size limit.
Change
read_limited_from_payloadnow measuresbytes.len().saturating_add(item.len())before extending.
read_typed_from_payloadtakes acapand an error message and delegates toread_limited_from_payload.256 * 1024.Notes for reviewers
generous, but pick whatever matches how the endpoint is used in practice.
read_from_field(the multipart helper in the same module) already does thesaturating_addcomparison and did not need changing.Testing
read_limited_from_payloada 9-byte chunk followed by a 2-bytechunk with
cap = 10; the call must now fail instead of returning 11 bytes./v3/reportwith a body just under and just over 256 KiB andcheck the status codes.