[BUG] `npm audit` not working properly with pre-releases / JFrog article "Invisible npm malware"
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.1k
- Forks
- 4.7k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 19
Description
Is there an existing issue for this?
- I have searched the existing issues
This issue exists in the latest npm version
- I am using the latest npm
Current Behavior
As described in the JFrog post "Invisible npm malware – evading security checks with crafted versions", npm audit is unable to detect vulnerabilities in pre-release versions.
Their post says:
Following a disclosure from JFrog, we learned from the NPM maintainers that this functionality is the expected behavior, therefore we do not expect this behavior to change.
Could you please explain why you consider this expected behavior (even if the answer is that this is a technical limitation)? Even though you should normally avoid depending on pre-releases, in some cases it might be necessary (e.g. to get an important bug fix), and it would certainly be useful to also be notified about vulnerabilities if there are any.
Expected Behavior
npm audit should detect vulnerabilities in pre-release versions of dependencies.
Steps To Reproduce
- Create a
package.jsonwith the following content{ "name": "test", "version": "1.0.0", "dependencies": { "cruddl": "2.0.0-update.2" } } - Run
npm install, thennpm audit
❌ Bug: No vulnerability is detected - Change the dependency version to
1.7.6or2.0.0and repeat step 2
✔️ As expected: The vulnerability is detected
Environment
- npm: 9.2.0
- Node.js: v16.14.2
- OS Name: Windows 10
- System Model Name:
- npm config:
; "builtin" config from #redacted#\AppData\Roaming\npm\node_modules\npm\npmrc
prefix = "#redacted#\\AppData\\Roaming\\npm"
; "cli" config from command line options
location = "project"
; node bin location = C:\Program Files\nodejs\node.exe
; node version = v16.14.2
; npm local prefix = #redacted#\Downloads\npm-test
; npm version = 9.2.0
; cwd = #redacted#\Downloads\npm-test
; HOME = #redacted#
; Run `npm config ls -l` to show all defaults.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by creating the package.json shown in the issue, running npm install, and comparing npm audit results for the pre-release and stable dependency versions. Trace the npm audit vulnerability matching behavior for pre-release versions; done means the reported vulnerability is detected consistently without breaking the existing stable-version behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- cli, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100