Skip to content

Inspect bounded package, SBOM, ELF and Sharp source evidence - #10

Merged
CompleteDotTech merged 5 commits into
mainfrom
feat/local-evidence-adapters
Oct 25, 2026
Merged

CompleteDotTech merged 5 commits into
mainfrom
feat/local-evidence-adapters

Conversation

@CompleteDotTech

Copy link
Copy Markdown
Contributor

Fill node2shell-check#6's missing local evidence adapters. Add explicit npm lock v1/v2/v3 and CycloneDX/SPDX package metadata, bounded ELF32/64 header/program/interpreter inspection, and import-associated Sharp input/block/unblock lexical candidates. All locations are relative to an explicit evidence root, and all adapter rows remain unknown/not_tested; they do not establish deployed library selection, provenance, PIE/libc, effective mitigation or input trust.

Preserve the existing report contract, input-alias/output publication safeguards and standalone distribution. Extend the deterministic builder with src/adapters.py and rebuild/checksum the executable. Advisory ranges, rule snapshot and native affected-range uncertainty are unchanged. Documentation specifies exact formats, parser bounds, limitations and primary format sources.

Validation: 69 local synthetic Python 3.14 tests pass (three platform skips), including ELF class/endian/layout, malformed headers/segments/duplicates, npm link/instance and SBOM observations, source inactivity/candidates, no execution, relative paths, output protection/parity and standalone execution. Build/checksum check, real CLI help, documented synthetic JSON/HTML examples, relative links and git diff --check pass. GitHub Copilot review and exact-head hosted CI are required before merge.

Refs CompleteTech-Security/node2shell-check#6

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.

🟡 Changes recommended

SBOM parsing can raise uncaught errors for malformed fields and omit valid CycloneDX subject-component evidence.

2 open issues
What changed in this PR

This PR extends the offline Sharp/librsvg evidence checker with explicit local metadata and source adapters. Observations remain separate unknown records and do not establish runtime selection, mitigation or exploitability.

Changes:

  • Add bounded npm lock, CycloneDX/SPDX, ELF and Sharp source inspection.
  • Integrate adapter inputs with existing reporting and input-protection safeguards.
  • Update the standalone build, checksum, synthetic tests, examples and documentation.
File Description
tools/​build.py Include adapters in the standalone build.
test_adapters.py Add synthetic adapter and report-protection tests.
src/​checker.py Add adapter options and result integration.
src/​adapters.py Implement bounded metadata and source inspection.
sharp_rsvg_rce_check.py Regenerate the standalone checker with adapters.
SHA256SUMS Update the executable checksum.
README.md Document adapter usage, limits and uncertainty.
examples/​source.example.js Add a synthetic Sharp source fixture.
examples/​package-lock.example.json Add a synthetic npm lock fixture.
docs/​REFERENCE.md Specify adapter formats and bounds.
docs/​METHODOLOGY.md Clarify adapter evidence limitations.
docs/​IMPLEMENTATION.md Record adapter implementation and verification requirements.
AGENTS.md Add adapters to the project map.

Review effort: Balanced

Comment thread src/adapters.py Resolved
Comment thread src/adapters.py 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.

🔵 Needs a closer look

The new parsers require final human review, with unresolved evidence-loss issues and exact-head hosted CI still unverified.

No open issues 🎉

2 previously missed issues

In code that hasn't changed since last review

Medium severity Detect npm v1 aliases and preserve Sharp observations

src/​adapters.py:128

An npm v1 alias such as dependencies: {"image": {"version": "npm:sharp@0.35.4"}} produces only a no-observation coverage row because neither name comparison matches. Recognize the explicit alias target and retain a separate Sharp observation while keeping its qualified version uncertain. Add a v1 alias regression and rebuild sharp_rsvg_rce_check.py and SHA256SUMS.

Medium severity Normalize JavaScript line terminators before lexing

src/​adapters.py:257

With CR-, U+2028- or U+2029-separated JavaScript, a leading // comment consumes the subsequent Sharp import and call because the lexer recognizes only LF, losing candidate evidence. Normalize JavaScript line terminators before lexing, counting CRLF once, and add regression cases. Rebuild sharp_rsvg_rce_check.py and SHA256SUMS so standalone users receive the same fix.

2 resolved since last review

Review effort: Balanced

Copy link
Copy Markdown
Contributor Author

Addressed both previously missed observations in c10dd1b: npm v1 alias targets retain separate uncertain Sharp observations, and the lexer normalizes CRLF/CR/U+2028/U+2029 before scanning/comments/line counting. Added alias and line-terminator fixtures and rebuilt the standalone checker/checksum; all 70 local tests pass.

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.

🟡 Changes recommended

The ELF reader bypasses existing file-opening safeguards and rejects valid unused program-header entries.

1 open issue
1 previously missed issue

In code that hasn't changed since last review

Medium severity Skip PT_NULL entries before ELF segment bounds checks

src/​adapters.py:52

The range check rejects valid ELF files when a PT_NULL entry's unused offset or size exceeds the file length, causing the assessment to exit with code 2. Skip PT_NULL entries, whose remaining fields are undefined, while retaining bounds checks for actual segments. Add a regression and regenerate sharp_rsvg_rce_check.py and SHA256SUMS.

Review effort: Balanced

Comment thread src/adapters.py 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.

🔵 Needs a closer look

The new parsers require final human review, with a confirmed lexer defect unresolved and exact-head hosted CI not independently verified.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Recognize => before fallback to avoid regex false positives

src/​adapters.py:254

The => regex case is unreachable because the lexer emits = and > separately. As a result, const pattern = () => /const image = require('sharp'); image(input)/; produces a Sharp call candidate from text entirely inside a regex literal. Recognize => before the single-character fallback, add a regression, and rebuild sharp_rsvg_rce_check.py and its checksum.

1 resolved since last review

Review effort: Balanced

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.

🔵 Needs a closer look

The new binary, metadata and source parsers warrant final human review despite no retained blocking findings.

No open issues 🎉

Review effort: Balanced

Copy link
Copy Markdown
Contributor Author

Final verification at cf875c7: GitHub Copilot rereview has no retained blocking findings; all three inline threads are resolved. Addressed malformed SBOM types, CycloneDX subject components, npm-v1 aliases, JavaScript line terminators/arrow-return regex opacity, regular-file identity/symlink protections and PT_NULL handling. All 72 local synthetic tests pass (three platform skips), standalone deterministic build/checksum and diff checks pass, and all six Python/OS configurations passed hosted CI on the exact head. Adapter evidence remains unknown/not_tested and primary advisory thresholds/date are unchanged. No real target/native code was run.

@CompleteDotTech
CompleteDotTech merged commit 7da4608 into main Oct 25, 2026
13 checks passed
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