Description
Problem
The gateway reads a bundle manifest into memory with Gateway::manifest (crates/cli/src/commands/gateway.rs). That pull uses the gateway's normal --max-blob-mb (default 1 TiB). The 64 MiB MAX_MANIFEST_BYTES check runs only on the bytes already read.
So a request for /<hash>/<path> or /<hash>/, where <hash> is a large non-manifest blob, pays for about 64 MiB plus the pipe read-ahead before it fails with "the manifest is larger than 67108864 bytes". Anyone who can reach the gateway can make it spend the operator's funds this way, once for each distinct hash. Nothing caches the failed hash.
decdn get decdn:<hash>/<path> -o - has the same route and does not have this problem. Since #2467, fetch_entry_hash (crates/cli/src/commands/fetch.rs) clamps the manifest fetch's max_blob_mb to MAX_MANIFEST_MB. The streamer then clamps the size claim before it sizes the fill store, and the drive ends with a typed decdn_client::BlobTooLarge. So the lanes request no bytes past the cap.
Proposed fix
- In
start_pullfor a manifest, or in amanifest-specificBlobFetch, cloneself.commonand setmax_blob_mbtoMAX_MANIFEST_MB(0→ the cap, otherwisemin). This is the same clampfetch_entry_hashapplies. MakeMAX_MANIFEST_MBpub(crate). - Map
BlobTooLargefrom that pull to a 4xx response saying the blob is not a bundle manifest. A 502 is wrong here, because nothing upstream failed. - Optional: share the entry lookup with
fetch::entry_hash(bytes, path). TodayGateway::entryrepeats thefind(|e| e.path == path)+parse_hashsteps, and a malformed hash there does not name its entry. The gateway's not-found case answers with a 404, so the shared piece may only be the lookup on a parsedBundleManifest.
Test
The gateway tests drive pulls through the worker. A test that serves a blob larger than the cap for a manifest request should check that the request fails without the lanes requesting a range past MAX_MANIFEST_BYTES.
Follow-up from the #2467 review.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Projects
- StatusShow more project fieldsDone
Activity
fix(cli): name the raw blob only when the gateway serves it