Repository navigation
zola, nushell: fetch crates before loading the getrandom shim - #1326
Conversation
Both builds preloaded the deterministic getrandom/getentropy shim over a plain `cargo build --locked`, which also fetches crates, so cargo's TLS ran on the shim's fixed bytes. Fetch first with real entropy (`cargo fetch --locked`), then preload only the offline `cargo build --frozen`, as codex does (#878). nushell has the network through `rust` (needs.internet), zola declares it itself. No build script in either dependency graph downloads (every build script of every registry crate in both Cargo.locks scanned), so the frozen build needs no network. Output is unaffected: the same locked crates compile the same way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reached
This review includes 2 billable files and costs up to $0.50.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 52 minutes for your next included review. View limit details
|
norrietaylor
left a comment
There was a problem hiding this comment.
Scope matches the title. Two build scripts change, and every hunk traces to the fetch-first change for #974. The zola comment move is part of that change.
Clobber none. git log on both files shows the CVE-2026-111943 lock patch from #955 as the last earlier change. Both scripts keep that patch and its checks, and cargo fetch --locked runs after them, so the fetch uses the patched lock.
Correctness the change is good. The order matches packages/codex/build.sh:56-81. nushell has the network through rust, which declares dns and internet at packages/rust/build.ncl:48-52. The lock patches change only versions and checksums in the lines I read, so they add no new crate to the audited graph.
The three findings are low or nit. Two are about comments, and one is about a missing guard.
Residual risk the claim that no build script downloads is a point-in-time audit for 0.23.6 and 0.116.1. Nothing fails closed on a version bump, and --frozen does not stop a build.rs. Repeat the audit when these packages change version, or convert them to detbuild.
Not checked I did not build, by instruction, so the claim that output bytes do not change is unverified. I could not reproduce the 1,389-crate audit, because the request for the upstream Cargo.lock files was denied. gitleaks was not run. I read the diff, and it holds no credential. No dependency manifest changed.
| SHIM | ||
| gcc -shared -fPIC -O2 -o /tmp/detrand.so /tmp/detrand.c | ||
| LD_PRELOAD=/tmp/detrand.so cargo build --locked --release | ||
| LD_PRELOAD=/tmp/detrand.so cargo build --frozen --release |
There was a problem hiding this comment.
low · This fix has no regression guard, so a later edit can restore cargo build --locked under the shim without a failure. detbuild_preload_guard.py matches only libdetbuild.so, so it skips /tmp/detrand.so here and /tmp/libdetrand.so at packages/nushell/build.sh:71. The negative control in the PR body ran once and is not committed. The same gap applies to codex and verus-latest. Convert these packages to detbuild, or extend the guard to match the inline shims.
| # Deterministic build-time entropy (the guide's prescribed shim): interposes | ||
| # getrandom/getentropy so build.rs / proc-macro / rustc-internal HashMaps | ||
| # iterate identically every build. Runtime binary is unaffected. It wraps only | ||
| # the offline BUILD: `--frozen` refuses any network access. |
There was a problem hiding this comment.
low · The comment says --frozen refuses any network access. That is true for cargo only. A build.rs can still download under the shim, and .github/scripts/detbuild_preload_guard.py:54-57 says so. The next reader can take this line as proof that the shimmed step is offline, but only the version-specific audit supports that. packages/nushell/build.sh:70 has the same wording, and packages/codex/build.sh:67 is the existing source of it. Write that --frozen stops cargo from fetching.
| # Scope the shim to the cargo build only — no global export/unset window. | ||
| LD_PRELOAD=/tmp/libdetrand.so cargo build --locked --release | ||
| # Scope the shim to the cargo build only — no global export/unset window — and | ||
| # keep that build offline: `--frozen` refuses any network access. |
There was a problem hiding this comment.
nit · This PR moves the zola shim explanation down to the shim, but the nushell explanation stays at lines 24-30. That text now sits above the CVE block and about 25 lines from the shim, with the new fetch block also between them. Move it to line 54 so that the two scripts have the same layout.
Fixes #974.
zola and nushell preloaded their deterministic getrandom/getentropy shim over a plain
cargo build --locked. That command also downloads crates, so cargo's TLS sessions ran on the shim's fixed bytes. Both now follow the codex pattern from #878:cargo fetch --lockedruns first, with no shim and real entropy, and the shim is preloaded only oncargo build --frozen --release, which cannot use the network. Each package keeps its own inline shim. Converting them todetbuild(#884) is left for a follow-up.Both builds have the network. zola declares
needs.internetitself. nushell gets it throughrust, which declares it, so nushell's build is networked although its own build.ncl has noneeds.Build scripts that download: I took every registry crate in zola 0.23.6's and nushell 0.116.1's Cargo.lock (1,389 crates, all platforms, no git dependencies), downloaded each
.cratefrom crates.io, and searched every build script for network access, including custombuild =paths such as aws-lc-sys'sbuilder/. None downloads anything. curl-sys and libgit2-sys rungit submodule updateonly when their vendored C source is missing, which never happens for a registry crate. A few others callgitfor local metadata only. So noRUSTY_V8_ARCHIVE-style fail-closed or pinnedSourceis needed.The other two shim carriers named in the #884 review:
cargo fetch --lockedunshimmed, thenLD_PRELOAD=... cargo build --frozen, and fails closed on rusty_v8 withRUSTY_V8_ARCHIVE=/nonexistent/.... No change.git's runtime dependencycurldeclaresneeds.internet. Its preloaded steps are offline anyway. Every crate comes from the sha256-pinned vendor tarball through[source.crates-io] replace-with = "vendored-sources", andCARGO_NET_OFFLINE=trueis exported for both the preloadedcargo buildand thecargo run -p cargo-verusthat invokes cargo again. I scanned its build scripts the same way (371 registry crates plus verus's own fourbuild.rs) and none downloads. No change here. The preloaded commands carry no explicit--offlineflag, which the newdetbuild_preload_guard.pywould require once verus moves to detbuild. That flag belongs with the conversion, not a separate rebuild of verus.Verification, in a local min session (pkgbuild loadout, fresh
activateper run):min package build --rebuild --verbose zolafinished. The log shows all 665Downloadedlines before the firstCompilingline and none after. The shimmed--frozenstep built zola in 3m50s.min check --packages zola: every check passes, including the standalone smoke test.min package build --rebuild --verbose nushellfinished. All 984Downloadedlines come from the unshimmed fetch, thenLD_PRELOAD=/tmp/libdetrand.so cargo build --frozen --releasecompiled with no further download.min check --packages nushell: all pass.cargo fetch --lockedline removed. The shimmed build failed in the networked sandbox withno matching package named 'giallo' found ... offline mode (via --frozen), exit 101. So the shimmed step cannot reach the network even when the sandbox allows it, and every crate it compiles came from the unshimmed fetch.Reproducibility: output bytes should not change. The fetch only fills cargo's registry cache with the crates Cargo.lock already pinned and checksummed. The compile step still sees the same sources, flags and shim, and
--frozenadds nothing beyond--lockedexcept refusing the network. The fetch runs for all targets, so the offline build has every platform-conditional crate it might resolve.🤖 Generated with Claude Code