npm / npm/rfcs

[RRFC] Warn users when skipping alias/git deps during audit

Open
#497 3 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
777
Forks
267
PR merge metrics
No merged PRs in 30d

Description

The problem

When running "NPM audit" with alias packages, or packages received from git installation,
it simply skips the package with no warning or sign that the package was not validated.

Organizations relying on the npm audit functionality as part of their installation can be fooled into downloading malwared / vulnerable packages.

Sample vulnerable package "pug => 3.0.0" can be bypassed when used with an alias "pug => npm:pug@3.0.0"
Same bypass can happen also when using from tarball

dependencies": {
    "pug": "https://github.com/pugjs/pug/tarball/pug@3.0.0"
  }
Steps to reproduce
  1. npm init
  2. npm i --save pug@npm:pug@3.0.0
  3. npm audit
Possible Remediation

In npm 7 package aliases are checked but still not with "out-of-store" packages,
Currently because of the issue here - https://github.com/npm/cli/issues/2701 it is not possible to upgrade to npm 7 in CI environments

There is no warning of packages that are not scanned in UI or in the outcoming JSON which I think should have some kind of warning/error

This issue was disclosed to the security team in March and it was decided that this should be filed as a feature/issue and not a security bug.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the alias case with npm init, npm i --save pug@npm:pug@3.0.0, and npm audit, then compare it with the tarball and git dependency cases described here. Review how npm audit reports results in its UI and JSON output; done means skipped packages are clearly reported as unvalidated, with the npm 7 and issue #2701 constraints accounted for.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
devtools, security
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.