CVE-2022-29256: Command Injection in sharp Package

sharp Updated 02 Oct 2025

Summary

01/06/2022
Yes i
Moderate
6.5

CVE-2022-29256: sharp vulnerable to Command Injection in post-installation over build environment. Affects sharp versions < 0.30.5. Fixed in 0.30.5. 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 Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

Background

The sharp package is an open-source image processing library for Node.js. It provides a simple and efficient API for resizing, cropping, and manipulating images. The package is widely used in web applications and other projects that require image processing capabilities. However, versions of sharp prior to v0.30.5 are vulnerable to a command injection vulnerability during the post-installation process in the build environment. This vulnerability can be exploited if an attacker can set the value of the PKG_CONFIG_PATH environment variable during the npm install command.

Vulnerability Detail

The vulnerability in sharp arises from a logic flaw that is executed only during the npm install process. If an attacker can control the PKG_CONFIG_PATH environment variable, they can inject arbitrary commands during the installation of vulnerable versions of sharp. This can lead to remote code execution and compromise the security of the build environment. The impact of this vulnerability is considered moderate, with a CVSS score of 6.5. However, it is important to note that this vulnerability does not affect Windows users and is unlikely to impact those who already prioritize the security of their build environment.

How To Fix

Minimum fixed version

0.30.5

This is the first release that contains the fix.

npm install sharp@0.30.5

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

There is no known workaround for this vulnerability. It is essential to update to the latest version of the sharp package to mitigate the risk.

Conclusion

The sharp package prior to v0.30.5 is vulnerable to a command injection issue during the post-installation process. It is crucial to update to the latest version of the package to mitigate the risk of remote code execution and compromise of the build environment. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for sharp →

Share this vulnerability

FAQ

The sharp package is an open-source image processing library for Node.js. It provides a simple and efficient API for resizing, cropping, and manipulating images.

The vulnerability allows an attacker to inject arbitrary commands during the installation of vulnerable versions of sharp. This can lead to remote code execution and compromise the security of the build environment.

Users of sharp versions prior to v0.30.5 are affected by this vulnerability. However, it is important to note that this vulnerability does not impact Windows users and is unlikely to affect those who prioritize the security of their build environment.

To fix this vulnerability, it is recommended to update the sharp package to the latest version (v0.30.5 or later) by running the command: npm install sharp@latest.

There are no known workarounds for this vulnerability. It is crucial to update to the latest version of the sharp package to mitigate the risk.

Related vulnerabilities

Recent vulnerabilities recorded for sharp.

Sponsored Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

How To Fix

Minimum fixed version

0.30.5

This is the first release that contains the fix.

npm install sharp@0.30.5

Tip — Not sure which version your app runs? Vulert can match this fix to it. 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