Skip to content

feat(supply-chain): inspect locked npm dependency contents - #952

Merged
rng1995 merged 10 commits into
NVIDIA:mainfrom
YMuskrat:ymuskrat/inspect-npm-dependency-contents
Oct 31, 2026
Merged

rng1995 merged 10 commits into
NVIDIA:mainfrom
YMuskrat:ymuskrat/inspect-npm-dependency-contents

Conversation

@YMuskrat

Copy link
Copy Markdown
Contributor

Fixes #951

SkillSpector checks dependency declarations against advisories and supply-chain rules, but does not automatically inspect the code shipped in external packages. A package with no advisory can therefore contain a credential-stealing installation hook without its contents being examined.

Add opt-in --inspect-dependencies for package-lock.json and npm-shrinkwrap.json v2/v3. Inspect recorded registry packages, including transitive, development, optional and aliased installations, without resolving new versions, installing packages or executing their code. Verify SHA-512 integrity before passing a tarball to a disposable worker; report the package identity, artifact SHA-256 digest, lock references and source locations with its findings.

This first version supports credential-free HTTPS tarballs from the public npm registry and Linux x86-64/AArch64 seccomp isolation. The downloader pins validated public addresses, preserves TLS verification, rejects redirects, and ignores host proxy/registry credentials. The worker closes extra descriptors, denies filesystem/network/process access, enforces CPU/memory/output limits, and reads archives entirely in memory. It applies existing data-exfiltration, privilege-escalation and supply-chain patterns to supported UTF-8 source and decoded npm scripts. Dependency contents remain local; this pass does not perform LLM or YARA analysis.

Missing or stale locks, unsupported sources/content, integrity or identity mismatches, unavailable isolation, malformed archives and exhausted budgets remain incomplete in the existing ledger and coverage inventory. Incomplete inspection prevents a SAFE recommendation; --fail-on-incomplete also fails the CLI. Reports explicitly show when dependency inspection was not requested. The flag propagates through recursive and external-reference scans; registry mode rejects it.

Coverage is limited to recorded locked artifacts and supported static analysis. Integrity does not establish package trust, and inspection does not certify install-graph completeness or inspect code fetched/generated at runtime.

Validation:

  • 63 new dependency-inspection cases passed across source runs and targeted retries, including real isolated workers, JavaScript exfiltration, lifecycle command locations, hostile archives, integrity failures, budgets, DNS/redirect handling and all report formats.
  • All 63 cases also passed against a fresh, noneditable wheel installation.
  • Integration suite: 241 passed, 5 skipped; repeated with the repository's locked dependencies.
  • Unit validation: 16,171 cases passed across the full run and targeted retries after correcting local test dependencies. Five remaining tests reproduce on unchanged main: three batch tests require sockets denied in this environment, and two uv execution tests require unavailable /tmp paths. 23 skipped and 4 expected failures.
  • Formatting, lint, format check, wheel build and clean-base patch application passed.
  • Live npm acquisition could not be exercised because registry DNS is unavailable in this environment; network behavior uses deterministic HTTP tests.

See docs/DEPENDENCY_CONTENT_INSPECTION.md for supported sources, platforms, limits and configuration.

Document the opt-in dependency inspection mode and its initial support boundaries.

Signed-off-by: YMuskrat <[email protected]>
Document supported artifacts, isolation, completeness semantics, and configurable limits.

Signed-off-by: YMuskrat <[email protected]>
Add bounded artifact acquisition, SHA-512 verification, isolated static inspection, canonical completeness accounting, and CLI/workflow integration.

Signed-off-by: YMuskrat <[email protected]>
Include dependency inspection results in the report and preserve completeness gates.

Signed-off-by: YMuskrat <[email protected]>
Cover integrity, archive isolation, provenance, budgets, unsupported content, and completeness behavior with 63 cases.

Signed-off-by: YMuskrat <[email protected]>

@rng1995 rng1995 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.

[SkillSpector Review]

Value and readiness

The opt-in artifact/integrity/isolated-worker design is coherent and addresses #951 with explicit unsupported-content accounting. One host acquisition bound is not enforced under slow streaming, so this head is not ready.

Material findings

  1. Required: enforce a total acquisition deadline independently of buffered HTTP iteration. src/skillspector/dependency_inspection.py:323-340 uses a per-read HTTPX timeout and only checks the absolute deadline after response.iter_raw(chunk_size=64 * 1024) yields. HTTPX 0.28.1 buffers that iterator until a full 64 KiB chunk or EOF; a server delivering one byte per second stays under the 10-second read timeout but prevents the deadline check from running for roughly 18 hours. There is no outer timeout around host HTTP acquisition, so the advertised 120-second dependency/shared workflow limit can be exceeded dramatically before the restricted worker even starts. Iterate unbuffered transport chunks and apply a real total acquisition deadline (including headers), for example a separately timed downloader process. Add a deterministic slowly yielding transport/clock regression that proves timeout before the first 64 KiB and preserves incomplete accounting. Primary library evidence: Response.iter_raw uses ByteChunker, whose decode method returns no chunks below the configured threshold.

PIC tradeoffs

Linux/public-npm-only support, unsupported workspace links, local-only static modules, lack of YARA/LLM dependency analysis and failure-closed unsupported assets are explicit first-version choices. Integrity binds bytes to locks and does not certify install-graph completeness. Static review found no immediate seccomp escape; this is not a runtime isolation guarantee.

Verification and gaps

Read the complete diff, #951, every new test and pinned host/worker/sandbox/graph/state/report/CLI context. Traced URL/DNS pinning, SRI/identity checks, archive path/type/trailing-payload checks, budgets, protocol validation, member/summary ledger outcomes, recursive/transitive flag propagation and local-only meta-analyzer eligibility. Inspected primary HTTPX 0.28.1 source as data to verify buffering semantics. Existing network tests return immediate bytes and do not cover the deadline gap. Live registry acquisition is also explicitly unverified by the author. Hosted checks: changes SUCCESS, lint SUCCESS, test-unit IN_PROGRESS, OpenCode TypeScript Tests SUCCESS, DCO Check SUCCESS, docker-smoke SUCCESS. This is a read-only static review; no contributor code, tests, imports, builds or scanner invocations were executed.

Reviewed head: 61ab8ed3dfb212c85ca96e2d9d06445804981d68.

Run HTTP acquisition in a disposable subprocess with the remaining absolute deadline, including headers and cleanup. Stream raw transport chunks without buffering and conservatively charge failed acquisition.

Add regressions for one-byte streams, stalled headers/body, DNS deadlines, subprocess delivery, and incomplete accounting. Document the enforced acquisition boundary.

Validation: deadline regressions passed on source and a fresh wheel; 241 integration tests passed, 5 skipped; lint, formatting, and wheel build passed.

Signed-off-by: YMuskrat <[email protected]>
SanHsien added a commit to SanHsien/SkillSpector that referenced this pull request Oct 30, 2026
…NVIDIA#951; defer the 52 commits

The v2.13.x releases sit on a maintenance branch and are not adopted. The 52 commits on main are
deferred as a batch, not judged one by one, and the commit watermark stays at d7338f5; the
roadmap gains a row for the per-commit review.

Executed from the roadmap's near-term table; the finished row is removed in
the same commit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: SanHsien <[email protected]>

@rng1995 rng1995 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.

[SkillSpector Review]

Value and readiness

The previous total-acquisition-deadline blocker is fixed, including headers, body streaming and client cleanup. This head still fails eight new positive detection regressions in its hosted Linux unit job, so the feature is not ready to approve.

Material findings

  1. Required: restore the supported isolated worker's positive detections and pass these meaningful regressions. At head 226cfaa, test-unit job 123686383161 fails tests/unit/test_dependency_inspection.py:246 (real transitive JavaScript worker returns no E1/E2), :267 (decoded lifecycle command has no SC2), :811 (no E2 through JSON, SARIF, Markdown and terminal), :928 (decoded nested script loses SC2), and :970 (earlier E2 is absent in the later-failure preservation case). These are eight feature-contract assertions, not timeout/timing failures. The direct worker tests return structured files, whereas unavailable isolation would raise dependency_sandbox_unavailable; the benign-worker test with limitations == [] and archive rejection tests pass. That evidence does not establish the internal failure cause, but it does show the positive security path is unqualified on the advertised Linux/Python 3.12 environment. Correct the worker/analyzer integration while preserving isolation and these detection assertions, include returned limitation/error details in failing-test diagnostics, and obtain a passing exact-head unit run. Do not weaken or skip the positive cases to make CI green.

PIC tradeoffs

The public-npm/Linux scope, unsupported workspace links, local-only static module selection and lack of dependency YARA/LLM analysis remain explicit initial scope choices. Failed child acquisition now conservatively charges its full byte grant, which may stop later downloads earlier but prevents allowance renewal after unknown partial transfers.

Verification and gaps

Read the complete current change and exact delta from the previous review, all review/discussion records, added downloader module and every new deadline test. Verified subprocess.run receives time remaining after DNS and kills/reaps the downloader; unbuffered raw chunks, post-header/EOF/cleanup deadline checks, timeout/exit-code accounting and strict incomplete inventory survive. New tests cover trickling bytes, stalled headers/body, delayed EOF/close, successful output and shared-budget charging. Inspected read-only exact-head hosted failure logs, worker protocol and finding-emission paths; no unproven syscall or infrastructure diagnosis is asserted. Live registry acquisition and worst-case isolation behavior were not independently exercised. Fresh exact-head hosted checks: changes SUCCESS, lint SUCCESS, test-unit FAILURE, OpenCode TypeScript Tests SUCCESS, DCO Check SUCCESS, docker-smoke SUCCESS. Read-only static review: no contributor code, tests, snippets, imports, builds or scanner invocations were executed.

Reviewed head: 226cfaa52644eff9d93c4a0ee571ecd3b8da7d2f.

Show worker limitations and incomplete work in positive detection assertions. Require E1, E2 and SC2 findings under the existing sandbox while retaining filesystem, network and process denial checks. Run dependency inspection regressions before the full CI suite.

Validation: all 78 dependency inspection tests passed locally on Python 3.12.13; Ruff lint, format checks and patch checks passed. The hosted detection failure remains under investigation.

Signed-off-by: YMuskrat <[email protected]>
Exercise the real worker entrypoint when checking positive detections and denied host access, so its resource and descriptor setup is covered. Preserve captured stderr and render incomplete-work diagnostics without repr truncation.

Signed-off-by: YMuskrat <[email protected]>
Hosted worker diagnostics show that finding UUID creation attempts to open /dev/urandom after seccomp denies filesystem access. Seed a worker-local SHA-256/counter identity source before descriptor closure, and scope its use to archive inspection through a task-local finding-ID factory. Ordinary scans keep UUID identities.

Keep the syscall policy, descriptor closure and resource limits unchanged. Exercise the actual worker bootstrap, deny runtime entropy in the regression, retain E1/E2/SC2 detection assertions and verify that file, network and process access remain blocked. Cover nested factory restoration after exceptions.

Signed-off-by: YMuskrat <[email protected]>
Normalize the byte-string quote style required by Ruff 0.15.19. No test behavior changes.

Validation: Ruff lint and format checks passed across src/ and tests/; git diff --check passed.

Signed-off-by: YMuskrat <[email protected]>

@rng1995 rng1995 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.

[SkillSpector Review]

Value and readiness

Ready on this head. Both prior blockers are resolved: HTTP acquisition retains a hard parent-enforced deadline, and the isolated worker now emits its required positive security findings without needing entropy after restriction.

Material findings

No new or still-open required changes found. The worker seeds an identity source before closing descriptors/installing seccomp, then scopes hash-and-counter IDs through a ContextVar while inspecting the archive; ordinary Finding identities remain unchanged outside that scope. The original E1/E2/SC2 assertions and all-format/preservation checks are retained. The strengthened real-bootstrap test additionally denies os.urandom after isolation, requires E1/E2/SC2 with no limitations, and simultaneously proves filesystem/network/process denial. Exact-head hosted execution now passes those acceptance cases.

PIC tradeoffs

The Linux/public-npm and local static-analysis scope remains explicit; unsupported sources/content and exhausted budgets remain incomplete. The ID factory avoids broadening sandbox permissions and resets on nested/exceptional scope exit. Integrity binds artifacts to locks and does not establish publisher trust or install-graph completeness.

Verification and gaps

Read the complete current change and exact 226cfaa-to-6a041808 delta, all prior reviews and discussion, pinned host/downloader/worker/sandbox/model/graph/report/CLI context, and every new regression assertion. Verified the seccomp allowlist and downloader deadline/accounting were not relaxed to repair detections. Read the actual hosted job log: the isolated dependency suite ran 79 tests with 79 passing and no skips, then the full unit run reported 16,338 passed, 24 skipped and 4 expected failures. This verifies the prior eight acceptance failures were exercised successfully rather than removed or skipped. Live registry acquisition remains unverified as already documented. Hosted exact-head checks: changes SUCCESS, lint SUCCESS, test-unit SUCCESS, OpenCode TypeScript Tests SUCCESS, DCO Check SUCCESS, docker-smoke SUCCESS. This was a read-only static review; no contributor code, tests, snippets, imports, builds or scanner invocations were executed.

Reviewed head: 6a041808a83a8d75e93d715f2795cf9ed15dc11b.

@rng1995
rng1995 merged commit bd6edea into NVIDIA:main Oct 31, 2026
6 checks passed
rng1995 pushed a commit that referenced this pull request Nov 2, 2026
* feat(supply-chain): document locked npm content inspection

Document the opt-in dependency inspection mode and its initial support boundaries.

Signed-off-by: YMuskrat <[email protected]>

* docs: define npm inspection scope and resource limits

Document supported artifacts, isolation, completeness semantics, and configurable limits.

Signed-off-by: YMuskrat <[email protected]>

* feat(supply-chain): inspect locked npm dependency contents

Add bounded artifact acquisition, SHA-512 verification, isolated static inspection, canonical completeness accounting, and CLI/workflow integration.

Signed-off-by: YMuskrat <[email protected]>

* feat(report): expose dependency inspection status

Include dependency inspection results in the report and preserve completeness gates.

Signed-off-by: YMuskrat <[email protected]>

* test(supply-chain): cover locked npm inspection

Cover integrity, archive isolation, provenance, budgets, unsupported content, and completeness behavior with 63 cases.

Signed-off-by: YMuskrat <[email protected]>

* fix(supply-chain): enforce total dependency acquisition deadline

Run HTTP acquisition in a disposable subprocess with the remaining absolute deadline, including headers and cleanup. Stream raw transport chunks without buffering and conservatively charge failed acquisition.

Add regressions for one-byte streams, stalled headers/body, DNS deadlines, subprocess delivery, and incomplete accounting. Document the enforced acquisition boundary.

Validation: deadline regressions passed on source and a fresh wheel; 241 integration tests passed, 5 skipped; lint, formatting, and wheel build passed.

Signed-off-by: YMuskrat <[email protected]>

* test(supply-chain): expose isolated detection failures early

Show worker limitations and incomplete work in positive detection assertions. Require E1, E2 and SC2 findings under the existing sandbox while retaining filesystem, network and process denial checks. Run dependency inspection regressions before the full CI suite.

Validation: all 78 dependency inspection tests passed locally on Python 3.12.13; Ruff lint, format checks and patch checks passed. The hosted detection failure remains under investigation.

Signed-off-by: YMuskrat <[email protected]>

* test(supply-chain): diagnose the complete sandbox bootstrap

Exercise the real worker entrypoint when checking positive detections and denied host access, so its resource and descriptor setup is covered. Preserve captured stderr and render incomplete-work diagnostics without repr truncation.

Signed-off-by: YMuskrat <[email protected]>

* fix(supply-chain): seed worker finding identities before isolation

Hosted worker diagnostics show that finding UUID creation attempts to open /dev/urandom after seccomp denies filesystem access. Seed a worker-local SHA-256/counter identity source before descriptor closure, and scope its use to archive inspection through a task-local finding-ID factory. Ordinary scans keep UUID identities.

Keep the syscall policy, descriptor closure and resource limits unchanged. Exercise the actual worker bootstrap, deny runtime entropy in the regression, retain E1/E2/SC2 detection assertions and verify that file, network and process access remain blocked. Cover nested factory restoration after exceptions.

Signed-off-by: YMuskrat <[email protected]>

* style(tests): apply Ruff formatting to the worker fixture

Normalize the byte-string quote style required by Ruff 0.15.19. No test behavior changes.

Validation: Ruff lint and format checks passed across src/ and tests/; git diff --check passed.

Signed-off-by: YMuskrat <[email protected]>

---------

Signed-off-by: YMuskrat <[email protected]>
(cherry picked from commit bd6edea)
Signed-off-by: Narendran Raghavan <[email protected]>
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.

Inspect locked npm dependency contents as an opt-in scan

2 participants