Skip to content

fix(package): scan semantic content for internal references - #618

Open
mldangelo-oai wants to merge 10 commits into
mainfrom
mdangelo/codex/fix-package-semantic-content-scan
Open

fix(package): scan semantic content for internal references#618
mldangelo-oai wants to merge 10 commits into
mainfrom
mdangelo/codex/fix-package-semantic-content-scan

Conversation

@mldangelo-oai

@mldangelo-oai mldangelo-oai commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

Scan the semantic contents of the npm package so marker-like compressed bytes do not reject a clean release. Continue checking paths, headers, text and decompressed bundled code.

Changes

  • Validate the controlled plain-ustar format before native extraction, then verify the extracted regular files and sizes. Keep private temporary storage and cleanup.
  • Read each archive once and pass it to tar through stdin, preserving Windows paths and executable lookup behavior.
  • Accept the two octal size-field layouts actually emitted by npm and pnpm. A fresh npm 11.12.1 artifact exposed the prior parser mismatch.
  • Share the dist-file contract and tar-fixture builders. Remove two duplicate functions and ten net lines while retaining the archive and disclosure checks.
  • Current main is already included. Bundled plugin contents and versions are unchanged by this update.

Testing

  • Final release integration updates the synthetic archive fixture to include the executable MCP launcher now required by main, sharing its plugin contract across tests. The two failing positive cases pass after the fixture correction; the permission check and archive/disclosure protections are unchanged.

  • Five focused suites, seed 618: 27 passed. The npm size-field unit and end-to-end regressions failed before the fix and passed afterward.

  • Fresh npm 11.12.1 and pnpm 11.9.0 artifacts both passed the 282-entry package check. Full installed npm smoke passed with 118 plugin files.

  • Types, generated models, formatting and build passed.

  • The full pnpm check-package entrypoint, including installed smoke, passed. Full suite, native Windows and Node 22 were not rerun.

  • The prior workflow was cancelled; its four red checks were aggregate coverage gates. New-head CI is left for a separate pass.

  • Final main refresh (fd98a90): package 0.1.21 includes the MCP launcher-permission fix; SDK implementation and bundled payload are unchanged. Types/model generation, formatting, build, 44 focused tests, static artifact verification and full installed-package smoke passed, including MCP initialization. CI was not awaited.

Risk and rollout

This is a package-validation change, not a general tar parser. Unsupported tar forms still fail; path/type checks, extraction agreement, expanded-size bounds, PNG digests and complete Brotli consumption remain. Keep the existing squash-only integration guidance for this branch. No package was published and no PR was merged.

Public disclosure review

  • No customer, partner, prospect, or user identities, data, or identifying details are included.
  • No credentials, personal data, private source, scan findings, or nonpublic links or tickets are included.
  • I reviewed the branch name, title, description, commits, changes, comments, logs, screenshots, attachments, and links for public disclosure.

Existing automated comments link to account-gated Codex settings, so the second attestation is left unchecked. This update uses synthetic fixtures and a GitHub noreply commit identity; other authors' comments are unchanged.

@github-actions github-actions Bot added the bug Something isn't working label Aug 23, 2026
@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 23, 2026

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-27T08:58:10.828678Z 1239bee New commits
🔒 Security Review Completed 2026-08-23T19:52:42.362463Z 6d0bc65 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 6d0bc657c1

ℹ️ 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".

@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: fd44228f5b

ℹ️ 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".

@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 35cc277e85

ℹ️ 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".

@kmbroai kmbroai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Critical review

Reviewed head 35cc277e85843e61a6cd55a051f4425bc9fdd6d7.

Recommendation: keep semantic-content scanning; no new blocking correctness defect found in the reviewed changes. Decoding compressed archive bytes as text can reject a clean package because of coincidental byte sequences. Scanning filenames, actual text, and decompressed bundled code fixes the right problem without weakening the intended disclosure check.

Correctness

check-package.mjs validates the closed archive format before extraction, compares the native tar listing with parsed paths, verifies the extracted tree and sizes, and cleans up in finally. Scanning complete headers retains metadata coverage, while PNGs remain restricted to the known digest instead of arbitrary text interpretation. The Brotli helper checks decompression consumption, so trailing data is not silently ignored.

Passing the already-read archive on stdin avoids Windows drive-letter interpretation and a separate path reread. Keeping the caller's working directory also avoids accidentally selecting a relative-PATH executable from beside the archive. The --ignore-zeros use is acceptable here specifically because the preceding parser proves the remainder is zero padding; it should not be copied to an unconstrained archive reader.

Simplification and necessity

The semantic scanner is the essential fix. The extra parser/extractor agreement is defensible only as validation of this package's controlled plain-ustar contract—not as a general tar library. Preserve that narrow scope. An npm pack-format change should cause one explicit compatibility update, not accumulate ad hoc support for every extension.

There are three native tar passes plus the in-memory parser and filesystem walk. I would avoid adding further independent interpretations. If this becomes costly to maintain, evaluate a single maintained archive reader with equivalent path/type/metadata guarantees; do not simply remove checks while retaining native extraction. The existing expanded-size bound is unchanged by this PR and is not a newly introduced scan-input cap.

Verification

Ran the five focused package helper suites: 25 passed, 0 failed, 72 assertions, including binary-marker false positives, decompressed content, tar forms/listing, provenance, and timeout helpers. Linux with Bun 1.3.14 / Node 22.13.1 and cached dependencies. I did not independently rebuild the full npm archive, run installed-package smoke, or execute native Windows/macOS packaging, so the author's broader artifact claims are not my verification results.

@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: f561a80ed7

ℹ️ 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".

@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: 1239beeb4e

ℹ️ 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".


assertNoInternalReference(header);
if (
header[156] !== 0x30 ||

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Accept NUL regular-file typeflags

When an otherwise valid npm tarball uses the POSIX-compatible NUL typeflag for a regular file, this condition rejects it even though the system tar command accepts and extracts it; the previous parser explicitly treated both NUL and "0" as regular-file encodings. This representation-only restriction can therefore break check:package for installable archives produced by a different tar writer, so accept both regular-file typeflags while scanning their semantic content.

AGENTS.md reference: AGENTS.md:L19-L22

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants