fix(coding-agent): verify pinned fd, ripgrep, and uv downloads - #2173
fix(coding-agent): verify pinned fd, ripgrep, and uv downloads#2173kevinjosethomas wants to merge 1 commit into
Conversation
Helper binaries were resolved from the latest GitHub release and installed without any digest check, partial downloads stayed in ~/.prime/agent/bin, and archive containment relied on the system tar. uv was installed by piping https://astral.sh/uv/install.sh into sh. Pin fd 10.5.0, ripgrep 15.2.0, and uv 0.12.9 with bundled SHA-256 digests, download into a staging directory, verify the digest before extraction, validate tar and zip member paths, run the version check on the staged binary, and only then move it into place. uv now comes from the pinned GitHub release archive through the same path; PRIME_AGENT_INSTALL_UV and the interactive confirmation keep their semantics. Linear: ENG-5343
Prime Agent performance — completedPR
Python runtime
Sandbox cost: ~$0.1101 — no inference calls. Methodology and samplesMain resolved at 2026-09-09T23:53:55.403373+00:00. Harness
|
Context
tools-manager.tsresolved the latest fd/ripgrep release from the GitHub API and installed whatever the asset contained into~/.prime/agent/binwith no digest check; an interrupted download left a partial<asset>.tar.gzin the bin dir, and archive containment relied on GNU tar's defaults.bootstrap.tsinstalled uv withsh -c "curl -LsSf https://astral.sh/uv/install.sh | sh". Supply-chain exposure, not evidence of upstream compromise.Root cause: no pinned versions, no integrity check, download and extraction happened directly in the install directory.
Changes
src/utils/helper-tool-releases.ts(new): pins fd 10.5.0, ripgrep 15.2.0, uv 0.12.9 with bundled SHA-256 digests per supported asset. ripgrep and uv digests cross-checked against their published.sha256files; fd publishes none, so its digests were computed from the GitHub release assets. uv 0.12.9 chosen over 0.12.10-12 to respect the 7-day release age.src/utils/helper-tool-install.ts(new): shared installer. Downloads into a staging dir under the destination, hashes the stream and rejects on mismatch before extraction, lists tar members (tar -tPzf) and validates each (no absolute paths, no..), applies the same check plus symlink rejection to zip entries viaextract-zip'sonEntry, verifies the extracted binary is a regular file inside the staging dir, runs the caller's--versioncheck on the staged binary, then renames it into place. The staging dir is removed on every exit path, so failures leave nothing behind. Also enforces HTTPS and a size cap.src/utils/tools-manager.ts: uses the installer; no more GitHub API "latest" lookup.src/core/kernel/bootstrap.ts:ensureUvdownloads the pinned uv release archive through the same installer into~/.prime/agent/bin/uv(also checked on later runs, alongside PATH and~/.local/bin). No shell is spawned.PRIME_AGENT_INSTALL_UV=1/0and the interactive confirmation keep their semantics; prompt and error text now name the pinned version.scripts/pin-helper-tools.ts(new): maintainer script to recompute digests for a new version and cross-check upstream checksums.docs/rlm-runtime.md: documents the uv/helper provisioning path.test/helper-tool-install.test.ts,test/kernel-bootstrap-uv.test.ts(new, stubbed fetch, hand-built tar.gz/zip fixtures intest/archive-fixtures.ts),test/tools-manager.test.tsupdated for the pinned flow.Model-facing surface unchanged.
Validation
Local:
npm run checkclean;tools-manager,helper-tool-install,kernel-bootstrap-uv,kernel-bootstrap,kernel-bootstrap-windowstest files pass (57 tests). Real download on darwin/arm64 through the new path installed fd 10.5.0 and rg 15.2.0 with digests verified.Prime Sandbox (
node:24-bookworm, GNU tar 1.34, usertester, freshHOME):eng5343-helper.test.ts): 4/4 vulnerable assertions pass — tampered archive installed asfd(echo 'tampered-fd 9.9.9 MARKER-5343'), requests wereapi.github.com/.../releases/latest+ asset with no checksum fetch, interrupted download leftfd-v9.9.9-x86_64-unknown-linux-gnu.tar.gzin the bin dir, uv bootstrap ransh -c curl -LsSf https://astral.sh/uv/install.sh | sh.SHA-256 mismatch for fd-v10.5.0-x86_64-unknown-linux-gnu.tar.gz, interrupted download leaves[], fakeshnever invoked; traversal containment still holds.ensureToolWithStatus("fd"/"rg")installed fd 10.5.0 and ripgrep 15.2.0 into~/.prime/agent/bin;ensureKernelPythonwith no uv on PATH andPRIME_AGENT_INSTALL_UV=1downloaded uv 0.12.9 (uv 0.12.9 (x86_64-unknown-linux-gnu)), verified it, and bootstrapped the kernel venv (Python 3.11.16,rlmimportable).Not validated live: Windows zip assets (digests for ripgrep/uv cross-checked against upstream
.sha256; fd computed from GitHub), macOS x86_64 and Linux aarch64 assets (same provenance).Linear: ENG-5343 — https://linear.app/primeintellect/issue/ENG-5343
Note
Verify pinned
fd,ripgrep, anduvdownloads with SHA-256 and safe extractionuvinstaller with a static pinned release registry coveringfd10.5.0,rg15.2.0, anduv0.12.9 across six supported Rust targets.uv,fd, andrgprovisioning through this shared installer instead of bespoke download logic.UnsupportedPlatformError;uvis no longer installed by piping a remote shell script, andtools-managerno longer queries the GitHub latest-release API at runtime.Macroscope summarized 2b69894.