Skip to main content

CVE-2022-46161: CWE-94: Improper Control of Generation of Code ('Code Injection') in bpampuch pdfmake

Medium
Published: Tue Dec 06 2022 (12/06/2022, 18:47:00 UTC)
Source: CVE
Vendor/Project: bpampuch
Product: pdfmake

Description

pdfmake is an open source client/server side PDF printing in pure JavaScript. In versions up to and including 0.2.5 pdfmake contains an unsafe evaluation of user controlled input. Users of pdfmake are thus subject to arbitrary code execution in the context of the process running the pdfmake code. There are no known fixes for this issue. Users are advised to restrict access to trusted user input.

AI-Powered Analysis

AILast updated: 06/21/2025, 20:06:48 UTC

Technical Analysis

CVE-2022-46161 is a code injection vulnerability classified under CWE-94 affecting the open-source JavaScript library pdfmake, maintained by bpampuch. Pdfmake is widely used for generating PDF documents on both client and server sides using pure JavaScript. Versions up to and including 0.2.5 are vulnerable due to an unsafe evaluation of user-controlled input. Specifically, the library performs dynamic code evaluation (e.g., using eval or similar functions) on input that can be influenced by users without sufficient sanitization or validation. This flaw allows an attacker to inject arbitrary code that will execute in the context of the process running pdfmake. Since pdfmake can be used in server environments (e.g., Node.js) or client-side applications, exploitation could lead to arbitrary code execution on the server or client machine, depending on deployment. No official patches or fixes are currently available for this vulnerability, and users are advised to restrict pdfmake usage to trusted inputs only. There are no known exploits in the wild at this time, but the potential for exploitation remains significant due to the nature of code injection vulnerabilities. The vulnerability was published on December 6, 2022, and has been enriched by CISA, indicating recognition by cybersecurity authorities. The lack of a patch and the direct impact on code execution make this a critical concern for applications relying on pdfmake for PDF generation, especially in environments processing untrusted or user-supplied data.

Potential Impact

For European organizations, the impact of CVE-2022-46161 can be substantial, particularly for those using pdfmake in web applications, document management systems, or internal tools that generate PDFs dynamically. Exploitation could lead to arbitrary code execution, resulting in full compromise of the server or client environment where pdfmake is running. This can lead to data breaches, unauthorized access to sensitive information, disruption of services, and potential lateral movement within networks. Organizations in sectors such as finance, healthcare, government, and critical infrastructure, which often handle sensitive documents and rely on PDF generation, are at higher risk. The vulnerability undermines confidentiality, integrity, and availability by allowing attackers to execute malicious payloads, modify documents, or disrupt PDF generation workflows. Since pdfmake is a JavaScript library, environments using Node.js servers or Electron-based desktop applications are particularly vulnerable. The absence of a patch increases the window of exposure, and the medium severity rating may underestimate the real-world impact if exploited in high-value targets. European organizations with web-facing applications or internal tools that accept user input for PDF generation should consider this vulnerability a serious threat.

Mitigation Recommendations

Given the absence of an official patch, European organizations should implement the following specific mitigations: 1) Strictly validate and sanitize all user inputs before passing them to pdfmake to ensure no malicious code can be injected. Employ allow-listing of input content and reject any input containing executable code or suspicious characters. 2) Isolate pdfmake execution environments, especially on servers, using containerization or sandboxing techniques to limit the impact of potential code execution. 3) Where possible, avoid using pdfmake versions <= 0.2.5 and consider alternative PDF generation libraries that do not rely on unsafe code evaluation. 4) Implement runtime application self-protection (RASP) or web application firewalls (WAFs) with custom rules to detect and block suspicious payloads targeting PDF generation endpoints. 5) Monitor logs for unusual activity related to pdfmake usage, such as unexpected command execution or process spawning. 6) Educate developers and DevOps teams about the risks of dynamic code evaluation and enforce secure coding practices to prevent similar vulnerabilities. 7) If pdfmake must be used, restrict its usage to trusted internal inputs only, avoiding exposure to external or unauthenticated users. 8) Regularly review and update dependency inventories to identify vulnerable versions and plan for migration once patches become available.

Need more detailed analysis?Get Pro

Technical Details

Data Version
5.1
Assigner Short Name
GitHub_M
Date Reserved
2022-11-28T17:27:19.997Z
Cisa Enriched
true

Threat ID: 682d9849c4522896dcbf6ed7

Added to database: 5/21/2025, 9:09:29 AM

Last enriched: 6/21/2025, 8:06:48 PM

Last updated: 8/5/2025, 11:29:52 PM

Views: 12

Actions

PRO

Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.

Please log in to the Console to use AI analysis features.

Need enhanced features?

Contact root@offseq.com for Pro access with improved analysis and higher rate limits.

Latest Threats