Skip to content

Security scan: resolve findings (2026-07-29) - #2

Merged
FlyOverCoderKY merged 2 commits into
mainfrom
claude/security-scan-fixes
Jul 30, 2026
Merged

FlyOverCoderKY merged 2 commits into
mainfrom
claude/security-scan-fixes

Conversation

@FlyOverCoderKY

Copy link
Copy Markdown
Contributor

Re-examined every finding in docs/securityscan.md against the code. Seven were
valid and are fixed with tests; three are disputed in the report with reasoning.
@pegma/audit is bumped to 0.1.1.

Disposition

# Severity Finding Disposition
1 Low __proto__ keys in details silently dropped Fixed
2 Low occurredAt accepts non-ISO-8601 strings Fixed
3 Low decodeAuditEvent decodes malformed records into plausible events Fixed
4 Low Release validation does not forbid install-time lifecycle scripts Fixed
5 Low Windows runNpm fallback uses shell: true with unescaped arguments Fixed
6 Low Release workflow installs npm@11.18.0 without an integrity pin Fixed
7 Informational sweep limit of NaN bypasses the guard Fixed
8 Informational Smoke test installs sibling dependencies without a lockfile Disputed
9 Informational Unbounded partition reads and details size Disputed
10 Informational Unbounded exports recursion in release validation Disputed

Fixed

1 — __proto__ detail keys. requireDetails built its copy with
copied[key] = value, which for __proto__ calls the inherited setter instead
of storing the detail. JSON.parse produces that key as an own property, so the
decode 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 own
key survives whatever it is called.

2 — non-ISO occurredAt. Validation was Number.isNaN(Date.parse(text)),
which also accepts implementation-defined formats: March 3, 2020 was stored
verbatim 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:00Z is still refused.

3 — lenient decode. Any stored auditActorKind other than "system"
decoded as a principal, inventing an actor, and String(...) turned a null or
missing field into "null"/"undefined", which then passed the non-empty-string
check. Stored fields must now be non-empty strings and the actor kind must be
exactly principal or system; a corrupt row raises AuditError. Everything
encodeAuditEvent writes still round-trips unchanged.

4 — install-time lifecycle scripts. validateRepository asserted prepack
but constrained nothing else in scripts. package.json is always packed, so
the files allowlist places no constraint on a postinstall, and the smoke
test installs with --ignore-scripts and so would not reveal one either. A
findInstallTimeScript helper now rejects preinstall, install, and
postinstall, with its own unit test.

5 — shell: true in runNpm. The fallback is removed rather than quoted:
runNpm requires npm_execpath, which every release entry point sets by being
an 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.cmd without shell: true (EINVAL),
and Node now deprecates passing arguments alongside shell: true (DEP0190) for
exactly 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 installing
it. A test asserts the workflow uses the reviewed constants and no longer
installs the bare registry spec.

7 — NaN sweep limit. NaN <= 0 is false, so limit: NaN passed the
guard, and deleted >= NaN is also false, so the limit never bound and one call
swept the whole partition. limit is the only bound on a permanent deletion, so
it 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-scripts blocks install-time
hooks, and — checked against the code — prepareRelease hashes the tarball
before smokeTestTarball runs while verifyPreparedManifest re-hashes it in
the 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 details size. Neither quantity is
attacker-amplified, and neither can be bounded here without breaking a stated
design rule. history and sweep read one partition because storage-core's
list is 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.md says the design cannot
absorb. Partition names and details contents are chosen by the trusted caller,
and SECURITY.md already assigns both to the host. AGENTS.md documents
one-partition-at-a-time reads as a known gap.

10 — unbounded exports recursion. exportTargets only ever walks the
exports object of packages/audit/package.json, a repository-controlled file
authored 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/audit 0.1.0 → 0.1.1, with package-lock.json synchronized. No
public 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-integer
sweep limit now receives an AuditError where it previously received a
silently degraded result. Nothing encodeAuditEvent produces is affected.

Checks

npm ci, npm run format:check, npm run check, npm test (30/30, up from
24), and npm run release:check all pass locally on Node 24.18.0, and
npm run release:pack produces and smoke-tests a valid 0.1.1 tarball.
docs/securityscan.md also needed a Prettier table reformat, which was already
failing format:check on main.

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings July 30, 2026 00:35
@cursor

cursor Bot commented Jul 30, 2026

Copy link
Copy Markdown

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.

@github-actions

github-actions Bot commented Jul 30, 2026 •

Copy link
Copy Markdown

Grok Grok Build Review — no issues

Review complete. No issues found — the changes look solid.

The seven fixes are implemented at the correct boundaries and match the failure modes described in the security scan: details key preservation, ISO timestamp acceptance, strict decode, install-time script refusal, removal of the shell-based npm fallback, integrity-pinned npm CLI install, and a safe-integer sweep limit. The three disputed items are correctly treated as non-actionable under this package’s atomicity and trust model. No defects that would block merge were identified.

Reviewed commit 88f556c · workflow run

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 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".

Comment thread packages/audit/src/index.ts Resolved

Copilot AI 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.

🟢 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/audit to 0.1.1 and 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.

Comment thread docs/securityscan.md Resolved
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>
@FlyOverCoderKY
FlyOverCoderKY merged commit d53322e into main Jul 30, 2026
5 checks passed
@FlyOverCoderKY
FlyOverCoderKY deleted the claude/security-scan-fixes branch July 30, 2026 00:50
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.

2 participants