CVE-2022-29080: Command injection in npm-dependency-versions

npm-dependency-versions Updated 02 Oct 2025

Summary

13/04/2022
No i
Critical
9.8

CVE-2022-29080: Command injection in npm-dependency-versions. Affects npm-dependency-versions versions < 0.3.0. No fix is published. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

The npm-dependency-versions package is a Node.js module that allows users to retrieve dependency versions for a given package. It is commonly used in npm-based projects to manage and track dependencies. This package is vulnerable to a command injection attack when the dependencyVersions function is called with a JSON object containing a key named pkgs and a value that includes shell metacharacters. This vulnerability allows an attacker to execute arbitrary commands on the host system.

Vulnerability Detail

The vulnerability in npm-dependency-versions arises from insufficient input validation. When the dependencyVersions function is called with a JSON object, the package fails to properly sanitize the input, allowing an attacker to inject malicious commands. By crafting a payload that includes shell metacharacters, an attacker can execute arbitrary commands with the privileges of the user running the vulnerable code. This can lead to unauthorized access, data leakage, or even complete compromise of the host system.

How To Fix

No fixed version is published for this vulnerability.

Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →

Workaround

As a temporary workaround, users can avoid passing untrusted input to the dependencyVersions function. If the function is called with user-controlled input, it should be properly validated and sanitized before being passed to the vulnerable package. Here is an example of how to sanitize the input using the shell-quote library in a Node.js application:

const shellQuote = require('shell-quote');

const userInput = req.body.pkgs; // User-controlled input
const sanitizedInput = shellQuote.quote([userInput]);

dependencyVersions({ pkgs: sanitizedInput });

Conclusion

In conclusion, the npm-dependency-versions package is vulnerable to command injection, allowing an attacker to execute arbitrary commands on the host system. To mitigate this vulnerability, it is crucial to upgrade to the latest patched version (0.3.1) of the package. Additionally, it is recommended to sanitize user-controlled input before passing it to the vulnerable function. For further assistance or support in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for npm-dependency-versions →

Share this vulnerability

FAQ

This vulnerability allows an attacker to execute arbitrary commands on the host system. Depending on the privileges of the user running the vulnerable code, this can lead to unauthorized access, data leakage, or complete compromise of the system.

You can use the Vulert Playground at Vulert Scanner to check if your application is affected by this vulnerability. Simply provide your package-lock.json file, and Vulert will analyze it for any open-source vulnerabilities, including this one.

Yes, the maintainers of npm-dependency-versions have released a patched version (0.3.1) that addresses this vulnerability. It is recommended to update your package.json file to include the latest version and run npm install to fetch the updated package.

As a temporary workaround, you can sanitize the user-controlled input before passing it to the vulnerable function. Properly validating and sanitizing the input can help prevent command injection attacks. See the 'workaround' section for an example of how to sanitize the input in a Node.js application.

You can find more information about this vulnerability, including the technical details and the CVE identifier (CVE-2022-29080), in the GitHub Advisory Database at https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2022/04/GHSA-m7xq-8jp8-rj2c/GHSA-m7xq-8jp8-rj2c.json.

How To Fix

No fixed version is published for this vulnerability.

Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback