From c7639fef395df0d5bf8a5f703d1a80c23dc2b2ff Mon Sep 17 00:00:00 2001 From: devinfoley <139239+devinfoley@users.noreply.github.com> Date: Wed, 2 Dec 2026 00:30:35 +0000 Subject: [PATCH] build(runner): override Pi's minimatch to 11.0.8 and fix 1.0.0 fixtures Pi 1.7.0 pins minimatch 11.0.3, which has GHSA-cf2h-pxjq-68xw, GHSA-hqmv-qgp3-jx75 and GHSA-c859-jr93-m5j4 (fixed in 11.0.8). No Pi release pins a fixed minimatch yet, so the distribution overrides it. PI_SECURITY_OVERRIDES lets the verifier accept only that exact override, and only while Pi still pins 11.0.3. Regenerate the closure pins and profiles, and move the Rust and installation-integrity fixtures from Pi 1.0.0 to 1.7.0. Co-Authored-By: Claude Opus 5.5 --- doc/architecture/runner-pi-capabilities.md | 5 ++++- packages/paperclip-runner/acpx-profiles.json | 2 +- .../src/generated_acpx_profiles.rs | 2 +- .../tests/native_provider_backend.rs | 2 +- .../scripts/materialize-pi-distribution.mjs | 17 +++++++++++++--- .../materialize-pi-distribution.test.mjs | 20 ++++++++++++++++--- .../scripts/pi-distribution/package-lock.json | 10 +++++----- .../scripts/pi-distribution/package.json | 3 +++ .../src/drivers/acpx/generated-profiles.ts | 2 +- .../acpx/installation-integrity.test.ts | 6 +++--- .../src/drivers/acpx/pi-closure-pins.ts | 6 +++--- 11 files changed, 53 insertions(+), 22 deletions(-) diff --git a/doc/architecture/runner-pi-capabilities.md b/doc/architecture/runner-pi-capabilities.md index 2c1577bfe57..4f3cfdc6133 100644 --- a/doc/architecture/runner-pi-capabilities.md +++ b/doc/architecture/runner-pi-capabilities.md @@ -57,7 +57,10 @@ fixes. Since 1.6.0, Pi publishes exact dependency pins instead of a bundled `npm-shrinkwrap.json`, and pins `brace-expansion` 5.0.12 itself, so the materializer no longer applies a brace-expansion patch. It now checks that every dependency Pi declares installs at exactly that version and that every -`undici` and `brace-expansion` copy in the lock is the reviewed release. The +`undici`, `brace-expansion` and `minimatch` copy in the lock is the reviewed +release. Pi 1.7.0 pins minimatch 11.0.3, so the distribution overrides it to +11.0.8 (`PI_SECURITY_OVERRIDES`); the override fails closed when Pi changes +that pin, so the next Pi upgrade reviews it again. The profile version is unchanged; the new `commandDigest` starts saved Pi sessions fresh. diff --git a/packages/paperclip-runner/acpx-profiles.json b/packages/paperclip-runner/acpx-profiles.json index 5fb9dbe6be6..a20a2ab640d 100644 --- a/packages/paperclip-runner/acpx-profiles.json +++ b/packages/paperclip-runner/acpx-profiles.json @@ -28,7 +28,7 @@ "agentServerVersion": "0.0.33", "agentRuntimePackage": "@earendil-works/pi-coding-agent", "agentRuntimeVersion": "1.7.0", - "commandDigest": "sha256:5f798272e3b1efa448007e93b1fcdd0d44b827d7e73d550288e821323be7c1a0", + "commandDigest": "sha256:7ae4ee8a0428c609c529c731aff30ca51c77d4ec2f4f02629a4dfb14ee77aaab", "requiresProviderPolicy": true }, "cursor": { diff --git a/packages/paperclip-runner/runner/crates/runner-core/src/generated_acpx_profiles.rs b/packages/paperclip-runner/runner/crates/runner-core/src/generated_acpx_profiles.rs index 2e381e66611..d76bb9fbfb0 100644 --- a/packages/paperclip-runner/runner/crates/runner-core/src/generated_acpx_profiles.rs +++ b/packages/paperclip-runner/runner/crates/runner-core/src/generated_acpx_profiles.rs @@ -74,7 +74,7 @@ pub(crate) fn acpx_release_profile(agent: &str) -> Option { agent_runtime_package: Some("@earendil-works/pi-coding-agent"), agent_runtime_version: Some("1.7.0"), command_digest: - "sha256:5f798272e3b1efa448007e93b1fcdd0d44b827d7e73d550288e821323be7c1a0", + "sha256:7ae4ee8a0428c609c529c731aff30ca51c77d4ec2f4f02629a4dfb14ee77aaab", requires_provider_policy: true, qualification_pending: false, }, diff --git a/packages/paperclip-runner/runner/crates/runner-core/tests/native_provider_backend.rs b/packages/paperclip-runner/runner/crates/runner-core/tests/native_provider_backend.rs index 0378dc86569..ce9bc65325a 100644 --- a/packages/paperclip-runner/runner/crates/runner-core/tests/native_provider_backend.rs +++ b/packages/paperclip-runner/runner/crates/runner-core/tests/native_provider_backend.rs @@ -17,7 +17,7 @@ use sha2::{Digest, Sha256}; const CODEX_ACPX_DIGEST: &str = "sha256:443491f4e814501a5dc47347e4510e84faeec9c9382e2d4e53bfe69386d5aabc"; const PI_ACPX_DIGEST: &str = - "sha256:42e186b921f36accf3087cf64986a88346dcdb0bdf78c2ef44a2c4f8abd3453a"; + "sha256:7ae4ee8a0428c609c529c731aff30ca51c77d4ec2f4f02629a4dfb14ee77aaab"; fn temporary_directory(label: &str) -> PathBuf { let nonce = SystemTime::now() diff --git a/packages/paperclip-runner/scripts/materialize-pi-distribution.mjs b/packages/paperclip-runner/scripts/materialize-pi-distribution.mjs index d962fa3877d..1eefda38954 100644 --- a/packages/paperclip-runner/scripts/materialize-pi-distribution.mjs +++ b/packages/paperclip-runner/scripts/materialize-pi-distribution.mjs @@ -19,10 +19,19 @@ const lockDirectory = join(packageRoot, "scripts/pi-distribution"); const patchPath = join(workspaceRoot, "patches/pi-acp@0.0.33.patch"); const supportedTargets = new Set(["darwin-arm64", "darwin-x64", "linux-x64"]); export const PI_DISTRIBUTION_PINS = Object.freeze({ - wrapper: "0.0.33", runtime: "1.7.0", sdk: "0.26.0", zod: "3.25.76", nodeVersion: PI_NODE_VERSION, undici: "8.12.4", braceExpansion: "5.0.12", nodeBundledUndici: "7.29.1", + wrapper: "0.0.33", runtime: "1.7.0", sdk: "0.26.0", zod: "3.25.76", nodeVersion: PI_NODE_VERSION, undici: "8.12.4", braceExpansion: "5.0.12", minimatch: "11.0.8", nodeBundledUndici: "7.29.1", wrapperSha256: "9d129b3d38772e93e97080aa6c4e574ac5df4e47ce5bc331a484a9fbf8188b36", helperSha256: "41e0490b617da0d60e0c8ec58ef311236f945129d99f816cff6897f78da7f91d", }); +/** + * Reviewed npm overrides of an exact Pi dependency pin, for advisories fixed + * after the Pi release. `upstream` must still be Pi's pin, so a Pi upgrade + * forces a fresh review instead of silently keeping the override. + * minimatch 11.0.8 fixes GHSA-cf2h-pxjq-68xw, GHSA-hqmv-qgp3-jx75 and GHSA-c859-jr93-m5j4. + */ +export const PI_SECURITY_OVERRIDES = Object.freeze({ + minimatch: Object.freeze({ upstream: "11.0.3", version: PI_DISTRIBUTION_PINS.minimatch }), +}); const hash = (bytes) => createHash("sha256").update(bytes).digest("hex"); /** Install the published Pi graph exactly as the committed lock pins it. */ @@ -58,10 +67,12 @@ export async function verifyLockedPiPackageGraph(root, lock, target = { platform if (runtime.version !== PI_DISTRIBUTION_PINS.runtime) throw new Error("Pi runtime package differs from its pin"); for (const [name, version] of Object.entries(runtime.dependencies ?? {})) { const pinned = lock.packages[`${piPath}/node_modules/${name}`] ?? lock.packages[`node_modules/${name}`]; - if (!pinned || pinned.version !== version) throw new Error(`Pi distribution does not install Pi's pinned dependency ${name}`); + const override = Object.hasOwn(PI_SECURITY_OVERRIDES, name) ? PI_SECURITY_OVERRIDES[name] : undefined; + if (override && version !== override.upstream) throw new Error(`Pi changed its ${name} pin; review the security override again`); + if (!pinned || pinned.version !== (override?.version ?? version)) throw new Error(`Pi distribution does not install Pi's pinned dependency ${name}`); } // Reviewed security floors: every copy in the graph must be the reviewed release. - for (const [name, version] of [["undici", PI_DISTRIBUTION_PINS.undici], ["brace-expansion", PI_DISTRIBUTION_PINS.braceExpansion]]) { + for (const [name, version] of [["undici", PI_DISTRIBUTION_PINS.undici], ["brace-expansion", PI_DISTRIBUTION_PINS.braceExpansion], ["minimatch", PI_DISTRIBUTION_PINS.minimatch]]) { const copies = Object.entries(lock.packages).filter(([path]) => path === `node_modules/${name}` || path.endsWith(`/node_modules/${name}`)); if (!copies.length || copies.some(([, entry]) => entry.version !== version)) throw new Error(`Pi distribution ${name} differs from its reviewed security pin`); } diff --git a/packages/paperclip-runner/scripts/materialize-pi-distribution.test.mjs b/packages/paperclip-runner/scripts/materialize-pi-distribution.test.mjs index d73b00acb5b..9c3062051af 100644 --- a/packages/paperclip-runner/scripts/materialize-pi-distribution.test.mjs +++ b/packages/paperclip-runner/scripts/materialize-pi-distribution.test.mjs @@ -5,7 +5,7 @@ import { mkdtemp, mkdir, readFile, readdir, realpath, rm, symlink, writeFile } f import { tmpdir } from "node:os"; import { dirname, join } from "node:path"; import test from "node:test"; -import { assertPiNodeSystemDependencies, downloadPinnedPiNodeArchive, PI_DISTRIBUTION_PINS, materializePiDistribution, resolvePiBundledNpm, piDistributionInstallCommand, verifyLockedPiPackageGraph, writePiDistributionManifest } from "./materialize-pi-distribution.mjs"; +import { assertPiNodeSystemDependencies, downloadPinnedPiNodeArchive, PI_DISTRIBUTION_PINS, PI_SECURITY_OVERRIDES, materializePiDistribution, resolvePiBundledNpm, piDistributionInstallCommand, verifyLockedPiPackageGraph, writePiDistributionManifest } from "./materialize-pi-distribution.mjs"; import { verifyPiRuntimeManifest } from "../src/drivers/acpx/pi-verified-runtime.ts"; async function fixture(t) { @@ -30,7 +30,9 @@ test("distribution lock closes exact wrapper, SDK and upstream Pi graph with int const pkg = JSON.parse(await readFile(new URL("./pi-distribution/package.json", import.meta.url), "utf8")); const lock = JSON.parse(await readFile(new URL("./pi-distribution/package-lock.json", import.meta.url), "utf8")); assert.deepEqual(lock.packages[""].dependencies, pkg.dependencies); - assert.equal(pkg.overrides, undefined); + // Only reviewed security overrides may replace one of Pi's exact pins. + assert.deepEqual(pkg.overrides, Object.fromEntries(Object.entries(PI_SECURITY_OVERRIDES).map(([name, { version }]) => [name, version]))); + assert.equal(lock.packages["node_modules/minimatch"].version, "11.0.8"); assert.equal(lock.packages["node_modules/brace-expansion"].version, "5.0.12"); assert.equal(lock.packages["node_modules/undici"].version, "8.12.4"); assert.equal(PI_DISTRIBUTION_PINS.undici, "8.12.4"); @@ -58,12 +60,14 @@ test("package verification requires Pi's declared pins and the reviewed security [pi]: entry("pi-coding-agent", PI_DISTRIBUTION_PINS.runtime), "node_modules/undici": entry("undici", PI_DISTRIBUTION_PINS.undici), "node_modules/brace-expansion": entry("brace-expansion", PI_DISTRIBUTION_PINS.braceExpansion), + "node_modules/minimatch": entry("minimatch", PI_DISTRIBUTION_PINS.minimatch), } }; await write(`${pi}/package.json`, JSON.stringify({ version: PI_DISTRIBUTION_PINS.runtime, dependencies: { undici: PI_DISTRIBUTION_PINS.undici, "brace-expansion": PI_DISTRIBUTION_PINS.braceExpansion } })); await assert.rejects(verifyLockedPiPackageGraph(root, lock), /missing locked package/); await write("node_modules/undici/package.json", JSON.stringify({ version: PI_DISTRIBUTION_PINS.undici })); await write("node_modules/brace-expansion/package.json", JSON.stringify({ version: PI_DISTRIBUTION_PINS.braceExpansion })); - assert.equal(await verifyLockedPiPackageGraph(root, lock), 3); + await write("node_modules/minimatch/package.json", JSON.stringify({ version: PI_DISTRIBUTION_PINS.minimatch })); + assert.equal(await verifyLockedPiPackageGraph(root, lock), 4); await write("node_modules/undici/package.json", JSON.stringify({ version: "8.10.2" })); await assert.rejects(verifyLockedPiPackageGraph(root, lock), /differs from its lock/); await write("node_modules/undici/package.json", JSON.stringify({ version: PI_DISTRIBUTION_PINS.undici })); @@ -76,6 +80,16 @@ test("package verification requires Pi's declared pins and the reviewed security await assert.rejects(verifyLockedPiPackageGraph(root, lock), /Pi's pinned dependency undici/); await write(`${pi}/package.json`, JSON.stringify({ version: "1.0.0" })); await assert.rejects(verifyLockedPiPackageGraph(root, lock), /differs from its lock|Pi runtime package differs from its pin/); + // A reviewed override is accepted only while Pi still pins the reviewed upstream version. + const overridden = structuredClone(lock); + await write(`${pi}/package.json`, JSON.stringify({ version: PI_DISTRIBUTION_PINS.runtime, dependencies: { minimatch: PI_SECURITY_OVERRIDES.minimatch.upstream } })); + assert.equal(await verifyLockedPiPackageGraph(root, overridden), 4); + await write(`${pi}/package.json`, JSON.stringify({ version: PI_DISTRIBUTION_PINS.runtime, dependencies: { minimatch: "11.0.9" } })); + await assert.rejects(verifyLockedPiPackageGraph(root, overridden), /review the security override again/); + const vulnerable = structuredClone(overridden); vulnerable.packages["node_modules/minimatch"] = entry("minimatch", "11.0.3"); + await write("node_modules/minimatch/package.json", JSON.stringify({ version: "11.0.3" })); + await write(`${pi}/package.json`, JSON.stringify({ version: PI_DISTRIBUTION_PINS.runtime, dependencies: { minimatch: PI_SECURITY_OVERRIDES.minimatch.upstream } })); + await assert.rejects(verifyLockedPiPackageGraph(root, vulnerable), /Pi's pinned dependency minimatch/); }); test("manifest includes resources and emitted extension and rejects byte changes or links escaping the graph", async (t) => { diff --git a/packages/paperclip-runner/scripts/pi-distribution/package-lock.json b/packages/paperclip-runner/scripts/pi-distribution/package-lock.json index 7329f225ba1..ce97dfefcd7 100644 --- a/packages/paperclip-runner/scripts/pi-distribution/package-lock.json +++ b/packages/paperclip-runner/scripts/pi-distribution/package-lock.json @@ -1196,16 +1196,16 @@ } }, "node_modules/minimatch": { - "version": "11.0.3", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-11.0.3.tgz", - "integrity": "sha512-iny/40PEGkNJQ5/Pv6z3nm6FbRAby32GeZRjCUJk2WnNDbgPSTcdI+DDvLqsgBdD4cD5sMtMheqPPnehCCa8Nw==", + "version": "11.0.8", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-11.0.8.tgz", + "integrity": "sha512-nFQuYSTVrGvysVBps5Ih+0BdnYFN/Cj3C816r6+p7yK+FHrVLGE4O4N9AFwykrlNlvM2HYt+Rad1Uiro6h88Ig==", "license": "BlueOak-1.0.0", "dependencies": { - "@isaacs/nonrecursive-glob-match": "^1.0.3", + "@isaacs/nonrecursive-glob-match": "^1.1.0", "brace-expansion": "^5.0.12" }, "engines": { - "node": "18 || 20 || >=22" + "node": "20 || >=22" }, "funding": { "url": "https://github.com/sponsors/isaacs" diff --git a/packages/paperclip-runner/scripts/pi-distribution/package.json b/packages/paperclip-runner/scripts/pi-distribution/package.json index 8d1dacb3b65..131710ea334 100644 --- a/packages/paperclip-runner/scripts/pi-distribution/package.json +++ b/packages/paperclip-runner/scripts/pi-distribution/package.json @@ -9,6 +9,9 @@ "pi-acp": "0.0.33", "zod": "3.25.76" }, + "overrides": { + "minimatch": "11.0.8" + }, "engines": { "node": ">=24.11.0" } diff --git a/packages/paperclip-runner/src/drivers/acpx/generated-profiles.ts b/packages/paperclip-runner/src/drivers/acpx/generated-profiles.ts index e483b2a0048..6d6de45fb4a 100644 --- a/packages/paperclip-runner/src/drivers/acpx/generated-profiles.ts +++ b/packages/paperclip-runner/src/drivers/acpx/generated-profiles.ts @@ -40,7 +40,7 @@ export const QUALIFIED_ACPX_PROFILE_DATA = { "agentServerVersion": "0.0.33", "agentRuntimePackage": "@earendil-works/pi-coding-agent", "agentRuntimeVersion": "1.7.0", - "commandDigest": "sha256:5f798272e3b1efa448007e93b1fcdd0d44b827d7e73d550288e821323be7c1a0", + "commandDigest": "sha256:7ae4ee8a0428c609c529c731aff30ca51c77d4ec2f4f02629a4dfb14ee77aaab", "permissionPolicy": "interactive" }, "cursor": { diff --git a/packages/paperclip-runner/src/drivers/acpx/installation-integrity.test.ts b/packages/paperclip-runner/src/drivers/acpx/installation-integrity.test.ts index e8ca82cd58a..99d546c43e5 100644 --- a/packages/paperclip-runner/src/drivers/acpx/installation-integrity.test.ts +++ b/packages/paperclip-runner/src/drivers/acpx/installation-integrity.test.ts @@ -380,7 +380,7 @@ describe("ACPX installation integrity", () => { await mkdir(nestedRuntimeDirectory, { recursive: true }); await writeFile( join(nestedRuntimeDirectory, "package.json"), - JSON.stringify({ version: "1.0.0" }), + JSON.stringify({ version: "1.7.0" }), ); await expect( @@ -1492,7 +1492,7 @@ describe("ACPX installation integrity", () => { fixture.runtimePackageJsonPath, JSON.stringify({ name: packageName, - version: "1.0.0", + version: "1.7.0", main: "index.js", }), ), @@ -2292,7 +2292,7 @@ async function installationFixture() { serverPackageJsonPath, JSON.stringify({ version: "0.0.33", bin: "bin/server.js" }), ), - writeFile(runtimePackageJsonPath, JSON.stringify({ version: "1.0.0" })), + writeFile(runtimePackageJsonPath, JSON.stringify({ version: "1.7.0" })), writeFile(commandPath, command), ]); await chmod(commandPath, 0o755); diff --git a/packages/paperclip-runner/src/drivers/acpx/pi-closure-pins.ts b/packages/paperclip-runner/src/drivers/acpx/pi-closure-pins.ts index c69a0df0a8f..04b436b3907 100644 --- a/packages/paperclip-runner/src/drivers/acpx/pi-closure-pins.ts +++ b/packages/paperclip-runner/src/drivers/acpx/pi-closure-pins.ts @@ -9,7 +9,7 @@ * three pins. Never accept a digest supplied only by an installed manifest. */ export const PI_DISTRIBUTION_CLOSURE_SHA256 = Object.freeze({ - "darwin-arm64": "14dbc2b713de99a87d7247c336f6db11d01c72111f2fc14503b61e619180ca10", - "darwin-x64": "4db678edccc316296a5ea05e46445c6707e4ebf31253653156c15af24e40cf94", - "linux-x64": "385141f7c5a0ee1865651561bc4704ae519c7587564930a4a846d16757d23465", + "darwin-arm64": "0f412b4cca4549753e083324c3e1a851bbc380f042f9a1ff7fdbfdc7c145b1cb", + "darwin-x64": "84d2c1bd61dd4ce49fcab8974d88da0f65291d819a32caf85c8b19af700e9629", + "linux-x64": "f1369263b0d2e470f7e5daaac19cbbefc543bb2e920efbaafadaf534aaaba71e", });