Repository navigation
Raise the tarball and wheel size limits, and make a limit an error instead of an end of archive (#2197) - #2410
Draft
Mikola Lysenko (mikolalysenko) wants to merge 5 commits into
Draft
Mikola Lysenko (mikolalysenko) wants to merge 5 commits into
Mikola Lysenko (mikolalysenko) wants to merge 5 commits into
Conversation
…it an error The tarball reader (npm tarballs, Python sdists) and the zip reader of the vendored-artifact checks (wheels, .nupkg) were sized for patch archives: 64 MiB unpacked, 10,000 entries, 16 MiB for one tarball member. They read whole packages now. A wheel with one compiled extension of 60 MiB, or an npm package of 31,858 files, could not be vendored or checked, and `vendor` said the service's archive "does not carry the patched files" (#2197). Both readers now take their limits from one place, `patch::archive_limits`: 200,000 entries, 512 MiB inflated in one read, and no more than 100 times the archive's own size once past the 64 MiB every archive may still use. The module docs give the packages the numbers were measured on. A member may be as large as what is left of its archive's budget; the tarball reader checks the declared size against that before it allocates. Both readers still hold what they inflate, so 512 MiB plus the archive is what reading one archive may take. Reaching a limit is now an error, never the end of the input (#2330). The tarball reader bounded the gzip stream with `Read::take`, which hands the tar parser an end of input at the limit. Between two entries the parser takes that for the end of the archive, so a second `package/index.js` placed exactly 64 MiB into the stream was never seen by the check for a second entry over a patched file, and the tarball verified. The stream is now read through a reader that fails on the first byte past the budget, and the walk reports that failure whatever the parser made of it. An archive past a limit says which limit, and what it holds or unpacks to where its own headers say: - `vendor --check`, `vex` and `repair` report a committed tarball, wheel, sdist or .nupkg as `vendor_artifact_too_large` (it was `vendor_artifact_unreadable`), and `vendor --check` names the limit. - `vendor` refuses a served Python distribution with `vendor_artifact_too_large`, and fails an npm package with "the patch service's tarball for <name>@<version> cannot be checked: <limit>". - `repair` reports a download past a limit the way it does for a jar. Three jar tests asserted that the wheel reader refuses a jar of 10,001 entries and 65 MiB; it reads one now, and the assertions are gone. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…r every archive `vex` words `vendor_artifact_too_large` for any vendored artifact now, not for a jar alone, and gives both sets of limits. Three tests in the vendor suite run the binary against the fixture patch service: - A package of 73 MiB in files of 14 MiB is vendored and checks clean. It failed with "does not carry the patched files". - A served tarball of some 80 KiB that unpacks to 80 MiB fails with a message that names the limit and what the tarball unpacks to, and nothing is committed. - A committed tarball with a second `package/index.js` exactly 64 MiB into its tar stream, its ledger fingerprint and lock integrity matching, fails `vendor --check` with `vendor_artifact_non_canonical`; it verified before (#2330). The same tarball without the second entry checks clean, and one past a limit fails with `vendor_artifact_too_large` and the limit named. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…d wheels The CLI contract gains an "Archive limits" paragraph under the vendor command: the limits an npm tarball, a Python wheel or sdist and a .nupkg are read within, what each command reports for an archive past one, the packages the limits were measured on, and the two measured wheels that stay refused. The `vendor_artifact_too_large` row no longer says the tag is for jars only. The usage guide states the limits in its vendoring section. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… short The tarball extractor of `vendor::registry_fetch` (registry tarballs, crates, the data archive of a gem, the tarball of a vlt directory) bounded the gzip stream at 512 MiB with `Read::take`. A reader that stops at its limit hands the tar parser an end of input, and between two entries the parser takes that for the end of the archive: the files before the cap were written, the ones after it were not, and the extraction returned success. A package cut short was then judged by the files it did hold. The stream is now read through the reader that fails on the first byte past the cap, as the zip extractors beside it already count what they inflate: "tarball decompresses past the 536870912-byte cap". The caps themselves are unchanged. This is the third `take(limit)` site named in #2330; the other two are the tarball readers of `patch::package`. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…read `vendor --check`, `vex` and `repair` refuse a committed npm tarball that holds a second entry an installer would extract over a patched file (`vendor_artifact_non_canonical`). The check ended a tarball where this crate's tar reader does, at the first all-zero block of the first gzip member. The installers read further, so a second `package/index.js` placed past that point verified here and installed the original (#2330). Measured with a tarball installed as a `file:` dependency: - npm 11.19.1 takes an entry that follows a single zero block (it ends an archive at two), passing over a block that is no tar header with a warning, and one in a second gzip member when the first has no end-of-archive marker. - Yarn 1.22.19 takes those, and an entry after the marker or in a second gzip member after it. The check now judges every entry up to the first zero block as before (an entry that cannot be read there still fails it), and then every entry after it: past zero blocks and blocks that are no header, to the end of the gzip member and through each member that follows. Nothing in that part fails the check for being unreadable, so a tarball with padding or other bytes after its marker verifies as it did. The limits count what is inflated there, and a limit that is met there is the same error. The reader that decodes the members for hashing is unchanged: it reads what it read, and the check above is what answers for the rest. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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.
Fixes #2197. Fixes the read-short parts of #2330.
The problem
Two readers decode a whole archive into memory: the tarball reader (npm tarballs, Python sdists) and the zip reader of the vendored-artifact checks (wheels,
.nupkg). Both were sized for patch archives of a few kilobytes: 64 MiB unpacked, 10,000 entries, 16 MiB for one tarball member. They read whole packages now, and released packages are larger, so a patch for one could not be vendored or checked, while a jar of the same size was accepted (200,000 entries, 1 GiB).Worse, the tarball reader stopped at its limit with
Read::take. The tar parser takes an end of input between two entries for the end of the archive, so every entry past 64 MiB was never seen and no error was raised (#2330).vendor --checkandvexthen verified a tarball whose secondpackage/index.js, the one an installer extracts last, sat past the limit.What changes
One set of limits for both readers (
patch/archive_limits.rs): 200,000 entries, 512 MiB inflated, and no more than 100 times the archive's own size once past 64 MiB. Nothing that was read whole before is refused now. There is no separate limit on one member: a member may be as large as what is left of its archive's budget, checked against its declared size before anything is allocated.Measured packages (wheels from their zip directories, tarballs streamed, nothing extracted):
next15.1.0@mui/icons-material6.2.1@next/swc-linux-x64-gnu15.1.0onnxruntime-node1.20.1ansible11.1.0 (wheel)xgboost2.1.3 (wheel)paddlepaddle2.6.2 (wheel)mkl2025.0.1 (wheel)tensorflow-cpu2.18.0 (wheel)The last two stay refused. 512 MiB and not the jar reader's 1 GiB because these readers hold what they inflate, while the jar reader holds a digest per member.
A limit is an error. A new
Boundedreader fails on the first byte past the budget, in the two tarball readers and in the registry extractor (which used to write a tree short of the files past its cap and return success). The error names the limit and what the archive holds:it unpacks to 946 MiB, over the limit of 512 MiB for one archive,it holds 200001 entries, over the limit of 200000. A committed archive over a limit isvendor_artifact_too_large(it wasvendor_artifact_unreadable, or verified).The check for a second entry over a patched file reads as far as the installers do (last commit, separable). Probed with npm 11.19.1 and Yarn 1.22.19 on tarballs installed as
file:dependencies:package/index.jsplacedTAR_ENTRY_INVALID)Before this change
vendor --checkandvexverified all five. The first three reach npm itself, which #2330 lists only for Yarn 1 or not at all. The check now reads on past zero blocks and non-header blocks, through every gzip member; nothing in that tail fails for being unreadable, so the only new refusals are a real second entry or a limit met there.What it does not change
applyandget: they do not use these readers since v5 removed the diff-archive path, so the issue's "patch package / diff archives" row is about what now reads whole npm tarballs and sdists.vendorreuses or re-downloads a committed tarball still stops at the first zero block, so a re-run ofvendorwould reuse a tarball thatvendor --checkandvexnow refuse. Left for a follow-up..nupkgand jar blob harvest.For the maintainers to decide
mklandtensorflow-cpu. Raising it is one constant, but reading only the members a check needs (streaming) should come first: peak memory is the archive plus what it inflates.xgboostwith 7% headroom and refuse_catboost.so(281.9 MiB).socket-patch repair" is wrong for an honest oversize artifact: the re-download is refused the same way. Jars have the same wording today.apply_failed; only the detail names the limit.ArchiveError::EntryTooLargeandTooManyEntriesvariants are replaced byTooLarge(String). Nothing in the workspace used them.Tests
tests/vendor/vendor_failure_paths.rs): a 73 MiB package is vendored and checked; a served tarball past what its size allows is refused as too large;vendor --checksees a second entry where the old limit fell, and past the first zero block and gzip member.cargo fmt --check,cargo clippy --workspace --all-features -- -D warnings, core lib (8,690 passed), the CLI lib and 19 CLI test binaries covering vendor, repair, vex, the takeover suites and mode migration (all passed). Not run: Windows, and pnpm and Bun were not probed for the tail shapes.🤖 Generated with Claude Code