Repository navigation
feat(artifacts): cap the size of a download from a URI - #251
Merged
Merged
Conversation
fakedev9999
requested changes
Nov 18, 2026
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.
Summary
Artifact::download_raw_from_uriandArtifact::download_raw_from_uri_partake a newmax_bytesargument. A larger artifact fails with the newArtifactTooLargeerror before the body is read.HEADrequest and from theGETresponse. The HTTPS path checksContent-Length, and it counts the bytes while it reads when the server sends no length.HEADbefore it sends aGET. Each range response must have status 206 and exactly the requested number of bytes, and the read stops at that number.ETagfromHEADasIf-Matchon each rangeGET. The download fails if the object changes afterHEAD.u64::MAX, so they have no limit, as before.Motivation
The cluster fulfiller and executor use these two functions to copy the program and the stdin of a request into cluster storage. They read the full artifact into memory. A requester controls the size of both artifacts, so one very large upload can use all the memory of the service. The service then restarts and reads the same artifact again.
With this argument, the fulfiller can refuse a program above 512 MiB (succinctlabs/sp1-cluster#217) before it reads the body.
Validation
Content-Length. A limit of 10 bytes passes and a limit of 9 bytes givesArtifactTooLarge.HEADgivesArtifactTooLarge, and noGETis sent.HEADgives an error. Before the fix, the download returned the first bytes of the new object.Caveats
sp1-clustercallsdownload_raw_from_uri_par, andsp1-cluster-privatecallsdownload_raw_from_uriin three places.If-Match, because that header never matches a weakETag.