jsPDF Affected by Client-Side/Server-Side Denial of Service via Malicious GIF Dimensions
Description
jsPDF is a library to generate PDFs in JavaScript. Prior to 4.2.0, 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, which lead to excessive memory allocation. Other affected methods are: html. The vulnerability has been fixed in jsPDF 4.2.0. As a workaround, sanitize image data or URLs before passing it to the addImage method or one of the other affected methods.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
jspdfnpm | < 4.2.0 | 4.2.0 |
Affected products
1Patches
12e5e156e284dMerge commit from fork
1 file changed · +10 −0
src/libs/omggif.js+10 −0 modified@@ -610,6 +610,11 @@ function GifReader(buf) { this.decodeAndBlitFrameBGRA = function(frame_num, pixels) { var frame = this.frameInfo(frame_num); var num_pixels = frame.width * frame.height; + + if (num_pixels > 512 * 1024 * 1024) { + throw new Error("Image dimensions exceed 512MB, which is too large."); + } + var index_stream = new Uint8Array(num_pixels); // At most 8-bit indices. GifReaderLZWOutputIndexStream( buf, @@ -682,6 +687,11 @@ function GifReader(buf) { this.decodeAndBlitFrameRGBA = function(frame_num, pixels) { var frame = this.frameInfo(frame_num); var num_pixels = frame.width * frame.height; + + if (num_pixels > 512 * 1024 * 1024) { + throw new Error("Image dimensions exceed 512MB, which is too large."); + } + var index_stream = new Uint8Array(num_pixels); // At most 8-bit indices. GifReaderLZWOutputIndexStream( buf,
Vulnerability mechanics
Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
6- github.com/advisories/GHSA-67pg-wm7f-q7fjghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2026-25535ghsaADVISORY
- github.com/ZeroXJacks/CVEs/blob/main/2026/CVE-2026-25535.mdghsax_refsource_MISCWEB
- github.com/parallax/jsPDF/commit/2e5e156e284d92c7d134bce97e6418756941d5e6ghsax_refsource_MISCWEB
- github.com/parallax/jsPDF/releases/tag/v4.2.0ghsax_refsource_MISCWEB
- github.com/parallax/jsPDF/security/advisories/GHSA-67pg-wm7f-q7fjghsax_refsource_CONFIRMWEB
News mentions
0No linked articles in our index yet.