Skip to content

fix(deps): update dependency jspdf to v4 [security]#1334

Open
renovate[bot] wants to merge 1 commit intomasterfrom
renovate/npm-jspdf-vulnerability
Open

fix(deps): update dependency jspdf to v4 [security]#1334
renovate[bot] wants to merge 1 commit intomasterfrom
renovate/npm-jspdf-vulnerability

Conversation

@renovate
Copy link
Contributor

@renovate renovate bot commented Mar 18, 2025

This PR contains the following updates:

Package Change Age Confidence
jspdf ^2.5.1^4.0.0 age confidence

GitHub Vulnerability Alerts

CVE-2025-29907

Impact

User control of the first argument of the addImage method results in CPU utilization and denial of service.

If given the possibility to pass unsanitized image urls to the addImage method, a user can provide a harmful data-url that results in high CPU utilization and denial of service.

Other affected methods are: html, addSvgAsImage.

Example payload:

import { jsPDF } from "jpsdf" 

const doc = new jsPDF();
const payload = 'data:/charset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=scharset=s\x00base64,undefined';

const startTime = performance.now()

try {
 doc.addImage(payload, "PNG", 10, 40, 180, 180, undefined, "SLOW");
} catch (err) {
  const endTime = performance.now()
  console.log(`Call to doc.addImage took ${endTime - startTime} milliseconds`)
}

doc.save("a4.pdf");

Patches

The vulnerability was fixed in jsPDF 3.0.1. Upgrade to jspdf@>=3.0.1

Workarounds

Sanitize image urls before passing it to the addImage method or one of the other affected methods.

Credits

Researcher: Aleksey Solovev (Positive Technologies)

CVE-2025-57810

Impact

User control of the first argument of the addImage method results in CPU utilization and denial of service.

If given the possibility to pass unsanitized image data or URLs to the addImage method, a user can provide a harmful PNG file that results in high CPU utilization and denial of service.

Other affected methods are: html.

Example payload:

import { jsPDF } from "jspdf" 

const payload = new Uint8Array([117, 171, 90, 253, 166, 154, 105, 166, 154])

const doc = new jsPDF();
const startTime = performance.now();
try {
  doc.addImage(payload, "PNG", 10, 40, 180, 180, undefined, "SLOW");
} finally {
  const endTime = performance.now();
  console.log(`Call to doc.addImage took ${endTime - startTime} milliseconds`);
}

Patches

The vulnerability was fixed in jsPDF 3.0.2. Upgrade to jspdf@>=3.0.2.

In jspdf@>=3.0.2, invalid PNG files throw an Error instead of causing very long running loops.

Workarounds

Sanitize image data or URLs before passing it to the addImage method or one of the other affected methods.

Credits

Researcher: Aleksey Solovev (Positive Technologies)

CVE-2025-68428

Impact

User control of the first argument of the loadFile method in the node.js build allows local file inclusion/path traversal.

If given the possibility to pass unsanitized paths to the loadFile method, a user can retrieve file contents of arbitrary files in the local file system the node process is running in. The file contents are included verbatim in the generated PDFs.

Other affected methods are: addImage, html, addFont.

Only the node.js builds of the library are affected, namely the dist/jspdf.node.js and dist/jspdf.node.min.js files.

Example attack vector:

import { jsPDF } from "./dist/jspdf.node.js";

const doc = new jsPDF();

doc.addImage("./secret.txt", "JPEG", 0, 0, 10, 10);
doc.save("test.pdf"); // the generated PDF will contain the "secret.txt" file

Patches

The vulnerability has been fixed in jsPDF@4.0.0. This version restricts file system access per default. This semver-major update does not introduce other breaking changes.

Workarounds

With recent node versions, jsPDF recommends using the --permission flag in production. The feature was introduced experimentally in v20.0.0 and is stable since v22.13.0/v23.5.0/v24.0.0. See the node documentation for details.

For older node versions, sanitize user-provided paths before passing them to jsPDF.

Credits

Researcher: kilkat (Kwangwoon Kim)

CVE-2026-24040

Impact

The addJS method in the jspdf Node.js build utilizes a shared module-scoped variable (text) to store JavaScript content. When used in a concurrent environment (e.g., a Node.js web server), this variable is shared across all requests.

If multiple requests generate PDFs simultaneously, the JavaScript content intended for one user may be overwritten by a subsequent request before the document is generated. This results in Cross-User Data Leakage, where the PDF generated for User A contains the JavaScript payload (and any embedded sensitive data) intended for User B.

Typically, this only affects server-side environments, although the same race conditions might occur if jsPDF runs client-side.

import { jsPDF } from "jspdf";

const docA = new jsPDF();
const docB = new jsPDF();

// 1. User A sets their script (stored in shared 'text' variable)
docA.addJS('console.log("Secret A");');

// 2. User B sets their script (overwrites shared 'text' variable)
docB.addJS('console.log("Secret B");');

// 3. User A saves their PDF (reads current 'text' variable)
docA.save("userA.pdf");

// Result: userA.pdf contains "Secret B" instead of "Secret A"

Patches

The vulnerability has been fixed in jspdf@4.0.1. The fix moves the shared variable into the function scope, ensuring isolation between instances.

Workarounds

Avoid using the addJS method in concurrent server-side environments. If usage is required, ensure requests are processed sequentially (e.g., using a queue) rather than in parallel.

CVE-2026-24043

Impact

User control of the first argument of the addMetadata function allows users to inject arbitrary XML.

If given the possibility to pass unsanitized input to the addMetadata method, a user can inject arbitrary XMP metadata into the generated PDF. If the generated PDF is signed, stored or otherwise processed after, the integrity of the PDF can no longer be guaranteed.

Example attack vector:

import { jsPDF } from "jspdf"

const doc = new jsPDF()

// Input a string that closes the current XML tag and opens a new one.
// We are injecting a fake "dc:creator" (Author) to spoof the document source.
const maliciousInput = '</jspdf:metadata></rdf:Description>' +
    '<rdf:Description xmlns:dc="http://purl.org/dc/elements/1.1/">' +
    '<dc:creator>TRUSTED_ADMINISTRATOR</dc:creator>' + // <--- Spoofed Identity
    '</rdf:Description>' +
    '<rdf:Description><jspdf:metadata>'

// The application innocently adds the user's input to the metadata
doc.addMetadata(maliciousInput, "http://valid.namespace")

doc.save("test.pdf")

Patches

The vulnerability has been fixed in jsPDF@4.1.0

Workarounds

Sanitize user input before passing it to the addMetadata method: escape XML entities. For example:

let input = "..."

input = input
    .replace(/&/g, "&amp;")
    .replace(/</g, "&lt;")
    .replace(/>/g, "&gt;")
    .replace(/"/g, "&quot;")
    .replace(/'/g, "&apos;")

doc.addMetadata(input)

CVE-2026-24133

Impact

User control of the first argument of the addImage method results in Denial of Service.

If given the possibility to pass unsanitized image data or URLs to the addImage method, a user can provide a harmful BMP file that results in out of memory errors and denial of service. Harmful BMP files have large width and/or height entries in their headers, wich lead to excessive memory allocation.

Other affected methods are: html.

Example attack vector:

import { jsPDF } from "jspdf" 

// malicious BMP image data with large width/height headers
const payload = ...

const doc = new jsPDF();

doc.addImage(payload, "BMP", 0, 0, 100, 100);

Patches

The vulnerability has been fixed in jsPDF 4.1.0. Upgrade to jspdf@>=4.1.0.

Workarounds

Sanitize image data or URLs before passing it to the addImage method or one of the other affected methods.

CVE-2026-24737

Impact

User control of properties and methods of the Acroform module allows users to inject arbitrary PDF objects, such as JavaScript actions.

If given the possibility to pass unsanitized input to one of the following methods or properties, a user can inject arbitrary PDF objects, such as JavaScript actions, which are executed when the victim opens the document. The vulnerable API members are:

  • AcroformChoiceField.addOption
  • AcroformChoiceField.setOptions
  • AcroFormCheckBox.appearanceState
  • AcroFormRadioButton.appearanceState

Example attack vector:

import { jsPDF } from "jspdf"
const doc = new jsPDF();

var choiceField = new doc.AcroFormChoiceField();
choiceField.T = "VulnerableField";
choiceField.x = 20;
choiceField.y = 20;
choiceField.width = 100;
choiceField.height = 20;

// PAYLOAD:
// 1. Starts with "/" to bypass escaping.
// 2. "dummy]" closes the array.
// 3. "/AA" injects an Additional Action (Focus event).
// 4. "/JS" executes arbitrary JavaScript.
const payload = "/dummy] /AA << /Fo << /S /JavaScript /JS (app.alert('XSS')) >> >> /Garbage [";

choiceField.addOption(payload);
doc.addField(choiceField);

doc.save("test.pdf");

Patches

The vulnerability has been fixed in jsPDF@4.1.0.

Workarounds

Sanitize user input before passing it to the vulnerable API members.

Credits

Research and fix: Ahmet Artuç

CVE-2026-25535

Impact

User control of the first argument of the addImage method results in denial of service.

If given the possibility to pass unsanitized image data or URLs to the addImage method, a user can provide a harmful GIF file that results in out of memory errors and denial of service. Harmful GIF files have large width and/or height entries in their headers, wich lead to excessive memory allocation.

Other affected methods are: html.

Example attack vector:

import { jsPDF } from "jspdf" 

// malicious GIF image data with large width/height headers
const payload = ...

const doc = new jsPDF();

doc.addImage(payload, "GIF", 0, 0, 100, 100);

Patches

The vulnerability has been fixed in jsPDF 4.1.1. Upgrade to jspdf@>=4.2.0.

Workarounds

Sanitize image data or URLs before passing it to the addImage method or one of the other affected methods.

References

https://github.com/ZeroXJacks/CVEs/blob/main/2026/CVE-2026-25535.md

CVE-2026-25940

Impact

User control of properties and methods of the Acroform module allows users to inject arbitrary PDF objects, such as JavaScript actions.

If given the possibility to pass unsanitized input to one of the following property, a user can inject arbitrary PDF objects, such as JavaScript actions, which are executed when the victim hovers over the radio option.

  • AcroformChildClass.appearanceState

Example attack vector:

import { jsPDF } from "jspdf"
const doc = new jsPDF();

const group = new doc.AcroFormRadioButton();
group.x = 10; group.y = 10; group.width = 20; group.height = 10;
doc.addField(group);

const child = group.createOption("opt1");
child.x = 10; child.y = 10; child.width = 20; child.height = 10;
child.appearanceState = "Off /AA << /E << /S /JavaScript /JS (app.alert('XSS')) >> >>";

doc.save("test.pdf");

Patches

The vulnerability has been fixed in jsPDF@4.2.0.

Workarounds

Sanitize user input before passing it to the vulnerable API members.

CVE-2026-25755

Impact

User control of the argument of the addJS method allows an attacker to inject arbitrary PDF objects into the generated document. By crafting a payload that escapes the JavaScript string delimiter, an attacker can execute malicious actions or alter the document structure, impacting any user who opens the generated PDF.

import { jsPDF } from "jspdf";
const doc = new jsPDF();
// Payload:
// 1. ) closes the JS string.
// 2. > closes the current dictionary.
// 3. /AA ... injects an "Additional Action" that executes on focus/open.
const maliciousPayload = "console.log('test');) >> /AA << /O << /S /JavaScript /JS (app.alert('Hacked!')) >> >>";

doc.addJS(maliciousPayload);
doc.save("vulnerable.pdf");

Patches

The vulnerability has been fixed in jspdf@4.2.0.

Workarounds

Escape parentheses in user-provided JavaScript code before passing them to the addJS method.

References

https://github.com/ZeroXJacks/CVEs/blob/main/2026/CVE-2026-25755.md


Release Notes

parallax/jsPDF (jspdf)

v4.2.0

Compare Source

This release fixes three security issues.

What's Changed

New Contributors

Full Changelog: parallax/jsPDF@v4.1.0...v4.2.0

v4.1.0

Compare Source

This release fixes several security issues.

What's Changed

Full Changelog: parallax/jsPDF@v4.0.0...v4.1.0

v4.0.0

Compare Source

This release fixes a critical path traversal/local file inclusion security vulnerability in the jsPDF Node.js build. File system access is now restricted by default and can be enabled by either using node's --permission flag or the new jsPDF.allowFsRead property.

There are no other breaking changes.

v3.0.4

Compare Source

This release includes a bunch of bugfixes. Thanks to all contributors!

What's Changed

New Contributors

Full Changelog: parallax/jsPDF@v3.0.3...v3.1.0

v3.0.3

Compare Source

This release fixes regressions with PNG encoding that were introduced in v3.0.2.

What's Changed
New Contributors

Full Changelog: parallax/jsPDF@v3.0.2...v3.0.3

v3.0.2

Compare Source

This release fixes a security issue where parsing of corrupt PNG images could lead to long running loops and denial of service.

What's Changed

New Contributors

Full Changelog: parallax/jsPDF@v3.0.1...v3.0.2

v3.0.1

Compare Source

This release fixes two security vulnerabilities:

  • Upgrade optional dependency canvg to 3.0.11
  • Fix a ReDoS vulnerability in the addImage method and the methods html and addSvgAsImage, which depend on addImage

v3.0.0

Compare Source

This major release officially drops support for Internet Explorer and fixes a security vulnerability in the html function by updating the optional dependency dompurify to v3.2.4. There are no other breaking changes.

New Contributors

Full Changelog: parallax/jsPDF@v2.5.2...v3.0.0


Configuration

📅 Schedule: Branch creation - "" (UTC), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@codecov
Copy link

codecov bot commented Mar 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 18.35%. Comparing base (222042a) to head (3e79e1c).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1334   +/-   ##
=======================================
  Coverage   18.35%   18.35%           
=======================================
  Files         454      454           
  Lines       74865    74865           
  Branches     1594     1599    +5     
=======================================
+ Hits        13743    13744    +1     
+ Misses      61122    61121    -1     
Flag Coverage Δ
unitTests 18.35% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link

github-actions bot commented Mar 18, 2025

Playwright test results

failed  2 failed
skipped  4 skipped

Details

stats  6 tests across 3 suites
duration  18 minutes, 9 seconds
commit  7500462

Failed tests

firefox-setup › auth.setup.ts › authenticate as user - ( @primary @slow @read @development @staging @production )
firefox-setup › auth.setup.ts › authenticate as admin - ( @primary @slow @read @development @staging @production )

Skipped tests

firefox › pages/myOrganization.test.ts › MyOrganization › Invitation Management: should display all required elements - ( @primary @slow @read @development @staging @production )
firefox › pages/myOrganization.test.ts › MyOrganization › User Management: should display all required elements - ( @primary @slow @read @development @staging @production )
firefox › pages/myOrganization.test.ts › MyOrganization › Organization Profile: should display all required elements - ( @primary @slow @read @development @staging @production )
firefox › pages/otherOrganizations.test.ts › OtherOrganizations › should have visible data-testids - ( @primary @slow @read @development @staging @production )

@renovate renovate bot force-pushed the renovate/npm-jspdf-vulnerability branch from 67acdd6 to 030b595 Compare March 26, 2025 14:39
@renovate renovate bot force-pushed the renovate/npm-jspdf-vulnerability branch 2 times, most recently from 3e7f371 to 0131aa9 Compare May 2, 2025 17:39
@renovate renovate bot force-pushed the renovate/npm-jspdf-vulnerability branch 8 times, most recently from 3167b90 to 3327c92 Compare May 15, 2025 22:18
@renovate renovate bot force-pushed the renovate/npm-jspdf-vulnerability branch 3 times, most recently from b2dadef to c222e52 Compare May 22, 2025 19:48
@renovate renovate bot force-pushed the renovate/npm-jspdf-vulnerability branch 4 times, most recently from d23d9a3 to 9ca1dd9 Compare June 6, 2025 09:51
@renovate renovate bot force-pushed the renovate/npm-jspdf-vulnerability branch 4 times, most recently from aaf50b5 to adcbb45 Compare June 13, 2025 20:27
@renovate renovate bot force-pushed the renovate/npm-jspdf-vulnerability branch 2 times, most recently from 75117d1 to 2202f2b Compare June 25, 2025 16:05
@renovate renovate bot force-pushed the renovate/npm-jspdf-vulnerability branch 2 times, most recently from cc23619 to 1f1574b Compare July 3, 2025 23:53
@renovate renovate bot force-pushed the renovate/npm-jspdf-vulnerability branch 2 times, most recently from 571417d to 91d9fa0 Compare July 10, 2025 07:00
@renovate renovate bot force-pushed the renovate/npm-jspdf-vulnerability branch 8 times, most recently from 75d5bd2 to e89d0cc Compare August 26, 2025 18:14
@renovate renovate bot force-pushed the renovate/npm-jspdf-vulnerability branch 2 times, most recently from c6f4ba6 to 470f313 Compare August 31, 2025 11:02
@renovate renovate bot force-pushed the renovate/npm-jspdf-vulnerability branch 2 times, most recently from 9eb7dfa to 69c7949 Compare September 12, 2025 19:09
@renovate renovate bot force-pushed the renovate/npm-jspdf-vulnerability branch 4 times, most recently from 4709962 to 209e9a3 Compare September 23, 2025 01:47
@renovate renovate bot force-pushed the renovate/npm-jspdf-vulnerability branch 2 times, most recently from a700d4c to 21e95c7 Compare September 29, 2025 17:49
@renovate renovate bot force-pushed the renovate/npm-jspdf-vulnerability branch 2 times, most recently from f557b64 to 2389905 Compare October 7, 2025 15:36
@renovate renovate bot force-pushed the renovate/npm-jspdf-vulnerability branch from 2389905 to d472133 Compare October 21, 2025 17:17
@renovate renovate bot force-pushed the renovate/npm-jspdf-vulnerability branch from d472133 to bcc4bbc Compare December 3, 2025 19:42
@renovate renovate bot force-pushed the renovate/npm-jspdf-vulnerability branch from bcc4bbc to de9ed42 Compare December 31, 2025 16:06
@renovate renovate bot changed the title fix(deps): update dependency jspdf to v3 [security] fix(deps): update dependency jspdf to v4 [security] Jan 5, 2026
@renovate renovate bot force-pushed the renovate/npm-jspdf-vulnerability branch from de9ed42 to e45e627 Compare January 5, 2026 18:01
@renovate renovate bot force-pushed the renovate/npm-jspdf-vulnerability branch from e45e627 to 3e79e1c Compare January 19, 2026 18:05
@renovate renovate bot force-pushed the renovate/npm-jspdf-vulnerability branch from 3e79e1c to ca5333b Compare February 2, 2026 21:31
@renovate renovate bot force-pushed the renovate/npm-jspdf-vulnerability branch 2 times, most recently from bd3c75f to 632f8b4 Compare February 9, 2026 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants