Skip to content

Tighten release artifact verification and details validation - #5

Merged
FlyOverCoderKY merged 1 commit into
mainfrom
claude/harden-release-and-details-validation
Nov 6, 2026
Merged

FlyOverCoderKY merged 1 commit into
mainfrom
claude/harden-release-and-details-validation

Conversation

@FlyOverCoderKY

Copy link
Copy Markdown
Contributor

Summary

  • authenticate stable release inputs before checkout and separate preparation, consumer smoke testing, and publication
  • revalidate the packed manifest, exact artifact inventory, and recorded digests
  • reject unsupported details containers while preserving plain and null-prototype detail bags

Validation

  • CI=1 pnpm run format:check
  • CI=1 pnpm run check
  • CI=1 pnpm test
  • CI=1 pnpm run release:check
  • edited-file control-byte check

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-11-06T21:28:15.921462Z 65481f8 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

OpenRouter review posted (issues). #5 (review)

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenRouter pull-request review

Verdict: issues
Scope: full-pr (full-pr)
Mode: initial
Commit: 65481f83f95bc7635e5940f89338e44ea37452db
Judge: openai/gpt-5.6-luna
Cost: $0.3297 (lanes $0.3217 + judge $0.0080)

Lanes

  • meta/muse-spark-1.2: ok (7 finding(s), 88.7s, 188422+13443 tokens (40629 cached), 4 tool round(s), via Meta, $0.25)
  • z-ai/glm-5.3-flash: ok (9 finding(s), 545.2s, 1415960+82858 tokens (1277184 cached), 18 tool round(s), via CoreWeave, $0.0737)

Findings

🟠 Issue 1 — Null-prototype details bypass for exotic objects

packages/audit/src/index.ts:232 · risk · identified by meta/muse-spark-1.2

An attacker who can control the details value can bypass the "details must be a plain object" check by nulling the prototype of a non-plain object.

isPlainDetailsContainer returns true immediately when Object.getPrototypeOf(value) === null without inspecting internal slots or constructor. Object.setPrototypeOf(new Date(), null) or Object.setPrototypeOf(new Map(), null) therefore passes as a plain container, while new Date() and new Map() are correctly rejected. The subsequent Object.keys(details) then sees no enumerable keys, so the exotic is accepted as an empty details bag instead of being rejected, silently losing data and violating the test's intent to reject date/map/set at every write entry point.

Concrete trigger: auditEvent({..., details: Object.setPrototypeOf(new Date('2026-07-26T12:00:00.000Z'), null) as any }) is accepted and encodes to {"auditDetails": "{}"} rather than throwing /details must be a plain object/.

Evidence: packages/audit/src/index.ts:229-247 early if (prototype === null) return true;. Checked current callers in requireDetails and tests in packages/audit/src/index.test.ts:145-170 which only test direct new Date/Map/Set without nulled prototype; no test covers the setPrototypeOf variant.

🔴 Issue 2 — validatePackageManifest requires dependencies even when absent

scripts/release-packages.mjs:442 · bug · identified by meta/muse-spark-1.2

validatePackageManifest treats dependencies as mandatory, contradicting its type dependencies?: and the possibility of a package with no runtime deps.

The loop iterates DEPENDENCY_FIELDS and for field === "dependencies" does if (!isPlainRecord(dependencies)) fail(...) before the if (dependencies === undefined) continue; guard. When manifest.dependencies is undefined (no dependencies), isPlainRecord(undefined) is false and the function throws "dependencies must be an object". The same manifest would pass the remaining checks and the lockfile sync.

Trigger: validatePackageManifest({ ...validManifest, dependencies: undefined }) or any future @​pegma/audit version that legitimately removes its two deps would fail pnpm run release:check even though the package is otherwise valid. Current packages/audit/package.json has deps so the existing test suite does not catch it.

Evidence: scripts/release-packages.mjs:432-447 first if (field === "dependencies" && !isPlainRecord(dependencies)) precedes the undefined-continue. Verified against scripts/release-packages.d.mts:25 where dependencies is optional and packages/audit/package.json which currently supplies it.

🟠 Issue 3 — comparePackedManifest allowlist gap lets extra manifest fields slip

scripts/release-packages.mjs:505 · risk · identified by meta/muse-spark-1.2

comparePackedManifest only iterates RELEASE_MANIFEST_FIELDS and compares those keys with isDeepStrictEqual. Any field not in that list is never compared, so a packed package/package.json that adds an unexpected top-level field will still pass validation.

Example injectable fields outside the list include funding, keywords, author, contributors, homepage, bugs, workspaces, packageManager. While most are inert, the absence of a deny-list means a trojaned npm CLI could add a new field that downstream consumers or registry policy might interpret, without failing prepareRelease. The intended invariant from docs/RELEASING.md is that the packed manifest is checked against the reviewed source manifest.

Evidence: scripts/release-packages.mjs:41-62 defines RELEASE_MANIFEST_FIELDS and 504-510 loops only that list. Checked that funding/keywords are not present in the list but are valid package.json keys that npm pack would preserve.

Gap: no test asserts that an extra field is rejected; tests/release-packages.test.ts:132-145 only checks publishConfig and dependencies changes.

🟠 Issue 4 — Record-digest and verify steps lack explicit strict-mode error handling

.github/workflows/publish.yml:121 · risk · identified by meta/muse-spark-1.2

In .github/workflows/publish.yml the inline bash steps that hash and verify the sealed artifact do not set set -euo pipefail and rely on the runner's default bash -e.

The Record the package manifest digest step (digest="$(node -e 'readFileSync(".release/package-manifest.json")...')" ) uses command substitution: with set +e a failing node (missing file or parse error) would leave digest empty and the following echo "digest=${digest}" >> "${GITHUB_OUTPUT}" would succeed, publishing an empty manifest_digest output. The downstream Verify the prepared release steps (node <<'NODE' ... throw new Error(...)) similarly depend on the shell propagating node's non-zero exit. If the runner's default shell options ever change, a verification failure could be silently ignored and the workflow would publish or smoke-test an unverified tarball.

Evidence: .github/workflows/publish.yml:121-126 (prepare: Record digest), 178-216 (smoke Verify) and 310-360 (publish Verify) have no set -euo pipefail header, unlike the Authenticate the release tag and Use the reviewed npm release steps which do. Verified the script bodies contain node <<'NODE' with throw that must abort the job.

Proof gap: GitHub's current bash shell does invoke with -e -o pipefail by default, so failure is currently propagated; the finding is about fragility to that implicit guarantee.

🔵 Issue 5 — Minimal publish environment still forwards GITHUB_TOKEN

.github/workflows/publish.yml:396 · nit · identified by meta/muse-spark-1.2

The Publish the prepared tarball step builds a minimal allowlist allowed_env and then runs env -i "${allowed_env[@​]}" npm .... The allowlist construction copies every environment variable matching GITHUB_* (while IFS='=' read -r name value; do case "${name}" in TMP*|SYSTEMROOT|GITHUB_*|ACTIONS_ID_TOKEN_*) ...).

That includes GITHUB_TOKEN (always present in Actions) and any other GITHUB_* secrets, which are then passed to the npm view/npm publish subprocesses. Publication only needs ACTIONS_ID_TOKEN_* for OIDC; forwarding GITHUB_TOKEN widens exfiltration surface if the npm CLI or registry response is compromised, contrary to the PR's goal of a minimal environment with empty npmrcs.

Evidence: .github/workflows/publish.yml:390-405 allowed_env construction and npm_clean() { env -i "${allowed_env[@​]}" npm "$@​" } . Checked that GITHUB_TOKEN matches GITHUB_* and is not required by the npm view/publish calls which use id-token: write.

Gap: not verified at runtime that the publish job's token is actually unused by npm; the risk is unnecessary credential exposure.

🟠 Issue 6 — Prepare job no longer enforces signed-tag check on local invocation

.github/workflows/publish.yml:119 · risk · identified by meta/muse-spark-1.2

The preparation command in CI was changed from pnpm run release:pack -- --require-clean --require-main-ancestor --require-release-tag --expected-release-commit ... to omit --require-release-tag.

In scripts/release-packages.mjs, validateReleaseTag (annotated-tag object check, verify-tag --raw, merge-base --is-ancestor origin/main) is only invoked when options.requireReleaseTag is truthy. Workflow authentication now does equivalent checks in a bare repository before checkout, but a developer running pnpm run release:pack -- --output .release locally or in a fork without that workflow shell will no longer get tag-signature or ancestry verification, and validateRepository will still accept a RELEASE_TAG mismatch only via the loose releaseTag !== \v${manifest.version}`check. The security commentary indocs/RELEASING.mdanddocs/securityscan.md` assumes the Node helper also enforces the signed tag.

Evidence: .github/workflows/publish.yml:119 new prepare line lacks --require-release-tag; scripts/release-packages.mjs:545-560 if (options.requireReleaseTag) validateReleaseTag(...). Verified that tests/release-packages.test.ts:391-402 still asserts checkout/tag authentication in the workflow but has no test that a local prepareRelease without the flag rejects an unsigned lightweight tag.

🔵 Issue 7 — Smoke-job inventory check weaker than publish-job check

.github/workflows/publish.yml:189 · nit · identified by meta/muse-spark-1.2

The two Verify the prepared release node blocks are not identical. The smoke job validates schemaVersion, name, version, sha256, integrity, tarball name, exact two-file inventory, and tarball digest, but does not verify manifest.gitCommit, manifest.releaseTag, or the v${version} tag-to-version binding. The publish job does verify gitCommit === RELEASE_COMMIT and releaseTag === RELEASE_TAG === \v${version}``.

An artifact whose manifest points at a different commit or tag than the event (e.g., built from a stale checkout) would still pass the smoke consumer-import test and be considered "verified" for OIDC, with failure deferred to the publish job. If smoke is used as a gate for promotion, the earlier signal is weaker than documented ("exact two-file inventory, release commit" in docs/RELEASING.md:58).

Evidence: .github/workflows/publish.yml:189-203 smoke verification if (manifest.schemaVersion !==1 || record?.name ...) lacks gitCommit/releaseTag checks present at 327-337 in publish verification. Cross-checked docs/RELEASING.md:58 which claims the publish job verifies those fields but does not state smoke omits them.

🟠 Issue 8 — Workflow tag regex rejects stable v0.0.x releases that the rest of the pipeline accepts

.github/workflows/publish.yml:38 · risk · identified by z-ai/glm-5.3-flash

A maintainer publishing a release for a tag like v0.0.5 (a backport, or an early-versioned package) gets both the prepare and publish jobs aborted at their very first step with The release tag must be a stable vX.Y.Z tag — even though v0.0.5 is valid, stable semver and every other check in the pipeline accepts it.

The regex ^v(0\.[1-9][0-9]*|[1-9][0-9]*\.[0-9]+)\.[0-9]+$ (.github/workflows/publish.yml:38 and again at :266) excludes minor 0 when major is 0. By contrast, STABLE_SEMVER in scripts/release-packages.mjs:39 ((0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)), validateReleaseTag's ^v\d+\.\d+\.\d+$, and the workflow's own inline manifest-version regex used in both verify steps all accept 0.0.x. So the tag gate is stricter than the version gate it feeds: a manifest version 0.0.x could never be released through this workflow.

docs/RELEASING.md still documents the requirement only as "a stable annotated vX.Y.Z tag", with no 0.0 carve-out, so the error message shown to the maintainer is also wrong. I checked that the current package version is 0.2.0, so nothing is blocked today; the inconsistency is latent but the failure mode (a hard release stop with a misleading message) is concrete.

🟠 Issue 9 — New release-pack integration test can exceed vitest's default 5 s per-test timeout

tests/release-packages.test.ts:150 · risk · identified by z-ai/glm-5.3-flash

The new test "seals a packed release as one manifest and one tarball" (tests/release-packages.test.ts:150) spawns a full pnpm run release:pack inside a single it(). That command runs validateRepository, a workspace build (tsc -b), npm pack whose prepack runs a second build (tsc -p tsconfig.json via another spawned npm), tar extraction, hashing, and two inventory validations — all within one test body.

vitest.config.ts sets no testTimeout, so vitest's default 5 000 ms per-test limit applies. On a slow or loaded runner (the test file runs concurrently with packages/audit/src/index.test.ts in vitest's default parallel pool), or on a developer machine with a cold cache, the gate pnpm test fails spuriously and blocks the CI matrix on both Node 22 and 24.

Proof gap: I cannot execute the suite here, so I cannot measure the actual duration; the author's validation run may have been comfortably under 5 s locally, but the margin is small and there is no explicit timeout to absorb runner variance.

🟠 Issue 10 — Release smoke test no longer imports every export target

.github/workflows/publish.yml:242 · risk · identified by z-ai/glm-5.3-flash

The removed smokeTestTarball iterated Object.keys(manifest.exports) and imported every export specifier from the clean consumer. The new smoke job imports only the package root: node --input-type=module --eval "await import(${PACKAGE_NAME@​Q})" (.github/workflows/publish.yml:242).

Today @​pegma/audit exports only ".", so coverage is momentarily identical. The moment a subpath export such as ./client is added to packages/audit/package.json, releases will publish a package whose additional entry points were never imported by any gate step — a silent coverage regression introduced by this PR, in a pipeline whose whole point is proving the exact packed bytes work.

The same smoke step also hardcodes "@​pegma/audit" and the pegma-audit- tarball prefix in both verify scripts, so the previously single-sourced PACKAGE constant now lives in three inline copies that must be edited in lockstep.

🟠 Issue 11 — New test hard-requires Corepack's pnpm CLI at two fixed Node-layout paths

tests/release-packages.test.ts:50 · risk · identified by z-ai/glm-5.3-flash

corepackPnpmCli() (tests/release-packages.test.ts:50-58) resolves pnpm only as <dirname(node)>/node_modules/corepack/dist/pnpm.js or <dirname(node)>/../lib/node_modules/corepack/dist/pnpm.js, and otherwise throws could not resolve Corepack's pnpm CLI, failing the entire tests/release-packages.test.ts file and with it the gate.

Concrete failing environments: a Node install that does not bundle Corepack at that layout (some distro packages strip it), Volta's per-version shims directory, or any setup where Corepack was installed globally into a non-adjacent npm prefix — the repo's own README.md instructs npm install -g corepack for environments without bundled Corepack, which lands it wherever npm's prefix points, not necessarily beside node.

CI is unaffected (ci.yml runs corepack enable on hostedtoolcache Node 22/24, where the bundled path exists), but the gate is now environment-fragile for local runs where it previously only needed pnpm on PATH.

🟠 Issue 12 — Tag authentication now fetches the tag and main from GitHub without any credentials

.github/workflows/publish.yml:61 · risk · identified by z-ai/glm-5.3-flash

Both authenticate steps clone and fetch from https://github.com/${GITHUB_REPOSITORY}.git anonymously (.github/workflows/publish.yml:61-64 in prepare, :289-292 in publish). The old flow fetched through actions/checkout's persisted workflow token (persist-credentials defaulted on, and the explicit git fetch origin main ran after checkout with those credentials).

Concrete failure scenario: if the repository is ever made private — or hosted anywhere anonymous git reads are refused — both jobs fail at their first step, even though npm trusted publishing itself is unaffected by repo visibility. Anonymous GitHub git traffic also carries much tighter rate limits than the workflow token, so a busy shared runner IP can fail the fetch transiently.

This works today only because pegma-dev/audit is public; the hardening PR trades token-authenticated fetches for unauthenticated ones without a fallback. (The later actions/checkout correctly uses persist-credentials: false; the gap is the fetch in the authenticate step, which runs before any credential exists.)

🔵 Issue 13 — --expected-release-commit in the pack step is now a no-op

.github/workflows/publish.yml:122 · nit · identified by z-ai/glm-5.3-flash

The pack step still reads pnpm run release:pack -- --require-clean --require-main-ancestor --expected-release-commit "${RELEASE_COMMIT}" --output .release (.github/workflows/publish.yml:122), but this PR removed --require-release-tag, and expectedReleaseCommit is only ever consumed inside validateReleaseTag, which validateRepository invokes solely under requireReleaseTag (scripts/release-packages.mjs:592-597). Nothing in the pack path reads the flag any more.

The flag therefore advertises a pack-time binding of the prepared artifact to the release-event commit that no longer executes; a reader or future editor of the workflow will reasonably assume the check is live. The binding does still hold transitively (authenticate verifies tag commit == github.sha, checkout is at github.sha, and the publish job's verify compares manifest.gitCommit to RELEASE_COMMIT), so this is a misleading-flag cleanup rather than a hole — the misleading part is the cost.

🔵 Issue 14 — validatePackageManifest refuses a package with no dependencies field

scripts/release-packages.mjs:485 · nit · identified by z-ai/glm-5.3-flash

In the DEPENDENCY_FIELDS loop (scripts/release-packages.mjs:482-486), the dependencies branch evaluates !isPlainRecord(manifest.dependencies) before the if (dependencies === undefined) continue; escape, so an absent dependencies field fails with "<label> dependencies must be an object" — a message about a field that is not there.

The surrounding code disagrees about whether absence is legal: validateRepository calls assertPnpmLockfileSynchronized(..., manifest.dependencies ?? {}), explicitly tolerating a missing field, and optionalDependencies/peerDependencies may be absent. So a future @​pegma/* package with no runtime dependencies (or its packed manifest, since the same validator now runs on the packed copy in prepareRelease) can never pass release:check, and the packed-manifest comparison path inherits the same trap.

Today packages/audit/package.json has dependencies, so nothing currently breaks; the inconsistency is latent but the error path is reachable by any dependency-free package this single-package validator is pointed at.

🔵 Issue 15 — docs/securityscan.md now references removed or relocated release mechanisms

docs/securityscan.md:223 · nit · identified by z-ai/glm-5.3-flash

The security-scan record — the repo's audit trail for the release pipeline — now describes mechanisms this PR removed or moved:

  • Section 6 records the npm-tarball integrity mitigation as running via release-packages.mjs verify-npm from the workflow; the workflow no longer calls verify-npm at all (the new test asserts the workflow does not contain verify-npm --tarball), and the check is inlined into each job instead.
  • Section 8 cites scripts/release-packages.mjs — smokeTestTarball (lines 285-319) and justifies its containment by "prepareRelease hashes the tarball before smokeTestTarball runs while verifyPreparedManifest re-hashes it in the publish job". smokeTestTarball was deleted and smoke testing moved to a dedicated job whose ordering and hash checks are different code.

A maintainer or auditor re-verifying the pipeline against this document will look for code that no longer exists, and the documented containment argument (hash-before-smoke inside one job) no longer matches how the guarantee is actually achieved (digest binding across jobs).

🔵 Issue 16 — Prepared-release verification now exists twice with divergent checks, and the script's publish path is unexercised

scripts/release-packages.mjs:772 · nit · identified by z-ai/glm-5.3-flash

The publish job's inline node verifier (.github/workflows/publish.yml:333-386) and verifyPreparedManifest (scripts/release-packages.mjs:772-812) enforce different subsets of the same contract: the workflow checks gitCommit and releaseTag against the release event but never validates record.shasum or record.files; the script validates shasum and files shape but compares gitCommit against a checkout's rev-parse HEAD — which cannot exist in the checkout-free publish job.

Because the two implementations must now be kept in agreement by hand, any future strengthening of one (say, adding a files allowlist re-check to the workflow) leaves the other behind, and nothing fails when they drift.

Additionally, pnpm run release:publish / publishPreparedRelease is no longer invoked by the workflow (the new test explicitly asserts publish does not contain scripts/release-packages.mjs) and no test exercises it — the suite never imports publishPreparedRelease, and the function refuses to run outside GITHUB_ACTIONS. The path remains advertised in package.json:20 and the script's usage message, so it can rot silently while still looking like a supported entry point.

Workflow run

function isPlainDetailsContainer(value: unknown): value is AuditDetails {
if (value === null || typeof value !== "object" || Array.isArray(value)) {
return false;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 Null-prototype details bypass for exotic objects (risk)

An attacker who can control the details value can bypass the "details must be a plain object" check by nulling the prototype of a non-plain object.

isPlainDetailsContainer returns true immediately when Object.getPrototypeOf(value) === null without inspecting internal slots or constructor. Object.setPrototypeOf(new Date(), null) or Object.setPrototypeOf(new Map(), null) therefore passes as a plain container, while new Date() and new Map() are correctly rejected. The subsequent Object.keys(details) then sees no enumerable keys, so the exotic is accepted as an empty details bag instead of being rejected, silently losing data and violating the test's intent to reject date/map/set at every write entry point.

Concrete trigger: auditEvent({..., details: Object.setPrototypeOf(new Date('2026-07-26T12:00:00.000Z'), null) as any }) is accepted and encodes to {"auditDetails": "{}"} rather than throwing /details must be a plain object/.

Evidence: packages/audit/src/index.ts:229-247 early if (prototype === null) return true;. Checked current callers in requireDetails and tests in packages/audit/src/index.test.ts:145-170 which only test direct new Date/Map/Set without nulled prototype; no test covers the setPrototypeOf variant.

export function validatePackageManifest(manifest, options = {}) {
const label = options.label ?? PACKAGE.name;
const expectedName = options.expectedName ?? PACKAGE.name;
const expectedVersion = options.expectedVersion;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 validatePackageManifest requires dependencies even when absent (bug)

validatePackageManifest treats dependencies as mandatory, contradicting its type dependencies?: and the possibility of a package with no runtime deps.

The loop iterates DEPENDENCY_FIELDS and for field === "dependencies" does if (!isPlainRecord(dependencies)) fail(...) before the if (dependencies === undefined) continue; guard. When manifest.dependencies is undefined (no dependencies), isPlainRecord(undefined) is false and the function throws "dependencies must be an object". The same manifest would pass the remaining checks and the lockfile sync.

Trigger: validatePackageManifest({ ...validManifest, dependencies: undefined }) or any future @​pegma/audit version that legitimately removes its two deps would fail pnpm run release:check even though the package is otherwise valid. Current packages/audit/package.json has deps so the existing test suite does not catch it.

Evidence: scripts/release-packages.mjs:432-447 first if (field === "dependencies" && !isPlainRecord(dependencies)) precedes the undefined-continue. Verified against scripts/release-packages.d.mts:25 where dependencies is optional and packages/audit/package.json which currently supplies it.

@@ -442,8 +504,33 @@ export async function validateRepository(options = {}) {
target.includes(".."),
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 comparePackedManifest allowlist gap lets extra manifest fields slip (risk)

comparePackedManifest only iterates RELEASE_MANIFEST_FIELDS and compares those keys with isDeepStrictEqual. Any field not in that list is never compared, so a packed package/package.json that adds an unexpected top-level field will still pass validation.

Example injectable fields outside the list include funding, keywords, author, contributors, homepage, bugs, workspaces, packageManager. While most are inert, the absence of a deny-list means a trojaned npm CLI could add a new field that downstream consumers or registry policy might interpret, without failing prepareRelease. The intended invariant from docs/RELEASING.md is that the packed manifest is checked against the reviewed source manifest.

Evidence: scripts/release-packages.mjs:41-62 defines RELEASE_MANIFEST_FIELDS and 504-510 loops only that list. Checked that funding/keywords are not present in the list but are valid package.json keys that npm pack would preserve.

Gap: no test asserts that an extra field is rejected; tests/release-packages.test.ts:132-145 only checks publishConfig and dependencies changes.


- name: Prepare and verify the release tarball
run: pnpm run release:pack -- --require-clean --require-main-ancestor --require-release-tag --expected-release-commit "${RELEASE_COMMIT}" --output .release
- name: Prepare the release tarball

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 Record-digest and verify steps lack explicit strict-mode error handling (risk)

In .github/workflows/publish.yml the inline bash steps that hash and verify the sealed artifact do not set set -euo pipefail and rely on the runner's default bash -e.

The Record the package manifest digest step (digest="$(node -e 'readFileSync(".release/package-manifest.json")...')" ) uses command substitution: with set +e a failing node (missing file or parse error) would leave digest empty and the following echo "digest=${digest}" >> "${GITHUB_OUTPUT}" would succeed, publishing an empty manifest_digest output. The downstream Verify the prepared release steps (node <<'NODE' ... throw new Error(...)) similarly depend on the shell propagating node's non-zero exit. If the runner's default shell options ever change, a verification failure could be silently ignored and the workflow would publish or smoke-test an unverified tarball.

Evidence: .github/workflows/publish.yml:121-126 (prepare: Record digest), 178-216 (smoke Verify) and 310-360 (publish Verify) have no set -euo pipefail header, unlike the Authenticate the release tag and Use the reviewed npm release steps which do. Verified the script bodies contain node <<'NODE' with throw that must abort the job.

Proof gap: GitHub's current bash shell does invoke with -e -o pipefail by default, so failure is currently propagated; the finding is about fragility to that implicit guarantee.

PACKAGE_TARBALL: ${{ steps.prepared.outputs.tarball }}
PACKAGE_VERSION: ${{ steps.prepared.outputs.version }}
run: |
set -euo pipefail

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Minimal publish environment still forwards GITHUB_TOKEN (nit)

The Publish the prepared tarball step builds a minimal allowlist allowed_env and then runs env -i "${allowed_env[@​]}" npm .... The allowlist construction copies every environment variable matching GITHUB_* (while IFS='=' read -r name value; do case "${name}" in TMP*|SYSTEMROOT|GITHUB_*|ACTIONS_ID_TOKEN_*) ...).

That includes GITHUB_TOKEN (always present in Actions) and any other GITHUB_* secrets, which are then passed to the npm view/npm publish subprocesses. Publication only needs ACTIONS_ID_TOKEN_* for OIDC; forwarding GITHUB_TOKEN widens exfiltration surface if the npm CLI or registry response is compromised, contrary to the PR's goal of a minimal environment with empty npmrcs.

Evidence: .github/workflows/publish.yml:390-405 allowed_env construction and npm_clean() { env -i "${allowed_env[@​]}" npm "$@​" } . Checked that GITHUB_TOKEN matches GITHUB_* and is not required by the npm view/publish calls which use id-token: write.

Gap: not verified at runtime that the publish job's token is actually unused by npm; the risk is unnecessary credential exposure.

printf '%s\n' '{"name":"audit-release-smoke","private":true,"type":"module"}' > "${consumer}/package.json"
cd "${consumer}"
npm install --ignore-scripts --no-audit --no-fund --package-lock=false "${PACKAGE_TARBALL}"
node --input-type=module --eval "await import(${PACKAGE_NAME@Q})"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 Release smoke test no longer imports every export target (risk)

The removed smokeTestTarball iterated Object.keys(manifest.exports) and imported every export specifier from the clean consumer. The new smoke job imports only the package root: node --input-type=module --eval "await import(${PACKAGE_NAME@​Q})" (.github/workflows/publish.yml:242).

Today @​pegma/audit exports only ".", so coverage is momentarily identical. The moment a subpath export such as ./client is added to packages/audit/package.json, releases will publish a package whose additional entry points were never imported by any gate step — a silent coverage regression introduced by this PR, in a pipeline whose whole point is proving the exact packed bytes work.

The same smoke step also hardcodes "@​pegma/audit" and the pegma-audit- tarball prefix in both verify scripts, so the previously single-sourced PACKAGE constant now lives in three inline copies that must be edited in lockstep.

}).trim();
}

function corepackPnpmCli(): string {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 New test hard-requires Corepack's pnpm CLI at two fixed Node-layout paths (risk)

corepackPnpmCli() (tests/release-packages.test.ts:50-58) resolves pnpm only as <dirname(node)>/node_modules/corepack/dist/pnpm.js or <dirname(node)>/../lib/node_modules/corepack/dist/pnpm.js, and otherwise throws could not resolve Corepack's pnpm CLI, failing the entire tests/release-packages.test.ts file and with it the gate.

Concrete failing environments: a Node install that does not bundle Corepack at that layout (some distro packages strip it), Volta's per-version shims directory, or any setup where Corepack was installed globally into a non-adjacent npm prefix — the repo's own README.md instructs npm install -g corepack for environments without bundled Corepack, which lands it wherever npm's prefix points, not necessarily beside node.

CI is unaffected (ci.yml runs corepack enable on hostedtoolcache Node 22/24, where the bundled path exists), but the gate is now environment-fragile for local runs where it previously only needed pnpm on PATH.

git init --bare --quiet "${repository}"
git -C "${repository}" config gpg.format ssh
git -C "${repository}" config gpg.ssh.allowedSignersFile "${allowed_signers}"
git -C "${repository}" remote add origin "https://github.com/${GITHUB_REPOSITORY}.git"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 Tag authentication now fetches the tag and main from GitHub without any credentials (risk)

Both authenticate steps clone and fetch from https://github.com/${GITHUB_REPOSITORY}.git anonymously (.github/workflows/publish.yml:61-64 in prepare, :289-292 in publish). The old flow fetched through actions/checkout's persisted workflow token (persist-credentials defaulted on, and the explicit git fetch origin main ran after checkout with those credentials).

Concrete failure scenario: if the repository is ever made private — or hosted anywhere anonymous git reads are refused — both jobs fail at their first step, even though npm trusted publishing itself is unaffected by repo visibility. Anonymous GitHub git traffic also carries much tighter rate limits than the workflow token, so a busy shared runner IP can fail the fetch transiently.

This works today only because pegma-dev/audit is public; the hardening PR trades token-authenticated fetches for unauthenticated ones without a fallback. (The later actions/checkout correctly uses persist-credentials: false; the gap is the fetch in the authenticate step, which runs before any credential exists.)

- name: Prepare and verify the release tarball
run: pnpm run release:pack -- --require-clean --require-main-ancestor --require-release-tag --expected-release-commit "${RELEASE_COMMIT}" --output .release
- name: Prepare the release tarball
run: pnpm run release:pack -- --require-clean --require-main-ancestor --expected-release-commit "${RELEASE_COMMIT}" --output .release

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 --expected-release-commit in the pack step is now a no-op (nit)

The pack step still reads pnpm run release:pack -- --require-clean --require-main-ancestor --expected-release-commit "${RELEASE_COMMIT}" --output .release (.github/workflows/publish.yml:122), but this PR removed --require-release-tag, and expectedReleaseCommit is only ever consumed inside validateReleaseTag, which validateRepository invokes solely under requireReleaseTag (scripts/release-packages.mjs:592-597). Nothing in the pack path reads the flag any more.

The flag therefore advertises a pack-time binding of the prepared artifact to the release-event commit that no longer executes; a reader or future editor of the workflow will reasonably assume the check is live. The binding does still hold transitively (authenticate verifies tag commit == github.sha, checkout is at github.sha, and the publish job's verify compares manifest.gitCommit to RELEASE_COMMIT), so this is a misleading-flag cleanup rather than a hole — the misleading part is the cost.

for (const field of DEPENDENCY_FIELDS) {
const dependencies = manifest[field];
if (field === "dependencies" && !isPlainRecord(dependencies)) {
fail(`${label} dependencies must be an object`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 validatePackageManifest refuses a package with no dependencies field (nit)

In the DEPENDENCY_FIELDS loop (scripts/release-packages.mjs:482-486), the dependencies branch evaluates !isPlainRecord(manifest.dependencies) before the if (dependencies === undefined) continue; escape, so an absent dependencies field fails with "<label> dependencies must be an object" — a message about a field that is not there.

The surrounding code disagrees about whether absence is legal: validateRepository calls assertPnpmLockfileSynchronized(..., manifest.dependencies ?? {}), explicitly tolerating a missing field, and optionalDependencies/peerDependencies may be absent. So a future @​pegma/* package with no runtime dependencies (or its packed manifest, since the same validator now runs on the packed copy in prepareRelease) can never pass release:check, and the packed-manifest comparison path inherits the same trap.

Today packages/audit/package.json has dependencies, so nothing currently breaks; the inconsistency is latent but the error path is reachable by any dependency-free package this single-package validator is pointed at.

@FlyOverCoderKY
FlyOverCoderKY merged commit 5f102f1 into main Nov 6, 2026
3 checks passed
@FlyOverCoderKY
FlyOverCoderKY deleted the claude/harden-release-and-details-validation branch November 6, 2026 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant