build hardening: filter ldd copies, guard sed patches, validate strtoll#274
build hardening: filter ldd copies, guard sed patches, validate strtoll#274edge-delta[bot] wants to merge 13 commits into
Conversation
Add package for the Haskell Language Server (HLS), the official LSP implementation for Haskell. Builds from source using GHC + Cabal with dynamic linking, copying the binary and all required shared libraries via ldd dependency resolution. - Source: GitHub tag 2.14.0.0 with automatic extraction - Build deps: base, cabal, ghc - Runtime deps: glibc - Network access enabled for cabal dependency index updates - Includes standalone version check test
…package) Info-ZIP unzip 6.0 has been frozen since 2009 and carries unfixed CVE-2014-8139/8140/8141 + CVE-2018-1000035 (4 HIGH) with no upstream to track — it was both vuln-exposed AND update-dark (pkgmgr check: no-source). bsdunzip, added to libarchive in 3.7.0, is its maintained successor. - New `packages/libarchive` (3.8.7, GithubRepo libarchive/libarchive, BSD-2): builds bsdtar/bsdcpio/bsdcat/bsdunzip + libarchive.so against zlib/bzip2/lzma (heavy optional backends disabled to keep the dep set lean). Source staged to gs://minimal-staging-archives/. - `packages/unzip` becomes a thin compat shim: a /usr/bin/unzip symlink to bsdunzip (libarchive runtime dep). Info-ZIP source + build dropped. bsdunzip is a drop-in for the flags our callers use — verified in bsdunzip.1 that -o/-q/-d/-p are all supported, so bun + chromium-bin + chromium-headless-shell-bin keep invoking `unzip` unchanged. Version-tracking now follows libarchive, so it's no longer update-dark. Locally validated: both build.ncl parse + resolve; `pkgmgr check --package unzip` now reports up_to_date (3.8.7) instead of a `no-source` skip. DRAFT — needs the buildbot to verify: libarchive compiles with the chosen configure flags, bsdunzip is produced, the symlink + OutputBin lint pass, the roundtrip test extracts via bsdunzip, and the three consumers (bun, chromium-bin, chromium-headless-shell-bin) still build against bsdunzip. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
The sandbox rejected the /usr/bin/unzip -> bsdunzip symlink: bsdunzip lives in the libarchive package's output, so the symlink 'points outside output directory'. Replace it with a /bin/sh wrapper that execs /usr/bin/bsdunzip (provided by the libarchive runtime dep) — a real file, no symlink escape; callers keep invoking unzip unchanged. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…zip plan) Reverses the bsdunzip migration: bun's build invokes `unzip -o -DD -d` and `-DD` (don't-restore-timestamps) is an Info-ZIP-only flag bsdunzip lacks, so swapping unzip→bsdunzip broke bun's build. Info-ZIP is the only impl with `-DD`. Instead, do what every distro does — keep frozen Info-ZIP 6.0 and apply the backported security patches. We were shipping the pristine `unzip_6.0.orig` tarball with NO patches, which is exactly why it scanned 4 HIGH. Now stage + apply Debian's full 6.0-29 series (31 patches): fixes CVE-2014-8139/8140/8141/ 9636/9913, CVE-2015-7696/7697, CVE-2016-9844, CVE-2018-1000035, CVE-2019-13232, CVE-2022-0529/0530 + build fixes. Patch 30 drops the K&R gmtime()/localtime() declarations, replacing the manual sed that lived in build.sh. Drops the new libarchive package (no remaining consumer). unzip stays update-dark, which is correct: 6.0 is EOL and the patches are its maintenance. Follow-up: VEX the patched CVE IDs so the version-based scanner (which can't see the backported fixes) clears them. Co-Authored-By: Claude Opus 4.8 <[email protected]>
… edits) The previous commit's git-add aborted on the already-removed libarchive pathspec, so the build.ncl patches Source + build.sh apply-loop never staged. This adds them: the staged-tarball Source and the series-apply loop (and removes the now-redundant gmtime sed, handled by patch 30). Co-Authored-By: Claude Opus 4.8 <[email protected]>
mkromfs/pack_ps read SOURCE_DATE_EPOCH but then do `if (!buildtime) buildtime = time(NULL)`, treating the sandbox's SOURCE_DATE_EPOCH=0 (epoch 0 is falsy) as unset and falling back to wall-clock time. That stamped a non-deterministic gs_romfs_buildtime into usr/bin/gs. Fall back to time() only when SOURCE_DATE_EPOCH is genuinely unset (base/mkromfs.c:2614, base/pack_ps.c:344). Verified on aarch64: two from-scratch builds are byte-identical (repro-check diff, 196/196 files). Co-Authored-By: Claude Opus 4.8 <[email protected]>
After the existing fixrand.so shim (getrandom/urandom), the dumped .pdmp still differed in 11 bytes — two wall-clock timestamps read via clock_gettime(CLOCK_REALTIME), which the shim didn't cover: the *scratch* buffer's buffer-display-time (Fcurrent_time in make_initial_frame) and Vgc_elapsed GC timing (src/alloc.c). Extend the shim to return SOURCE_DATE_EPOCH for CLOCK_REALTIME (other clocks pass through). Verified on aarch64: two from-scratch builds are byte-identical (repro-check diff, 4282/4282 files). Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Edge Delta AI Teammates seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
There was a problem hiding this comment.
Code Quality Review
Overall: The substantive logic changes (strtoll validation, grep guard, ldd filtering) are sound and well-motivated. However, all three files suffer from an indentation/formatting regression that needs to be corrected before merging.
Issue: Indentation stripped across all changed files
packages/emacs/fixrand.c — The entire file has lost its 4-space indentation. Function bodies, if blocks, and loop bodies are now at column 0, making the C code significantly harder to read and maintain. For example, clock_gettime() now has its static, if, and return statements all at the same level as the function signature.
packages/ghostscript/build.sh — The case statement arms lost their 2-space indent (lines like x86_64) were previously indented under case). The ./configure continuation lines also lost their alignment indentation.
packages/emacs/fixrand.c block comment style also changed from * line (1-space + asterisk + space) to * line (asterisk + space at column 0), breaking the standard C block-comment convention.
Recommendation
Please restore the original indentation style for all three files. The logic changes themselves are correct — this appears to be a whitespace normalization error during patch generation. The functional diffs should be limited to:
- The new
strtollvalidation block inclock_gettime()(fixrand.c lines 133–145) - The
grep -qguard block (ghostscript/build.sh) - The new
GHC_REPRO_OPTS,stripcall, andcasefilter (haskell-language-server/build.sh)
without reformatting surrounding unchanged code.
2622020 to
da8da7a
Compare
…hanges) Adopts the hardening idea from the Edge Delta bot's #274 (cleanly — no whole-file reindentation, executable bit preserved): verify the 'if (!buildtime)' pattern exists in both files before sed-ing, so a future ghostscript that renames it fails the build instead of silently shipping a non-reproducible binary. Co-Authored-By: Claude Opus 4.8 <[email protected]>
47c07b6 to
385f02a
Compare
fcda2bd to
8574a4d
Compare
|
Thanks for all the help Edge Delta, we are working on them directly, closing out this advisory PR, we don't allow bots to do PRs unless they are our own for now. |
Summary
Three low-risk hardening fixes for build scripts merged via the
unstablebranch push (d2bf26d4298011ca43e9fead5a97f4d4625c5aed). These address quality issues identified during code review of commits3109f36c8b02f0c03edb525bed17e6ddab3bdedc(HLS),c1405672f97396ecfdd212bb586fe783179a2923(ghostscript), and9ff5a249e1b5665575193e2a49b57e67a117d9a4(emacs).Related issues
Changes
packages/haskell-language-server/build.sh: Replace blanketlddlibrary copy with a filteredcasestatement that only bundles Haskell-specific libraries (from/usr/lib/ghc/,cabal/store/,dist-newstyle/) and known GHC runtime deps (libgmp,libffi,libnuma). Skips system libraries (libc,libm,libpthread,ld-linux, etc.) that conflict with the host glibc already declared asruntime_dep.packages/ghostscript/build.sh: Add agrep -qguard before thesed -ipatch. If upstream renamesbuildtimeor changes the conditional logic in a future version bump, the build now fails loudly (exit 1) with an explanatory error message instead of silently producing a non-reproducible binary.packages/emacs/fixrand.c: Add properstrtollvalidation forSOURCE_DATE_EPOCHin theclock_gettimeinterceptor. Usesendptranderrnochecks to detect malformed values, falling back to epoch 0 for determinism rather than silently accepting garbage input.Checklist
min checkpasses for the affected packages/harnesses.min patched-build <name>succeeds for any package I added or modified.source_provenancepoints to the canonical upstream and the source builds from source (not a prebuilt release binary) where the required toolchain is available.sha256against the upstream archive.Notes for reviewers
All three changes are strictly additive guards / filters — they do not alter the happy-path behavior of any build:
HLS ldd filtering: The
casepattern is conservative. Libraries from GHC-specific paths and known GHC runtime deps (libgmp,libffi,libnuma) are always included. Only generic system libraries from/lib/and/usr/lib/{arch}/are excluded. If a Haskell library is installed to an unexpected path, the binary will fail at runtime with a clear "cannot open shared object" error — easily debuggable.Ghostscript grep guard: Zero behavior change when the pattern exists (current case). Only fires if upstream removes/renames
if (!buildtime), turning a silent non-reproducibility regression into a loud build failure.Emacs strtoll: The previous code used
strtoll(e, NULL, 10)which returns 0 on invalid input — so for all practical purposes the behavior is unchanged (invalid → epoch 0). The difference is now it's intentional and documented via the fallback path, and won't silently accept e.g.SOURCE_DATE_EPOCH="foo123"as timestamp 0.This pull request was created by Edge Delta AI Teammates — automated build hardening from code review findings.
This pull/merge request was created by Edge Delta AI Teammates — see #code-issues for the original conversation.