Repository navigation
Conversation
The prove endpoint buffered the entire request body into memory via hyper::body::to_bytes, with no cap on the body size. Since the service is bound on all interfaces and performs no authentication before reading the body, any client could stream an arbitrarily large chunked body and exhaust the service memory. Request bodies are now read through a size-limited reader that rejects oversized bodies with a 413, both from the declared body length and while streaming chunks of unknown length. The limit is configurable via max_request_body_size_bytes (1 MiB by default). Co-authored-by: Josh Lind <JoshLind@users.noreply.github.com>
JoshLind
marked this pull request as ready for review
August 12, 2026 21:17
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.
What is the change being pushed?
The prover service now enforces a maximum request body size when reading POST bodies. Oversized requests are rejected with a
413 Payload Too Largeinstead of being buffered into memory. The limit is configurable via a newmax_request_body_size_bytesconfig field (1 MiB by default).Why are you pushing this change?
This was reported for the pepper service in
aptos-core(keyless/pepper/service), but the prover service here has the identical flaw:POST /v0/provecalledhyper::body::to_bytes(request_body)to fully buffer the request body before JSON parsing, with noContent-Lengthcap and no streaming size limit.0.0.0.0with no access-control middleware, and no authentication precedes the body-buffering call.So any client that can reach the prover service port could stream an arbitrarily large
Transfer-Encoding: chunkedbody and exhaust process memory, crashing the service.How is this implemented?
handler::read_request_body_with_limit, which replaces the unboundedhyper::body::to_bytescall. It first rejects bodies whose declared length (fromBody::size_hint().upper(), i.e.Content-Length) already exceeds the limit, then reads the body chunk-by-chunk withHttpBody::data()and aborts as soon as the accumulated bytes would exceed the limit. This second check is what bounds chunked bodies of unknown length. The buffer is grown on demand and is never pre-allocated from the client-declared length.ProverServiceError::PayloadTooLargeandhandler::generate_payload_too_large_response, so oversized bodies return413while malformed bodies keep returning400.ProverServiceConfig::max_request_body_size_bytes, defaulting to 1 MiB. Existing config files keep working, since the field falls back to the default.400for invalid JSON), a body one byte over the limit (413), a streamed body of unknown length that is never fully read (413), and direct unit coverage of the limited reader.Note that
/v0/proveis the only POST endpoint on this service; bodies on other methods/paths are never buffered.Type of change
Prover service change?
Checklist
Slack Thread