CVE-2022-24278 (published 2022-06-10T20:15Z)

The package convert-svg-core before 0.6.4 are vulnerable to Directory Traversal due to improper sanitization of SVG tags. Exploiting this vulnerability is possible by using a specially crafted SVG file.

Severity: HIGH
CVSS v2 base score: 7.5 (AV:N/AC:L/Au:N/C:P/I:P/A:P)
CVSS v3 base score: 9.8, CRITICAL (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H)

Weakness information:
cwe_id: CWE-22
cwe_name: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
description: The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.
extended_description: 
            Many file operations are intended to take place within a restricted directory. By using special elements such as ".." and "/" separators, attackers can escape outside of the restricted location to access files or directories that are elsewhere on the system. One of the most common special elements is the "../" sequence, which in most modern operating systems is interpreted as the parent directory of the current location. This is referred to as relative path traversal. Path traversal also covers the use of absolute pathnames such as "/usr/local/bin" to access unexpected files. This is referred to as absolute path traversal.
         
         

Fix information:
repo_url: https://github.com/neocotic/convert-svg
commit_details: repo_url: https://github.com/neocotic/convert-svg
author: Alasdair
author_date: 2022-06-07 10:14:34+01:00
msg: Convert only first SVG element from input

If the input to be converted contains multiple SVG elements, only the first SVG element should be converted. Currently, and undesirably, all SVG elements were being inserted into the page within Puppeteer, resulting in them all being stacked prior to the screenshot being taken.

Another symptom of this was that all recent safety measures implemented for remote code injection vulnerabilities can be easily circumvented by inserting a simple empty SVG element at the start of the input as it was the only one being sanitized.
repository: repo_url: https://github.com/neocotic/convert-svg
repo_name: neocotic/convert-svg
description: Node.js packages for converting SVG into other formats using headless Chromium
repo_language: JavaScript
owner: neocotic
file_changes: filename: Converter.js
change_type: ModificationType.MODIFY
diff: @@ -261,7 +261,7 @@ class Converter {
     input = Buffer.isBuffer(input) ? input.toString('utf8') : input;
 
     const { provider } = this;
-    const svg = cheerio.default.html(this[_sanitize](cheerio.load(input, null, false)('svg'), options));
+    const svg = cheerio.default.html(this[_sanitize](cheerio.load(input, null, false)('svg:first'), options));
 
     if (!svg) {
       throw new Error('SVG element not found in input. Check the SVG input');

programming_language: TypeScript
filename: issue-86.svg
change_type: ModificationType.ADD
diff: @@ -0,0 +1,2 @@
+<svg></svg>
+<svg viewBox="0 0 240 80" height="1000" width="1000" onload="eval(atob(this.id))" id="ZG9jdW1lbnQud3JpdGUoJzxzdmctZHVtbXk+PC9zdmctZHVtbXk+PGlmcmFtZSBzcmM9ImZpbGU6Ly8vZXRjL3Bhc3N3ZCIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwMHB4Ij48L2lmcmFtZT48c3ZnIHZpZXdCb3g9IjAgMCAyNDAgODAiIGhlaWdodD0iMTAwMCIgd2lkdGg9IjEwMDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHRleHQgeD0iMCIgeT0iMCIgY2xhc3M9IlJycnJyIiBpZD0iZGVtbyI+ZGF0YTwvdGV4dD48L3N2Zz4nKTs="></svg>

programming_language: Lua
filename: tests.json
change_type: ModificationType.MODIFY
diff: @@ -168,6 +168,12 @@
     "file": "issue-81.svg",
     "message": "should strip onload attribute"
   },
+  {
+    "name": "when SVG has multiple SVG elements",
+    "file": "issue-86.svg",
+    "options": { "width": 1000, "height": 1000 },
+    "message": "should only read first SVG element"
+  },
   {
     "name": "when setting both baseFile and baseUrl options",
     "file": "external-file.svg",

programming_language: Swift