From 0027b1dd27b88d4eeb4671bd65b3c1b8fc582702 Mon Sep 17 00:00:00 2001 From: Nathan Rover Date: Wed, 29 Jul 2026 20:21:12 -0400 Subject: [PATCH 1/2] Correct the published-state disclaimer The root and package READMEs told consumers that Pegma's packages are not published, but `@pegma/spine@0.1.1` has been on npm since the last release. Stale trust guidance in the shipped README is the one security-scan finding with something to fix; the other three are annotated as disputed in docs/securityscan.md with the reasoning that ruled each one out. Bumps the package to 0.1.2 so the corrected README reaches consumers. Co-Authored-By: Claude Fable 5 --- README.md | 4 ++-- docs/securityscan.md | 11 +++++++++++ package-lock.json | 2 +- packages/spine/README.md | 4 ++-- packages/spine/package.json | 2 +- 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 9a7d3f2..3ab05f2 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@ The small, stable contracts every [Pegma](https://pegma.dev) component shares. > [!IMPORTANT] -> Spine is in early `0.x` development. Its public API is not stable, its -> packages are not published, and it is not ready for production use. +> Spine is in early `0.x` development. `@pegma/spine` is published on npm, but +> its public API is not stable and it is not ready for production use. ## Why it exists diff --git a/docs/securityscan.md b/docs/securityscan.md index 9d30081..1fc7554 100644 --- a/docs/securityscan.md +++ b/docs/securityscan.md @@ -18,6 +18,7 @@ Findings are appended as they are discovered during the scan. - **Exploitability:** Negligible. The files cannot affect CI or publishing (never tracked, `.gitignore`d, and `verifyPreparedManifest` would reject the stale schema). The only residual risk is a local operator manually pointing `release:publish --manifest` at this stale file, which the script's own validation would refuse. - **File references:** `.release/package-manifest.json`, `.release/pegma-spine-0.1.1.tgz`, `.gitignore:4`, `scripts/release-packages.mjs:432-470` - **Recommendation:** Optionally delete the local `.release/` directory; no repository change required. +- ⚠️ Disputed 2026-07-29 — not a valid finding: the artifacts are untracked and `.gitignore`d, so they are absent from any clean checkout and from CI; `verifyPreparedManifest` rejects the stale schema (it requires a top-level `package` object and `releaseTag === "v" + version`) and additionally rebinds the manifest to the current `HEAD` commit, so no repository change exists to make. ### FINDING-002 — Release job installs npm from the registry pinned by version only @@ -27,6 +28,7 @@ Findings are appended as they are discovered during the scan. - **Exploitability:** Low. Exploitation would require compromise of the npm registry or the npm@11.18.0 package itself; version pinning prevents silent upgrades, and trusted-publisher OIDC limits token exposure. Registry compromise would affect the entire ecosystem, but this job is a single point where unverified code runs with release-adjacent privileges (though the OIDC token is only granted to the separate `publish` job, mitigating this). - **File references:** `.github/workflows/publish.yml:56-57` - **Recommendation:** Acceptable as-is given the OIDC token isolation; optionally verify npm's integrity hash after install or use a corepack-pinned npm. +- ⚠️ Disputed 2026-07-29 — not a valid finding: the step adds no trust beyond what the job already accepts. The same job runs `npm ci` for the whole dev tree and takes its Node toolchain from `setup-node`, so `registry.npmjs.org` is already in the job's trust root; pinning npm's tarball hash would not narrow it. The version is pinned twice (workflow line 57 and `REVIEWED_NPM_VERSION` in `scripts/release-packages.mjs:21`, which fails the release unless the root manifest pins `npm@11.18.0`), so silent drift is impossible, and the preparation job holds no `id-token: write`. ### FINDING-003 — CI runs `npm ci` on untrusted pull-request code @@ -36,6 +38,7 @@ Findings are appended as they are discovered during the scan. - **Exploitability:** Very low. The workflow declares `permissions: contents: read` (lines 9–10), holds no secrets, and has no `id-token: write`, so a malicious install script gains nothing exfiltratable. The release workflow is gated on protected signed tags and does not run on PRs. This is the standard, accepted PR-CI risk profile. - **File references:** `.github/workflows/ci.yml:7,9-10,38` - **Recommendation:** None required. Optionally set `ignore-scripts: true` in a committed `.npmrc` if lifecycle scripts are never needed in CI. +- ⚠️ Disputed 2026-07-29 — not a valid finding: there is nothing for a malicious install script to reach. The trigger is `pull_request`, not `pull_request_target`, so a fork PR runs with a read-only token from the fork's context; the workflow declares only `contents: read`, references no secrets, and has no `id-token: write`. Publishing is reachable only from a `release: published` event on a protected signed tag. ### FINDING-004 — README claims the package is unpublished, but `0.1.1` is on npm @@ -45,6 +48,7 @@ Findings are appended as they are discovered during the scan. - **Exploitability:** None. Stale trust guidance could confuse consumers about the package's maturity, and AGENTS.md (`Where things stand`) already documents the published state correctly. - **File references:** `README.md:9-10`, `packages/spine/README.md:9-10`, `AGENTS.md` - **Recommendation:** Update both READMEs' disclaimer to reflect the published `0.1.1` state. +- ✅ Resolved 2026-07-29 — both READMEs' `[!IMPORTANT]` note now states that `@pegma/spine` is published on npm while keeping the unstable-API and not-production-ready warnings. --- @@ -76,3 +80,10 @@ All four findings are Low or Informational. The repository's security posture is The published registry artifact `@pegma/spine@0.1.1` has `dist.integrity` and `dist.shasum` identical to the hashes recorded in the local `.release/package-manifest.json` — the published bytes match the reviewed build. _Scan completed 2026-07-28._ + +### Disposition review 2026-07-29 + +Every finding was re-examined against the code before being marked. FINDING-004 +is resolved; FINDING-001, FINDING-002, and FINDING-003 are disputed with the +reasoning recorded on each item. No code path in `packages/spine/src` or +`scripts/release-packages.mjs` required a change, and no workflow was modified. diff --git a/package-lock.json b/package-lock.json index 59837ed..b4e318b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1714,7 +1714,7 @@ }, "packages/spine": { "name": "@pegma/spine", - "version": "0.1.1", + "version": "0.1.2", "license": "MIT", "engines": { "node": ">=22" diff --git a/packages/spine/README.md b/packages/spine/README.md index 2a425f0..d0d6148 100644 --- a/packages/spine/README.md +++ b/packages/spine/README.md @@ -6,8 +6,8 @@ The small, stable contracts every [Pegma](https://pegma.dev) component shares. > [!IMPORTANT] -> Spine is in early `0.x` development. Its public API is not stable, its -> packages are not published, and it is not ready for production use. +> Spine is in early `0.x` development. `@pegma/spine` is published on npm, but +> its public API is not stable and it is not ready for production use. ## Why it exists diff --git a/packages/spine/package.json b/packages/spine/package.json index 9f44d77..f672161 100644 --- a/packages/spine/package.json +++ b/packages/spine/package.json @@ -1,6 +1,6 @@ { "name": "@pegma/spine", - "version": "0.1.1", + "version": "0.1.2", "description": "Shared identity, time, logging, and event contracts for Pegma components.", "license": "MIT", "type": "module", From e6ad86d77ceadd136570a2740e2b0f21b2d8611e Mon Sep 17 00:00:00 2001 From: Nathan Rover Date: Wed, 29 Jul 2026 20:28:18 -0400 Subject: [PATCH 2/2] Pin the release npm bootstrap by tarball digest `npm install --global npm@11.18.0` trusted registry-provided metadata, while every other install in the preparation job is constrained by package-lock.json integrity hashes. That left the bootstrap as the one fetch a compromised registry could substitute undetected, and the substituted npm is what then runs `npm ci` and packs the artifact. The step now downloads the tarball, checks it against a committed SHA-256 digest, installs from the verified file, and confirms the active npm is the reviewed version. FINDING-002 is re-marked resolved rather than disputed. Co-Authored-By: Claude Fable 5 --- .github/workflows/publish.yml | 20 +++++++++++++++++++- docs/securityscan.md | 8 ++++---- tests/release-packages.test.ts | 16 ++++++++++++++++ 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index fd87d3c..6abf6e7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -53,8 +53,26 @@ jobs: registry-url: https://registry.npmjs.org package-manager-cache: false + # Installed from a tarball checked against a committed hash, so the + # bootstrap is pinned by bytes rather than by registry metadata. Every + # other install in this job is already covered by package-lock.json. - name: Use the reviewed npm release - run: npm install --global npm@11.18.0 + shell: bash + env: + NPM_VERSION: 11.18.0 + NPM_TARBALL_SHA256: 73f6155215ebabf4ed96dca1f567c2372cc713c33af2e5b9b62fde4e92373e2e + run: | + tarball="${RUNNER_TEMP}/npm-${NPM_VERSION}.tgz" + curl --fail --silent --show-error --location --retry 3 \ + "https://registry.npmjs.org/npm/-/npm-${NPM_VERSION}.tgz" \ + --output "${tarball}" + echo "${NPM_TARBALL_SHA256} ${tarball}" | sha256sum --check --strict --quiet + npm install --global "${tarball}" + installed="$(npm --version)" + if [[ "${installed}" != "${NPM_VERSION}" ]]; then + echo "::error::npm ${installed} is active but ${NPM_VERSION} was reviewed" + exit 1 + fi - name: Install dependencies run: npm ci diff --git a/docs/securityscan.md b/docs/securityscan.md index 1fc7554..95e8a3d 100644 --- a/docs/securityscan.md +++ b/docs/securityscan.md @@ -28,7 +28,7 @@ Findings are appended as they are discovered during the scan. - **Exploitability:** Low. Exploitation would require compromise of the npm registry or the npm@11.18.0 package itself; version pinning prevents silent upgrades, and trusted-publisher OIDC limits token exposure. Registry compromise would affect the entire ecosystem, but this job is a single point where unverified code runs with release-adjacent privileges (though the OIDC token is only granted to the separate `publish` job, mitigating this). - **File references:** `.github/workflows/publish.yml:56-57` - **Recommendation:** Acceptable as-is given the OIDC token isolation; optionally verify npm's integrity hash after install or use a corepack-pinned npm. -- ⚠️ Disputed 2026-07-29 — not a valid finding: the step adds no trust beyond what the job already accepts. The same job runs `npm ci` for the whole dev tree and takes its Node toolchain from `setup-node`, so `registry.npmjs.org` is already in the job's trust root; pinning npm's tarball hash would not narrow it. The version is pinned twice (workflow line 57 and `REVIEWED_NPM_VERSION` in `scripts/release-packages.mjs:21`, which fails the release unless the root manifest pins `npm@11.18.0`), so silent drift is impossible, and the preparation job holds no `id-token: write`. +- ✅ Resolved 2026-07-29 — the bootstrap now downloads `npm-11.18.0.tgz`, checks it against a committed SHA-256 digest, and installs from the verified file, so it is pinned by bytes rather than by registry metadata. `npm ci` was already constrained by `package-lock.json` integrity hashes, which left this fetch as the one install in the job with no digest of its own. A regression test at `tests/release-packages.test.ts` asserts the digest check precedes the install. ### FINDING-003 — CI runs `npm ci` on untrusted pull-request code @@ -83,7 +83,7 @@ _Scan completed 2026-07-28._ ### Disposition review 2026-07-29 -Every finding was re-examined against the code before being marked. FINDING-004 -is resolved; FINDING-001, FINDING-002, and FINDING-003 are disputed with the +Every finding was re-examined against the code before being marked. FINDING-002 +and FINDING-004 are resolved; FINDING-001 and FINDING-003 are disputed with the reasoning recorded on each item. No code path in `packages/spine/src` or -`scripts/release-packages.mjs` required a change, and no workflow was modified. +`scripts/release-packages.mjs` required a change. diff --git a/tests/release-packages.test.ts b/tests/release-packages.test.ts index 3058b52..7561c85 100644 --- a/tests/release-packages.test.ts +++ b/tests/release-packages.test.ts @@ -160,6 +160,22 @@ describe("release source authentication", () => { expect(workflow).not.toContain("workflow_dispatch"); expect(workflow).toContain("retention-days: 30"); }); + + it("pins the npm bootstrap by tarball hash rather than by version alone", () => { + const workflow = readFileSync( + join(process.cwd(), ".github", "workflows", "publish.yml"), + "utf8", + ); + // The lockfile constrains every other install in the preparation job, so + // the npm bootstrap is the one fetch that needs its own committed digest. + expect(workflow).not.toMatch(/npm install --global npm@/u); + expect(workflow).toMatch(/NPM_TARBALL_SHA256: [0-9a-f]{64}\n/u); + expect(workflow).toContain("sha256sum --check --strict --quiet"); + const digestIndex = workflow.indexOf("sha256sum --check"); + const installIndex = workflow.indexOf('npm install --global "${tarball}"'); + expect(digestIndex).toBeGreaterThanOrEqual(0); + expect(installIndex).toBeGreaterThan(digestIndex); + }); }); describe("retry-safe publication", () => {