Skip to content

fix(enrichment): detect npm alias dependency targets for typosquat/confusion - #1724

Merged
JSONbored merged 1 commit into
mainfrom
codex/fix-npm-alias-dependencies-vulnerability
Jun 29, 2026
Merged

fix(enrichment): detect npm alias dependency targets for typosquat/confusion#1724
JSONbored merged 1 commit into
mainfrom
codex/fix-npm-alias-dependencies-vulnerability

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Motivation

  • Close a security-control bypass where npm alias dependency specifiers (e.g. "foo": "npm:attacker@1.0.0") were not parsed, so the analyzer never saw the real registry package and skipped typosquat and dependency-confusion checks.
  • Ensure the typosquat/dependency-confusion analyzer evaluates the actual package name and version that will be installed, preserving the existing semver parsing behavior.

Description

  • Change review-enrichment/src/analyzers/dependency-scan.ts to broaden the NPM_RE to capture the full package spec and add an NPM_ALIAS_RE to recognise npm:target@version alias specifiers and return the alias target name and version as the dependency entry.
  • Preserve existing behaviour for ordinary semver specs by keeping the semver guard and stripping leading semver operators when appropriate.
  • Add regression tests in review-enrichment/test/typosquat.test.ts including npmAliasAdd fixtures and tests that assert scanTyposquat now flags alias targets for both typosquat and dependency-confusion findings.

Testing

  • Ran the review-enrichment unit test suite with npm run test --prefix review-enrichment, which passed (all tests green, new alias-target tests included).
  • Verified git diff --check returned clean results locally.
  • Attempted the full local gate with npm run test:ci, but it could not be completed due to an environment/network blocker in actionlint (WASM fallback reported a pre-existing custom runner label in .github/workflows/self-host-nightly.yml).
  • Attempted npm audit --audit-level=moderate, which could not complete due to the npm registry audit endpoint returning 403 Forbidden in this environment.

Codex Task

@loopover-orb

loopover-orb Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-06-29 18:59:44 UTC

2 files · 1 AI reviewer · 1 blocker · readiness 86/100 · CI green · unknown

⏸️ Suggested Action - Manual Review

  • The AI review flagged a possible must-fix defect below the automatic close-confidence floor, so the gate is held for a human reviewer instead of passed automatically.

Review summary
The change correctly routes versioned npm alias specs like `"alias": "npm:target@​^1.0.0"` through `extractDependencyChanges`, so `scanTyposquat` now evaluates the installed target name rather than the alias key. The notable gap is that the alias parser only accepts aliases with an explicit target version, while npm accepts `npm:<name>` aliases and installs the default tagged package, so the bypass remains for a documented alias form.

Blockers

  • review-enrichment/src/analyzers/dependency-scan.ts:31 requires `npm:` aliases to contain a target-version separator, so a valid dependency like `"safe": "npm:l0dash"` falls through `parseLine` at `review-enrichment/src/analyzers/dependency-scan.ts:45` and the typosquat/confusion analyzer never sees `l0dash`.
Nits — 2 non-blocking
  • Update `NPM_ALIAS_RE` in `review-enrichment/src/analyzers/dependency-scan.ts:31` to allow a missing target version and decide explicitly what `DepChange.to` should be for that case, then add a regression in `review-enrichment/test/typosquat.test.ts` using `npmAliasAdd("lodash", "l0dash", undefined)` or a separate fixture that emits `"npm:l0dash"`.
  • AI reviewers agree on a likely critical defect: review-enrichment/src/analyzers/dependency-scan.ts:31 requires `npm:` aliases to contain a target-version separator, so a valid dependency like `"safe": "npm:l0dash"` falls through `parseLine` at `review-enrichment/src/analyzers/dependency-scan.ts:45` and the typosquat/confusion analyzer never sees `l0dash`. — Resolve the flagged defect, or override if the AI reviewers are mistaken, then re-run the gate.

Concerns raised — review before merging

  • review-enrichment/src/analyzers/dependency-scan.ts:31 requires `npm:` aliases to contain a target-version separator, so a valid dependency like `"safe": "npm:l0dash"` falls through `parseLine` at `review-enrichment/src/analyzers/dependency-scan.ts:45` and the typosquat/confusion analyzer never sees `l0dash`.
Signal Result Evidence
Code review ❌ 1 blocker 1 reviewer
Linked issue ⚠️ Missing No linked issue or no-issue rationale found.
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (size label size:S; no linked issue context).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 2 registered-repo PR(s), 2 merged, 280 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 2 PR(s), 280 issue(s).
Gate result ⚠️ Not blocking Advisory; not blocking this PR.
Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository registration is not available in the local Gittensory cache.
  • Public profile languages: not available
  • Official Gittensor activity: 2 PR(s), 280 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Explain no-issue PR.
  • Triage stale or unlinked PRs.
  • No action.
  • Link the issue being solved, or explicitly explain why this is a no-issue PR.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.

  • Re-run Gittensory review

@loopover-orb loopover-orb Bot added gittensor gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. labels Jun 29, 2026
@JSONbored
JSONbored force-pushed the codex/fix-npm-alias-dependencies-vulnerability branch from aae4809 to 7ad4d9f Compare June 29, 2026 18:49
@JSONbored
JSONbored merged commit 0d6b20d into main Jun 29, 2026
16 checks passed
@JSONbored
JSONbored deleted the codex/fix-npm-alias-dependencies-vulnerability branch June 29, 2026 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant