Executive brief
pdfme is a JavaScript library for generating PDF documents with dynamic templates. The expression evaluation feature in versions 5.2.0 through 5.4.0 contains vulnerabilities that allow attackers to escape the expression sandbox and execute arbitrary JavaScript code, steal sensitive data like cookies and authentication tokens, or modify application behavior through prototype pollution attacks. This requires user interaction to load a malicious template.
Technical details
The @pdfme/common library's expression evaluator implements a sandbox to safely evaluate template expressions, but this sandbox can be bypassed through multiple attack vectors. The primary vulnerability is a sandbox escape that allows attackers to obtain the Function constructor using indirect object property access methods like Object.getOwnPropertyDescriptor and Object.getPrototypeOf, enabling arbitrary JavaScript code execution in the application context. The secondary vulnerability involves prototype pollution through unfiltered access to prototype accessor methods (__lookupGetter__, __lookupSetter__, __defineGetter__, __defineSetter__) which can be exploited with Object.assign to pollute the prototype chain. The attack vector is network-based with low complexity and requires user interaction (loading a malicious PDF template). Affected versions are 5.2.0 through 5.4.0; a fix was released in version 5.4.1 implementing safeAssign and enhanced input sanitization.
Affected products
- pdfme @pdfme/common 5.2.0 through 5.4.0
Timeline
- 2025-07-10: disclosed: GHSA-54xv-94qv-2gfg published
- 2025-07-09: patched: Version 5.4.1 released with XSS and prototype pollution fixes (commit 0dd5473)