Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 11 additions & 0 deletions docs/securityscan.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.
- ✅ 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

Expand All @@ -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

Expand All @@ -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.

---

Expand Down Expand Up @@ -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-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.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/spine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion packages/spine/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
16 changes: 16 additions & 0 deletions tests/release-packages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down
Loading