|
| 1 | +[agent] 2026-11-28: architecture refactor |
| 2 | + |
| 3 | +**`main`:** cfc870f. The run started at 04:55Z. |
| 4 | + |
| 5 | +### Chosen |
| 6 | +No PR this run. Three routine PRs are open (#2261, #2265, #2267), so step 3 applies: open none and verify leads instead. All three are `ready` and none has changed since 2026-11-26 (each `updated_at` is the same): none merged or closed, none has a review from a person, and no maintainer has commented on the discussion. The one comment on any issue since 02:50Z is another routine's on #2325. No `arch-audit` issue was opened by anyone else since #2328; #2329 is a `bughunt` issue for pip. |
| 7 | + |
| 8 | +The leads still marked `to verify` (L08, L13, L14, #1970) need Windows, scala-cli or a Docker daemon. So this run took an area no run under this charter had executed: the size and count limits of the readers, each asked what it does when a real package is over it. One limit is silent, and it led to a check that stops reading before the package managers do: filed as #2330. The other limits I ran or read say what they refuse. |
| 9 | + |
| 10 | +### PR |
| 11 | +None opened. #2261, #2265 and #2267 still await review. `main` has not moved from cfc870f. |
| 12 | + |
| 13 | +### Leads and issues |
| 14 | + |
| 15 | +**New: L63, filed as #2330.** `vendor --check`, `vex` and `repair` read a committed npm tarball through `shadowed_member` and `read_archive_from_reader` (core `patch/package.rs`, lines 204 and 284). The first is the check that the tarball holds no second entry an installer would extract over a patched file (`vendor_artifact_non_canonical`, from #2120). Both stop reading in three places where package managers read on, and raise no error: |
| 16 | + |
| 17 | +| Where a second `package/index.js` with the original bytes sits | Tarball on disk | `vendor --check`, `vex` | Installs the original file | |
| 18 | +|---|---|---|---| |
| 19 | +| right after the package's files (control) | 251 bytes | `vendor_artifact_non_canonical`, omitted | all four | |
| 20 | +| after padding files, exactly 64 MiB into the tar stream | 693 kB | verified, `not_affected` | npm 10.9.9, pnpm 10.28.0, Yarn 1.22.22, Bun 1.4.4 | |
| 21 | +| after the tar end-of-archive marker | 259 bytes | verified, `not_affected` | Yarn 1.22.22 | |
| 22 | +| in a second gzip member | 340 bytes | verified, `not_affected` | Yarn 1.22.22 | |
| 23 | + |
| 24 | +``` |
| 25 | +$ socket-patch vendor --check; echo "exit $?" |
| 26 | +pkg:npm/left-pad@1.3.0: committed artifact and wiring verified |
| 27 | +exit 0 |
| 28 | +$ socket-patch vex --output vex.json --product pkg:generic/app@1 |
| 29 | +Wrote OpenVEX document with 1 statement to vex.json (not_affected, "Patched via Socket patch … (vendored)") |
| 30 | +$ npm ci --ignore-scripts && node -p "require('left-pad')" |
| 31 | +ORIGINAL (vulnerable) |
| 32 | +``` |
| 33 | + |
| 34 | +After the install `vex` still attests the package and says to re-run the install. `vendor` says "already vendored" and `repair` finds nothing to restore. The lock integrity and the ledger's `sha256` and `size` were updated with the tarball in each row, as in the tampered states of the 20:56Z entry of 2026-11-26. |
| 35 | + |
| 36 | +The 64 MiB row is the size limit (`MAX_TOTAL_DECOMPRESSED_BYTES`, line 20). Both functions bound the gzip stream with `take(limit)`. The limit is a multiple of the tar block size, so it can fall between two entries, and there the tar parser takes the end of its input for the end of the archive. A twin of the unit test `shadowed_member_judges_only_the_listed_files` fails on `main`: |
| 37 | + |
| 38 | +``` |
| 39 | +boundary at the cap: shadowed_member = Ok(None); read_archive_bytes_to_map = Ok((7, Some("patched"))) |
| 40 | +boundary one block before the cap: shadowed_member = Err("archive I/O error: unexpected EOF during skip"); … |
| 41 | +control: 48 MiB of padding: shadowed_member = Ok(Some("index.js")); read_archive_bytes_to_map = Ok((7, Some("original"))) |
| 42 | +``` |
| 43 | + |
| 44 | +Every other bounded read in core takes one byte more than its limit and fails when it gets it (the wheel reader in `vendor/verify.rs`, line 801, and more than a dozen `take(MAX + 1)` sites). Three tar sites take exactly the limit: these two and `walk_tar_gz` (core `vendor/registry_fetch.rs`, line 1272, at 512 MiB). |
| 45 | + |
| 46 | +The same limit turns away an honest package, with a false reason. With an installed copy of 73.4 MB, the fixture service serves a tarball that holds the patched `package/index.js`, and: |
| 47 | + |
| 48 | +``` |
| 49 | +$ socket-patch vendor; echo "exit $?" |
| 50 | +Error: Failed to vendor pkg:npm/left-pad@1.3.0: prebuilt tarball for left-pad@1.3.0 does not carry the patched files at their recorded paths |
| 51 | +exit 1 |
| 52 | +``` |
| 53 | + |
| 54 | +`tgz_bytes_match_after_hashes` (core `vendor/npm_common.rs`, line 566) maps any reader error to `false`. Packages over 67.1 MB unpacked exist and have advisories: `next@13.5.6` (72.3 MB), `next@14.2.3` (86.2 MB), `next@15.1.0` (120.6 MB), `aws-sdk@2.1692.0` (98.2 MB), `plotly.js@2.25.2` (86.8 MB), from `npm view <pkg> dist.unpackedSize`. The limits were written for patch archives (#67: "Real socket-patch archives are tiny (kilobytes)"), and vendored mode later read whole package tarballs through them (#249). Whole packages have wider limits in `registry_fetch.rs` (512 MiB, 128 MiB an entry, 60,000 entries). Jars had the same pair of problems, and #2132 gave them their own limits and `vendor_artifact_too_large`. Hosted mode reads the served tarball through the same function for a Yarn 1 pin and for a Yarn Berry pin with a `bin:` map (read, not run): a package over the limit loses its patch with `npm_tarball_unavailable` or `npm_manifest_unavailable`. |
| 55 | + |
| 56 | +The planned fix: a bounded gzip reader that fails on the first byte past its limit, for the three tar sites; a second-entry check that reads every gzip member and past the end marker; a "too large" verdict for `vendor`, `vendor --check` and `vex`. Whether a vendored tarball should be read within the whole-package limits, so that `next` can be vendored, is a question in the issue. Not checked: whether the patch service serves a patch for a package of that size (the public patch API is not reachable from this sandbox); Yarn Berry; the wheel reader and `walk_tar_gz` beyond reading them. |
| 57 | + |
| 58 | +It joins the queue after #2287: a false VEX statement and a false check, which need someone who can commit a tarball, beside a false refusal that needs only a large package. |
| 59 | + |
| 60 | +**Seen and not filed:** |
| 61 | +- **A vendored wheel over 64 MiB or 10,000 entries** is refused by `vendor` with "prebuilt wheel for … does not carry the patched files at their recorded paths" (core `vendor/pypi.rs`, line 4129). Read, not run; named in #2330. The wheel reader cannot be read short: it goes by the zip directory and counts what it inflates. |
| 62 | +- **A copy of more than 10,000 files** (Go, Cargo, Composer, gem, vlt) vendors with the warning `vendor_inventory_unrecorded` ("drift in its unpatched files will not be detectable"). That is what the code says it does. |
| 63 | +- The Gradle script graph (512 files, 8 levels, 1 MiB a file) and the patch-package directory walk (10,000 entries, 16 levels) fail safe at their limits: the first records the build as unresolved, the second protects every npm package. Read, not run. |
| 64 | + |
| 65 | +**L08, L13, L14, #1970:** still to verify. They need Windows, scala-cli or Docker. |
| 66 | + |
| 67 | +### Areas examined |
| 68 | +All with the binary built from `main`. |
| 69 | + |
| 70 | +- **The readers of a vendored npm tarball against four installers.** A project vendored through the repository's fixture service (`package-lock.json`, and a second one with a Yarn 1 lock), then the tarball changed in five ways with every recorded hash updated: #2330. `vendor --check`, `vex`, `list` and `repair --dry-run` over each, then `npm ci` or `yarn install --frozen-lockfile`; `vendor` and a wet `repair` over the 64 MiB one. The four tarballs that matter were also installed as a `file:` dependency by npm, pnpm, Yarn 1 and Bun into empty projects with empty caches. |
| 71 | +- **Vendoring a package over the limit**, 73.4 MB in seven files: #2330. |
| 72 | +- **Agent mode over large inputs.** A patched file of 20 MB, 70 MB and 300 MB, and a package of 12,000 files, each through `apply`, `apply --check`, `vex`, `rollback` and `apply --check` again. Every run patches, verifies, attests and restores. Agent mode reads no archive and has no limit of this kind. |
| 73 | +- **Read, not run:** the other limits in core (about 110 named constants). The ones a real project can reach are above; the rest bound a download, a count of warnings, or a walk that fails safe. |
| 74 | + |
| 75 | +### Lessons |
| 76 | +- **Ask each limit what it does at the limit, not past it.** One block before the limit the reader fails and one block past it fails; exactly at it the archive ends early and everything looks right. `take(limit)` over a stream of fixed-size records has that hole wherever the limit is a multiple of the record size. The idiom the rest of the code uses, `take(limit + 1)` and a check, has none: `grep -rn '\.take(MAX_'` lists the sites, and the ones without `+ 1` are the leads. |
| 77 | +- **A check that models an installer has to stop where the installer stops.** The comment on `shadowed_member` lists three things installers do that the decoder does not. Each thing the decoder stops at (a size limit, a zero block, the end of a gzip member) is a fourth, fifth and sixth. For any "what gets installed" check, list where the reader stops and install a file that continues past each stop with every package manager on the machine. It took ten minutes: four tarballs, four installers, `require()`. |
| 78 | +- **npm's tar refuses a tarball that inflates more than 1000:1** (`TAR_ABORT: max decompression ratio exceeded`). Padding made of zeros trips it. Thirty-two random bytes in every 4 KiB compress about 100:1 and pass. |
| 79 | +- **Yarn 1 reads past the tar end-of-archive marker and into a second gzip member; npm 10.9, pnpm 10.28 and Bun 1.4 do not.** Any reader here that judges a tarball for Yarn 1 has to read on as well. |
| 80 | +- **A limit's comment says what it was written for.** "Real socket-patch archives are tiny" sits above a limit that now reads whole packages. `git log -S` on the constant and on its newest caller gave the two PRs between which the meaning changed. |
| 81 | +- **The fixture service builds its package from an installed copy** when the project has one under `node_modules/`. Five 14 MiB files there make a served tarball over the limit; no network and no real large package is needed. Stop the holder test before the last quoted run: a stopped service turns every later `vendor` into a connection error. |
| 82 | +- **`npm view <pkg> dist.unpackedSize dist.fileCount`** answers "does a real package reach this" in a second. The npm registry is reachable from this sandbox; the public patch API is not. |
| 83 | +- A loop that prints `$?` after a pipe prints the status of the pipe's last command. Use `${PIPESTATUS[0]}`, or do not quote the status. |
| 84 | +- The hunt took 24 minutes of wall time: reading the limits ten, the probe test and the fixture service six (three builds), the matrix and the installers eight. |
| 85 | +- The register was at 11,975 characters and is at 11,987. L63 joined the collapsed `filed` row and the area joined the third Areas row. To make room, the Next PR line, two Areas cells and two notes are shorter. The sandbox note now says the public patch API is out of reach. |
| 86 | +- The owner was notified of #2330. |
| 87 | + |
| 88 | +### Needs a person |
| 89 | +- **#2330: `vendor --check` and `vex` pass a tampered vendored npm tarball**, and vendored mode refuses any package over 64 MiB unpacked (`next` 13.5 and later) with a message that blames the patch service. The issue is public and describes a way past a tamper check; a maintainer who wants that handled privately should edit or move it. Its last point asks whether a vendored tarball should be read within the whole-package limits. |
| 90 | +- **Review #2261, #2265 and #2267.** This is the twenty-fifth run in a row that could only verify leads. |
| 91 | +- **#2270** still blocks `ci-ok` on every PR; #2280 is open for it. |
| 92 | +- **#2309, #2277 and #2297 need an answer.** **#2299** and **#2315** each ask which of two fixes a maintainer prefers. |
| 93 | +- Thirty-three confirmed problems wait for a slot. #2301, #2303, #2305, #2308, #2310, #2312 with #2314, #2317, #2287, #2330, #2290, #2299, #2327, #2318, #2321, #2286, #2289 and #2315 go first, then #2259, #2294, #2296, #2271, L22 (after #2261), #647, #1917, #1926, #1860 beside #2271, #1836, #2306, #2322, #2324, #2328 and #2319. |
0 commit comments