Medium

sharp vulnerable to Command Injection in post-installation over build environment

  • Disclosed: 01.06.2022
  • Updated: 11.10.2026 10:22

There's a possible vulnerability in logic that is run only at npm install time when installing versions of sharp prior to the latest v0.30.5.

This is not part of any runtime code, does not affect Windows users at all, and is unlikely to affect anyone that already cares about the security of their build environment. However, out of an abundance of caution, I've created this advisory.

If an attacker has the ability to set the value of the PKG_CONFIG_PATH environment variable in a build environment then they might be able to use this to inject an arbitrary command at npm install time.

I've used the Common Vulnerability Scoring System (CVSS) calculator to determine the maximum possible impact, which suggests a "medium" score of 5.9, but for most people the real impact will be dealing with the noise from automated security tooling that this advisory will bring.

AV:L/AC:L/PR:H/UI:R/S:U/C:H/I:H/A:H/E:P/RL:O/RC:C/CR:X/IR:X/AR:X/MAV:X/MAC:X/MPR:X/MUI:R/MS:X/MC:X/MI:X/MA:X

This problem was fixed in commit a6aeef6 and published as part of sharp v0.30.5.

Thank you very much to @dwisiswant0 for the responsible disclosure.

Remember: if an attacker has control over environment variables in your build environment then you have a bigger problem to deal with than this issue.

Affected software

Click a technology to see all vulnerabilities affecting it.

PlatformPackageVulnerable versionsFixed in
npm package sharp < 0.30.5 0.30.5

References

CVSS score 6.5/10
CVSS vector
CVSS:3.1/AV:L/AC:L/PR:H/UI:R/S:U/C:H/I:H/A:H
Weakness (CWE)
CWE-77, CWE-78
Platform
npm
Package
sharp
Disclosed
01.06.2022
Updated
11.10.2026 10:22

Sources and licenses

OSV / GitHub Advisory Database - GHSA-gp95-ppv5-3jc5 - CC BY 4.0

Vulnerability history: sharp

All published vulnerabilities of this package (npm package), newest first. Shows whether this is a one-off slip or a package that needs watching.

Total entries
5
First → latest
06.2022 10.2026
Without a fix
0
Exploited in attacks
0

Severity breakdown

  • High 4
  • Medium 1

Disclosures per year

  1. 2022: 1
  2. 2023: 1
  3. 2024: 0
  4. 2025: 0
  5. 2026: 3
  1. High ghsa-wq5f-xc86-pv6w < 0.35.5 0.35.5
  2. High · 7.8 ghsa-54xq-cgqr-rpm3 < 0.32.6 0.32.6
  3. sharp vulnerable to Command Injection in post-installation over build environment this entry
    Medium · 6.5 CVE-2022-29256 < 0.30.5 0.30.5

Know which vulnerabilities affect your application

With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.

Connect your application
DockRay newsletter

Application security in your inbox

Important vulnerabilities, actionable guidance and practical advice for your applications. Choose your technologies and follow what matters to your project.

  • A daily digest of new vulnerabilities, critical ones included.
  • Notifications about important updates.
  • Practical advice on application security and monitoring.

Leave empty to receive updates for every technology.

Free to subscribe. Unsubscribe with one click in any email.