Security Vulnerability Report
中文
CVE-2026-31898 CVSS 8.1 HIGH

CVE-2026-31898

Published: 2026-03-18 04:17:21
Last Modified: 2026-03-20 18:08:04

Description

jsPDF is a library to generate PDFs in JavaScript. Prior to version 4.2.1, user control of arguments of the `createAnnotation` method allows users to inject arbitrary PDF objects, such as JavaScript actions. If given the possibility to pass unsanitized input to the following method, a user can inject arbitrary PDF objects, such as JavaScript actions, which might trigger when the PDF is opened or interacted with the `createAnnotation`: `color` parameter. The vulnerability has been fixed in [email protected]. As a workaround, sanitize user input before passing it to the vulnerable API members.

CVSS Details

CVSS Score
8.1
Severity
HIGH
CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:N

Configurations (Affected Products)

cpe:2.3:a:parall:jspdf:*:*:*:*:*:node.js:*:* - VULNERABLE
jsPDF < 4.2.1

PoC / Exploit Code

⚠ For Security Research Only
The following code is for security research and authorized testing only.
python
const jsPDF = require('jspdf'); const doc = new jsPDF(); doc.createAnnotation({ type: 'text', bounds: { x: 10, y: 10, w: 100, h: 100 }, color: '%EF %BFBD JavaScript注入代码' });

References

Raw JSON Data

JSON
{"cve": {"id": "CVE-2026-31898", "sourceIdentifier": "[email protected]", "published": "2026-03-18T04:17:21.050", "lastModified": "2026-03-20T18:08:04.133", "vulnStatus": "Analyzed", "cveTags": [], "descriptions": [{"lang": "en", "value": "jsPDF is a library to generate PDFs in JavaScript. Prior to version 4.2.1, user control of arguments of the `createAnnotation` method allows users to inject arbitrary PDF objects, such as JavaScript actions. If given the possibility to pass unsanitized input to the following method, a user can inject arbitrary PDF objects, such as JavaScript actions, which might trigger when the PDF is opened or interacted with the `createAnnotation`: `color` parameter. The vulnerability has been fixed in [email protected]. As a workaround, sanitize user input before passing it to the vulnerable API members."}, {"lang": "es", "value": "jsPDF es una biblioteca para generar PDFs en JavaScript. Anterior a la versión 4.2.1, el control del usuario sobre los argumentos del método 'createAnnotation' permite a los usuarios inyectar objetos PDF arbitrarios, como acciones de JavaScript. Si se le da la posibilidad de pasar entrada no saneada al siguiente método, un usuario puede inyectar objetos PDF arbitrarios, como acciones de JavaScript, que podrían activarse cuando el PDF se abre o se interactúa con el 'createAnnotation': parámetro 'color'. La vulnerabilidad ha sido corregida en [email protected]. Como solución alternativa, sanee la entrada del usuario antes de pasarla a los miembros vulnerables de la API."}], "metrics": {"cvssMetricV31": [{"source": "[email protected]", "type": "Secondary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:N", "baseScore": 8.1, "baseSeverity": "HIGH", "attackVector": "NETWORK", "attackComplexity": "LOW", "privilegesRequired": "NONE", "userInteraction": "REQUIRED", "scope": "UNCHANGED", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "availabilityImpact": "NONE"}, "exploitabilityScore": 2.8, "impactScore": 5.2}, {"source": "[email protected]", "type": "Primary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N", "baseScore": 6.5, "baseSeverity": "MEDIUM", "attackVector": "NETWORK", "attackComplexity": "LOW", "privilegesRequired": "NONE", "userInteraction": "REQUIRED", "scope": "UNCHANGED", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "availabilityImpact": "NONE"}, "exploitabilityScore": 2.8, "impactScore": 3.6}]}, "weaknesses": [{"source": "[email protected]", "type": "Primary", "description": [{"lang": "en", "value": "CWE-116"}]}], "configurations": [{"nodes": [{"operator": "OR", "negate": false, "cpeMatch": [{"vulnerable": true, "criteria": "cpe:2.3:a:parall:jspdf:*:*:*:*:*:node.js:*:*", "versionEndExcluding": "4.2.1", "matchCriteriaId": "E32C16E0-23FB-49ED-B364-2170D7FC9935"}]}]}], "references": [{"url": "https://github.com/parallax/jsPDF/blob/b1607a9391d4cd65ea7ade25998aea8345ae1be3/src/modules/annotations.js#L193-L208", "source": "[email protected]", "tags": ["Patch"]}, {"url": "https://github.com/parallax/jsPDF/commit/4155c4819d5eca284168e51e0e1e81126b4f14b8", "source": "[email protected]", "tags": ["Patch"]}, {"url": "https://github.com/parallax/jsPDF/releases/tag/v4.2.1", "source": "[email protected]", "tags": ["Release Notes"]}, {"url": "https://github.com/parallax/jsPDF/security/advisories/GHSA-7x6v-j9x4-qf24", "source": "[email protected]", "tags": ["Mitigation", "Vendor Advisory"]}]}}