The analysis of the security advisory and the associated patch commit 87a40bbd07e6b30575196370670b41f264aa78d7 clearly indicates that the vulnerability lies within the output method of the jsPDF object, located in src/jspdf.js. The vulnerability description explicitly names the output function and details how different options (pdfobjectnewwindow, pdfjsnewwindow, dataurlnewwindow) can be exploited.
The patch confirms this by making several key changes inside the output function's implementation:
- For the
datauristring output type (which is used by dataurlnewwindow), it replaces direct use of options.filename with encodeURIComponent(options.filename). This prevents manipulation of the data URI structure.
- For the
pdfobjectnewwindow, pdfjsnewwindow, and dataurlnewwindow output types, the patch refactors the code to stop generating raw HTML strings via concatenation (document.write(...)). Instead, it uses the safer DOM API (createElement, setting .src property) to build the content of the new window. This prevents attackers from injecting malicious HTML tags and scripts through the options.
The vulnerable function is identified as jsPDF.output because it is the entry point that processes the malicious input and, prior to the patch, performed the unsafe string concatenations that led to the HTML injection vulnerability.