CVE-2022-29256: Sharp Sharp Vulnerable To Command Injection Vulnerability
MODERATECVE-2022-29256 is a MODERATE (CVSS 6.5) sharp vulnerable to command injection vulnerability (CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')) affecting Sharp libraries in the npm ecosystem. The issue involves sharp vulnerable to command injection in post-installation over build environment. Remediation is available by upgrading affected packages to version 0.30.5.
CVE-2022-29256 at a Glance
Security Impact
CVSS: 6.5
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:L/PR:H/UI:R/S:U/C:H/I:H/A:H).
How to Fix CVE-2022-29256
To remediate this vulnerability, upgrade all affected Sharp dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install sharp@0.30.5
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls sharp
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2022-29256, inspect your project dependencies using npm:
npm ls sharp
Analyze the terminal output to locate any version of Sharp in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.30.5), your application is affected.
Note: The npm ls sharp command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection'), where the product constructs all or part of an os command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended os command when it is sent to a downstream component. In Sharp, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2022-29256 Affected Sharp Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
sharp
|
npm |
< 0.30.5
|
0.30.5
|
References
Frequently Asked Questions
What is CVE-2022-29256?
Which Sharp versions are affected?
What version fixes CVE-2022-29256?
Is sharp affected?
What is the CVSS score of CVE-2022-29256?
What CWE is associated with CVE-2022-29256?
How can I check npm dependencies for CVE-2022-29256?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-gp95-ppv5-3jc5",
"modified" : "2022-09-15T01:24:15Z",
"published" : "2022-06-01T19:58:29Z",
"aliases" : [ "CVE-2022-29256" ],
"summary" : "sharp vulnerable to Command Injection in post-installation over build environment",
"details" : "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.\n\nThis 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.\n\nIf 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.\n\nI'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.\n\n[`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`](https://nvd.nist.gov/vuln-metrics/cvss/v3-calculator?vector=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&version=3.1)\n\nThis problem was fixed in commit a6aeef6 and published as part of `sharp` v0.30.5.\n\nThank you very much to @dwisiswant0 for the responsible disclosure.\n\nRemember: if an attacker has control over environment variables in your build environment then you have a bigger problem to deal with than this issue.\n",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:L/AC:L/PR:H/UI:R/S:U/C:H/I:H/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "sharp"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "0.30.5"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/lovell/sharp/security/advisories/GHSA-gp95-ppv5-3jc5"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-29256"
}, {
"type" : "WEB",
"url" : "https://github.com/lovell/sharp/commit/a6aeef612be50f5868a77481848b1de674216f0c"
}, {
"type" : "WEB",
"url" : "https://advisory.dw1.io/54"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/lovell/sharp"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-77", "CWE-78" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2022-06-01T19:58:29Z",
"nvd_published_at" : "2022-05-25T22:15:00Z"
}
}