Summary
jsPDF's Acroform module previously allowed untrusted values to flow directly into low-level PDF object streams without proper neutralization.
An attacker who can supply unsanitized input to specific Acroform field APIs may inject arbitrary PDF objects (including JavaScript actions) that execute when a victim opens the generated PDF.
Affected context
This vulnerability affects applications that use jsPDF's Acroform module to generate interactive PDF forms and expose Acroform configuration to end users or other untrusted sources.
The risk is most significant where application logic passes user-controlled strings directly into:
AcroformChoiceField.addOptionAcroformChoiceField.setOptionsAcroFormCheckBox.appearanceStateAcroFormRadioButton.appearanceState
without validation, escaping, or constraining the allowed values.
Exploit preconditions
- Attack surface: PDF generation layer in applications using jsPDF Acroform features.
- Required access: Ability to influence or control data passed into the vulnerable Acroform APIs (e.g., form builders, admin panels, template editors, or any user-supplied configuration).
- Trigger point: Victim opens the crafted PDF in a PDF viewer that supports embedded JavaScript or respects the injected PDF objects.
- Why exploitation is possible: The library treated certain Acroform values as trusted and embedded them into the PDF structure without proper neutralization or structural validation, allowing attacker-crafted content to break out of the expected data context and introduce arbitrary PDF objects such as JavaScript actions.
Why this happens
The core issue is an improper output neutralization pattern: jsPDF's Acroform APIs allowed caller-provided values to be written directly into the PDF's internal object representation without enforcing a safe subset or performing escaping/encoding appropriate to the PDF syntax.
In terms of CWE-116, data that should have been treated strictly as content (e.g., choice option labels or appearance states) was instead inserted into a context where PDF object syntax and action definitions are interpreted.
This lack of contextual encoding and structural validation means an attacker can craft strings that alter the PDF object graph, attach additional objects, or reference JavaScript actions, turning benign configuration points into injection sinks.
Potential impact
- Attacker-controlled JavaScript execution when the victim opens the generated PDF (depending on viewer capabilities and security settings).
- Injection of arbitrary PDF objects, potentially altering document behavior, navigation, or embedded actions.
- Social engineering scenarios where a seemingly legitimate PDF performs unexpected actions (e.g., opening URLs, interacting with forms, or manipulating the viewing environment).
- Potential bypass of upstream input validation if that validation assumes the values are used purely as display text rather than as part of a structured PDF object model.
General mitigation guidance
Effective mitigation focuses on treating all Acroform configuration values as untrusted unless they originate from hard-coded or strictly controlled sources.
Recommended defensive patterns include:
- Strict whitelisting: Constrain values for
appearanceStateand option lists to a predefined, application-controlled set of allowed tokens rather than accepting free-form strings. - Context-aware encoding: When dynamic data must be used, apply encoding or escaping that is tailored to the PDF syntax and prevents breaking out of the intended data context.
- Separation of data and structure: Keep structural aspects of the PDF (object definitions, actions, references) fully under application or library control; allow users to influence only plain-text content or identifiers that cannot change the document structure.
- Input validation at boundaries: Validate and normalize data as early as possible (e.g., at HTTP/API boundaries or UI layers) so that only well-formed, expected values reach the PDF generation layer.
- Principle of least capability for user input: Avoid exposing low-level configuration options of jsPDF Acroform to untrusted users; provide higher-level abstractions that internally enforce safe defaults and disallow direct injection of raw object content.
How teams detect issues like this
Organizations can detect this class of issue by focusing on where user-controlled data flows into PDF generation code and, specifically, into Acroform APIs:
- Static analysis patterns:
- Identify calls to
AcroformChoiceField.addOption,AcroformChoiceField.setOptions,AcroFormCheckBox.appearanceState, andAcroFormRadioButton.appearanceState. - Flag instances where arguments are derived from HTTP request parameters, query strings, JSON bodies, or other user-controllable sources without intermediate validation or encoding.
- Code review signals:
- Direct passing of UI/editor content into PDF configuration.
- Helper methods or wrapper components that expose "raw" Acroform configuration to external callers.
- Lack of clear validation or whitelisting for appearance states and option values.
- Policy enforcement:
- Introduce secure coding guidelines that require PDF-generating code to treat all dynamic values as untrusted.
- Use automated code review tools or linters that enforce checks on PDF and document-generation libraries, ensuring proper neutralization steps are present.

