# CVE-2022-29256: sharp command injection in post-installation build environment

Source: https://junglewise.ai/threats/cve-2022-29256-sharp-command-injection-in-post-installation-build-environment  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2022-06-01. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

CVE-2022-29256 · Severity: low · CVSS 3.1 · Published 2022-06-01

sharp is a popular Node.js image processing library. During npm package installation, sharp runs build scripts that are vulnerable to command injection if an attacker can control the PKG_CONFIG_PATH environment variable in a build environment. This allows arbitrary code execution during package installation on non-Windows systems, potentially compromising the build pipeline and deployed applications.

Technologies: [Sharp](https://junglewise.ai/threats/technologies/npm-sharp).

## Quick answers

**Is CVE-2022-29256 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2022-29256 being exploited in the wild.

**How severe is CVE-2022-29256?** Low severity, with a CVSS score of 3.1, published 1 June 2022.

**Which products and versions are affected?** Sharp SEMVER:introduced=0,fixed=0.30.5.

**Is there a fix for CVE-2022-29256?** Yes. Sharp: upgrade to 0.30.5 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2022-29256 attacked?** It is attacked with local access, in a software library.

**Am I affected by CVE-2022-29256?** Check whether you run Sharp at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- Sharp: upgrade to 0.30.5 or later

## Technical details

The vulnerability is a command injection flaw (CWE-77, CWE-78) in sharp's post-installation build logic that occurs only at npm install time. The vulnerable code fails to properly neutralize the PKG_CONFIG_PATH environment variable, allowing an attacker with high privileges and user interaction capability to inject arbitrary commands. Attack requires local access to the build environment with ability to set environment variables. An attacker can achieve arbitrary code execution during installation on non-Windows systems. The vulnerability was patched in sharp v0.30.5 (commit a6aeef6), released on 2022-06-01.

## Affected products

- lovell sharp <0.30.5

## Identifiers

- CVE-2022-29256
- GHSA-gp95-ppv5-3jc5

## Timeline

- 2022-05-25: disclosed
- 2022-06-01: patched: sharp v0.30.5 released

## References

- [https://github.com/lovell/sharp/security/advisories/GHSA-gp95-ppv5-3jc5](https://github.com/lovell/sharp/security/advisories/GHSA-gp95-ppv5-3jc5)

## Related threats

- [sharp memory corruption in librsvg dependency](https://junglewise.ai/threats/sharp-vulnerability-in-librsvg-dependency-b5d03f31)
- [sharp remote code execution via malformed HEIF image](https://junglewise.ai/threats/sharp-remote-code-execution-via-malformed-heif-image-32a48ae6)
- [sharp buffer overflow in libwebp WebP image decoding](https://junglewise.ai/threats/sharp-buffer-overflow-in-libwebp-webp-image-decoding-aa074f7e)
