The vulnerability is a classic path traversal issue within the Node.js environment of the jsPDF library. The root cause lies in the loadFile function and its internal helper nodeReadFile located in src/modules/fileloading.js. Before the patch, the library would take a user-supplied file path, resolve it using path.resolve(), and then read the file using fs.readFileSync(). There was no validation to restrict the path to a specific directory, allowing an attacker to use ../ sequences to navigate the file system and access any file readable by the Node.js process.
The security advisory explicitly mentions that besides loadFile, the functions addImage, html, and addFont are also affected. This is because these functions rely on the same vulnerable file loading mechanism to handle assets like images, HTML resources, and fonts. The provided patch addresses the vulnerability by introducing a security control. It adds a new property, allowFsRead, which acts as a whitelist for file system access. By default, file system access is disabled. The user must now either use Node.js's built-in permission flags (--allow-fs-read) or explicitly define which files and directories jsPDF is allowed to read via the allowFsRead array. The patch also uses fs.realpathSync to resolve the canonical path of a file, making traversal attacks more difficult. Any runtime profile during exploitation would show calls to one of the four identified vulnerable functions.