{"id":"CVE-2026-31938","aliases":["CVE-2026-31938","GHSA-wfv2-pwc8-crg5"],"related":[],"kind":"vulnerability","state":"published","title":"jsPDF has HTML Injection in New Window paths","summary":"jsPDF is a library to generate PDFs in JavaScript. Prior to version 4.2.1, user control of the `options` argument of the `output` function allows attackers to inject arbitrary HTML (such as scripts) into the browser context the created PDF is opened in. The vulnerability can be exploited in the following scenario: the attacker provides values for the output options, for example via a web interface. These values are then passed unsanitized (automatically or semi-automatically) to the attack victim. The victim creates and opens a PDF with the attack vector using one of the vulnerable method overloads inside their browser. The attacker can thus inject scripts that run in the victims browser context and can extract or modify secrets from this context. The vulnerability has been fixed in jspdf@4.2.1. As a workaround, sanitize user input before passing it to the output method.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"jsPDF is a library to generate PDFs in JavaScript. Prior to version 4.2.1, user control of the `options` argument of the `output` function allows attackers to inject arbitrary HTML (such as scripts) into the browser context the created PDF is opened in. The vulnerability can be exploited in the following scenario: the attacker provides values for the output options, for example via a web interface. These values are then passed unsanitized (automatically or semi-automatically) to the attack victim. The victim creates and opens a PDF with the attack vector using one of the vulnerable method overloads inside their browser. The attacker can thus inject scripts that run in the victims browser context and can extract or modify secrets from this context. The vulnerability has been fixed in jspdf@4.2.1. As a workaround, sanitize user input before passing it to the output method.","source":"cvelist"},{"lang":"en","text":"### Impact\n\nUser control of the `options` argument of the `output` function allows attackers to inject arbitrary HTML (such as scripts) into the browser context the created PDF is opened in. The affected overloads and options are:\n\n* `\"pdfobjectnewwindow\"`: the `pdfObjectUrl` option and the entire options object, which is JSON-serialized and included verbatim in the generated HTML-string.\n* `\"pdfjsnewwindow\"`: the `pdfJsUrl` and `filename` options\n* `\"dataurlnewwindow\"`: the `filename` option\n\nThe vulnerability can be exploited in the following scenario: the attacker provides values for the output options, for example via a web interface. These values are then passed unsanitized (automatically or semi-automatically) to the attack victim. The victim creates and opens a PDF with the attack vector using one of the vulnerable method overloads inside their browser. The attacker can thus inject scripts that run in the victims browser context and can extract or modify secrets from this context.\n\nExample attack vector:\n\n```js\nimport { jsPDF } from 'jspdf';\nconst doc = new jsPDF();\n\nconst payload =  'x\\\"></iframe><script>window.__n=1</script><iframe src=\"';\n\ndoc.output('pdfjsnewwindow', {\n  filename: payload,\n  pdfJsUrl: 'viewer.html'\n});\n```\n\n### Patches\nThe vulnerability has been fixed in jspdf@4.2.1.\n\n### Workarounds\nSanitize user input before passing it to the output method.","format":"markdown","source":"ghsa"},{"lang":"es","text":"jsPDF es una biblioteca para generar PDFs en JavaScript. Antes de la versión 4.2.1, el control del usuario sobre el argumento 'options' de la función 'output' permite a los atacantes inyectar HTML arbitrario (como scripts) en el contexto del navegador en el que se abre el PDF creado. La vulnerabilidad puede ser explotada en el siguiente escenario: el atacante proporciona valores para las opciones de salida, por ejemplo, a través de una interfaz web. Estos valores se pasan luego sin sanear (automática o semi-automáticamente) a la víctima del ataque. La víctima crea y abre un PDF con el vector de ataque utilizando una de las sobrecargas de método vulnerables dentro de su navegador. El atacante puede así inyectar scripts que se ejecutan en el contexto del navegador de la víctima y puede extraer o modificar secretos de este contexto. La vulnerabilidad ha sido corregida en jspdf@4.2.1. Como solución alternativa, sanear la entrada del usuario antes de pasarla al método de salida.","source":"nvd"}],"published":"2026-03-17T17:07:59.000Z","modified":"2026-09-10T03:50:41.577Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:L","score":9.6,"rating":"CRITICAL"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:L","score":9.6,"rating":"CRITICAL"},{"scorer":"redhat-SADP","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:N","score":8.1,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:L","score":9.6,"rating":"CRITICAL"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","score":6.1,"rating":"MEDIUM"}],"cwes":["CWE-79"],"affected":[{"ranges":[{"version":"< 4.2.1","status":"affected"}],"vendor":"parallax","product":"jsPDF","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1775594119","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Red Hat Advanced Cluster Security 4.8","package":"advanced-cluster-security/rhacs-main-rhel8","cpe":"cpe:/a:redhat:advanced_cluster_security:4.8::el8","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1775594284","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Red Hat Advanced Cluster Security 4.9","package":"advanced-cluster-security/rhacs-main-rhel8","cpe":"cpe:/a:redhat:advanced_cluster_security:4.9::el8","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"4.2.1"}],"ecosystem":"npm","package":"jspdf","purl":"pkg:npm/jspdf","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"4.2.1"}],"vendor":"parall","product":"jspdf","cpe":"cpe:2.3:a:parall:jspdf:*:*:*:*:*:node.js:*:*","source":"nvd"}],"references":[{"url":"https://github.com/parallax/jsPDF/security/advisories/GHSA-wfv2-pwc8-crg5","tags":["mitigation","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/parallax/jsPDF/commit/87a40bbd07e6b30575196370670b41f264aa78d7","tags":["patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/parallax/jsPDF/releases/tag/v4.2.1","tags":["product","release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://access.redhat.com/security/cve/CVE-2026-31938","tags":["vdb-entry","x-refsource-redhat"],"sources":["cvelist","nvd"]},{"url":"https://bugzilla.redhat.com/show_bug.cgi?id=2448550","tags":["issue-tracking","x-refsource-redhat"],"sources":["cvelist","nvd"]},{"url":"https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-31938.json","tags":["x-sadp-csaf-vex"],"sources":["cvelist","nvd"]},{"url":"https://access.redhat.com/errata/RHSA-2026:7110","tags":["vendor-advisory","x-refsource-redhat"],"sources":["cvelist","nvd"]},{"url":"https://access.redhat.com/errata/RHSA-2026:7128","tags":["vendor-advisory","x-refsource-redhat"],"sources":["cvelist","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-31938","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/parallax/jsPDF","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"total","date":"2026-03-18T13:59:39.345Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-31938","url":"https://www.cve.org/CVERecord?id=CVE-2026-31938","licence":"CVE Terms of Use","modified":"2026-09-07T12:04:46.902Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-wfv2-pwc8-crg5","url":"https://github.com/advisories/GHSA-wfv2-pwc8-crg5","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:41.577Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-31938","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-31938","licence":"Public domain","modified":"2026-08-18T12:18:06.707Z"}],"updatedAt":"2026-11-25T22:59:16.085Z","epss":{"score":0.00317,"percentile":0.26605,"date":"2026-12-01T12:00:22.000Z"}}