Repository navigation
Security scan: resolve findings (2026-07-29) - #2
Conversation
Seven of the ten findings in docs/securityscan.md were valid and are fixed; three are disputed in the report with reasoning. Library: - `requireDetails` copies with `Object.defineProperty`, so a detail key that names an inherited accessor (`__proto__`, which `JSON.parse` produces as an own property) is stored instead of swallowed by the setter. - `requireTimestamp` requires an ISO 8601 date-time shape as well as a parsable instant, so `Date.parse`-only formats no longer enter a permanent record. - `decodeAuditEvent` requires stored fields to be non-empty strings and the stored actor kind to be exactly `principal` or `system`, rather than coercing a corrupt row into a plausible-looking event. - `sweep` validates a supplied `limit` as a positive safe integer, so `NaN` can no longer leave a permanent deletion unbounded. Release tooling: - `validateRepository` refuses a published manifest defining `preinstall`, `install`, or `postinstall`; `package.json` is always packed, so the `files` allowlist does not constrain them. - `runNpm` requires `npm_execpath` and never builds a shell command line. The removed Windows fallback passed unescaped arguments through `cmd.exe`. - The publish workflow verifies the npm CLI tarball against a reviewed sha512 before installing the tool that packs and publishes the release. Bumps @pegma/audit to 0.1.1. No public type or signature changes: validation is stricter, and every value the codec itself writes still round-trips. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0ff574a233
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
🟢 Ready to approve
The security fixes are narrowly scoped, fail closed, and are backed by targeted tests; only a minor documentation consistency nit was found.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Pull request overview
Addresses the 2026-07-29 security scan results for @pegma/audit by tightening validation in the audit codec and hardening the release pipeline, with additional tests and documentation updates. This fits the codebase’s focus on correctness/atomicity guarantees and on ensuring the release process fails closed.
Changes:
- Hardened audit event validation/decoding (strict ISO-8601 timestamps, faithful decoding of stored rows,
__proto__-safe details copying, and safe sweep limit validation). - Strengthened release tooling/workflow (forbid install-time lifecycle scripts; verify reviewed npm CLI tarball by integrity before installing).
- Updated tests and the security scan report; bumped
@pegma/auditto0.1.1and synchronized the lockfile.
File summaries
| File | Description |
|---|---|
| tests/release-packages.test.ts | Adds tests for install-time script refusal and reviewed npm tarball integrity pinning. |
| scripts/release-packages.mjs | Implements reviewed npm tarball integrity verification, removes unsafe runNpm fallback, and rejects install-time scripts. |
| scripts/release-packages.d.mts | Updates public typings for new --tarball option and new helper exports. |
| packages/audit/src/index.ts | Tightens timestamp validation, preserves __proto__ detail keys safely, makes decode fail closed on malformed rows, and hardens sweep limit validation. |
| packages/audit/src/index.test.ts | Adds regression tests for the tightened validation/decoding and sweep limit handling. |
| packages/audit/package.json | Bumps package version to 0.1.1. |
| package-lock.json | Synchronizes packages/audit version to 0.1.1. |
| docs/securityscan.md | Updates the scan summary and dispositions with resolved/disputed items. |
| .github/workflows/publish.yml | Downloads the npm CLI tarball and verifies it via release-packages.mjs verify-npm before installing globally. |
Review details
- Files reviewed: 8/9 changed files
- Comments generated: 1
- Review effort level: Low
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
Codex review: the shape check accepted a day past the end of its month, and `Date.parse` normalizes rather than refuses one, so `2026-02-30T00:00:00Z` parsed as March 2 and would have been kept forever as a day nothing happened on. Every other out-of-range component already makes `Date.parse` return `NaN`, so only the day-of-month needed the check. Also resolves the contradictory test count in docs/securityscan.md that Copilot flagged: the summary now marks 24/24 as the scan-time baseline and points at the post-fix 30/30 figure. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Re-examined every finding in
docs/securityscan.mdagainst the code. Seven werevalid and are fixed with tests; three are disputed in the report with reasoning.
@pegma/auditis bumped to0.1.1.Disposition
__proto__keys indetailssilently droppedoccurredAtaccepts non-ISO-8601 stringsdecodeAuditEventdecodes malformed records into plausible eventsrunNpmfallback usesshell: truewith unescaped argumentsnpm@11.18.0without an integrity pinsweeplimitofNaNbypasses the guarddetailssizeexportsrecursion in release validationFixed
1 —
__proto__detail keys.requireDetailsbuilt its copy withcopied[key] = value, which for__proto__calls the inherited setter insteadof storing the detail.
JSON.parseproduces that key as an own property, so thedecode path reached it too, and an event round-tripped as different bytes than
were submitted. The copy is now built with
Object.defineProperty, so every ownkey survives whatever it is called.
2 — non-ISO
occurredAt. Validation wasNumber.isNaN(Date.parse(text)),which also accepts implementation-defined formats:
March 3, 2020was storedverbatim in a record nothing in this package can correct afterwards. An ISO 8601
date-time shape (UTC designator or numeric offset) is now required in addition
to a parsable instant, so an in-shape but impossible value such as
2026-13-01T00:00:00Zis still refused.3 — lenient decode. Any stored
auditActorKindother than"system"decoded as a principal, inventing an actor, and
String(...)turned a null ormissing field into
"null"/"undefined", which then passed the non-empty-stringcheck. Stored fields must now be non-empty strings and the actor kind must be
exactly
principalorsystem; a corrupt row raisesAuditError. EverythingencodeAuditEventwrites still round-trips unchanged.4 — install-time lifecycle scripts.
validateRepositoryassertedprepackbut constrained nothing else in
scripts.package.jsonis always packed, sothe
filesallowlist places no constraint on apostinstall, and the smoketest installs with
--ignore-scriptsand so would not reveal one either. AfindInstallTimeScripthelper now rejectspreinstall,install, andpostinstall, with its own unit test.5 —
shell: trueinrunNpm. The fallback is removed rather than quoted:runNpmrequiresnpm_execpath, which every release entry point sets by beingan npm script, and never builds a shell command line. Worth noting that the
report's first suggestion is not implementable — since the fix for
CVE-2024-27980 Node refuses to spawn
npm.cmdwithoutshell: true(EINVAL),and Node now deprecates passing arguments alongside
shell: true(DEP0190) forexactly the reason the finding gives.
6 — unpinned npm CLI. The tool that packs and publishes the release was
fetched from the registry with only its version pinned, and everything
downstream is verified against metadata that same tool produces. The workflow
now downloads the tarball and verifies its sha512 against
REVIEWED_NPM_INTEGRITY(release-packages.mjs verify-npm) before installingit. A test asserts the workflow uses the reviewed constants and no longer
installs the bare registry spec.
7 —
NaNsweep limit.NaN <= 0is false, solimit: NaNpassed theguard, and
deleted >= NaNis also false, so the limit never bound and one callswept the whole partition.
limitis the only bound on a permanent deletion, soit is now validated as a positive safe integer and a refused sweep deletes
nothing.
Disputed
8 — smoke test without a lockfile. Accurate as a description, but there is
no weakness to close, and the report itself recommends no change. The prepare
job holds no secrets and no OIDC token,
--ignore-scriptsblocks install-timehooks, and — checked against the code —
prepareReleasehashes the tarballbefore
smokeTestTarballruns whileverifyPreparedManifestre-hashes it inthe publish job, so code executed during the smoke test cannot change what is
published without failing the release. A lockfile would not add a guarantee
either: the sibling versions are already exact-pinned in the package manifest.
9 — unbounded reads and
detailssize. Neither quantity isattacker-amplified, and neither can be bounded here without breaking a stated
design rule.
historyandsweepread one partition because storage-core'slistis explicitly unordered with no server-side filter or pagination;bounding a read would need a secondary index, which is a second collection with
its own atomicity problem — the one change
AGENTS.mdsays the design cannotabsorb. Partition names and
detailscontents are chosen by the trusted caller,and
SECURITY.mdalready assigns both to the host.AGENTS.mddocumentsone-partition-at-a-time reads as a known gap.
10 — unbounded
exportsrecursion.exportTargetsonly ever walks theexportsobject ofpackages/audit/package.json, a repository-controlled fileauthored by maintainers and reviewed before merge, so no untrusted input reaches
it. A stack overflow would abort validation and fail the release closed, which is
the direction a release check should fail. The report classifies it as a
robustness note rather than a vulnerability.
Version and migration impact
@pegma/audit0.1.0→0.1.1, withpackage-lock.jsonsynchronized. Nopublic type or signature changes; the diff is stricter validation only. Findings
2, 3, and 7 tighten what is accepted, so a caller already passing a non-ISO
occurredAt, reading a row this package did not write, or passing a non-integersweeplimit now receives anAuditErrorwhere it previously received asilently degraded result. Nothing
encodeAuditEventproduces is affected.Checks
npm ci,npm run format:check,npm run check,npm test(30/30, up from24), and
npm run release:checkall pass locally on Node 24.18.0, andnpm run release:packproduces and smoke-tests a valid0.1.1tarball.docs/securityscan.mdalso needed a Prettier table reformat, which was alreadyfailing
format:checkonmain.🤖 Generated with Claude Code