Breaking mPDF with regex and logic
Source Reddit NetSec
Description
A security issue has been identified in mPDF, a widely used open-source PHP library for generating PDFs from HTML, with approximately 70 million installs. Due to quirks in its logic and the use of regex, it is possible to craft inputs that trigger unintended web requests, even when inputs are sanitized. This behavior can potentially lead to remote code execution (RCE) scenarios. Although no known exploits are currently active in the wild and no patches have been released, the threat is considered medium severity. European organizations using mPDF in web applications that process user-generated HTML content are at risk, especially those lacking additional input validation or network restrictions. Mitigations include applying strict input validation beyond mPDF’s internal sanitization, isolating PDF generation processes, and monitoring outbound web requests from servers. Countries with significant PHP development ecosystems and large web hosting industries, such as Germany, France, and the UK, are more likely to be affected. Given the potential for RCE without user interaction and the widespread use of mPDF, the suggested severity is high. Defenders should prioritize reviewing mPDF usage and implement compensating controls until an official patch is available.