Executive brief
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.
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
Timeline
- 2022-05-25: disclosed
- 2022-06-01: patched: sharp v0.30.5 released