10.0critical
md-to-pdf is vulnerable to arbitrary JavaScript code execution when parsing front matter
- Severity
- 10.0critical CVSS:3.1 by GitHub_M
- Exploit likelihood
- 0.96% (higher than 62% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-547r-qmjm-8hvw
Description
md-to-pdf is a CLI tool for converting Markdown files to PDF using Node.js and headless Chrome. Prior to version 5.2.5, a Markdown front-matter block that contains JavaScript delimiter causes the JS engine in gray-matter library to execute arbitrary code in the Markdown to PDF converter process of md-to-pdf library, resulting in remote code execution. This issue has been patched in version 5.2.5.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| simonhaenisch md-to-pdf | < 5.2.5 | CVE List |
| md-to-pdf (npm) | before 5.2.5 | GitHub Advisory Database |
All scores
| GitHub_M | 10.0critical CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H |
| GitHub | 10.0critical CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H |
Classification
SSVC (CISA-ADP): exploitation poc, automatable yes, technical impact total.
What each source says
CVE List
md-to-pdf is a CLI tool for converting Markdown files to PDF using Node.js and headless Chrome. Prior to version 5.2.5, a Markdown front-matter block that contains JavaScript delimiter causes the JS engine in gray-matter library to execute arbitrary code in the Markdown to PDF converter process of md-to-pdf library, resulting in remote code execution. This issue has been patched in version 5.2.5.
GitHub Advisory Database
Summary
A Markdown front-matter block that contains JavaScript delimiter causes the JS engine in gray-matter library to execute arbitrary code in the Markdown to PDF converter process of md-to-pdf library, resulting in remote code execution.
Details
md-to-pdf uses the gray-matter library to parse front-matter. Gray-matter exposes a JavaScript engine that, when enabled or triggered by certain front-matter delimiters (e.g. ---js or ---javascript), will evaluate the front-matter contents as JavaScript. If user-supplied Markdown is fed to md-to-pdf and the front-matter contains malicious JS, the converter process will execute that code.
PoC
const { mdToPdf } = require('md-to-pdf');
var payload = '---javascript\n((require("child_process")).execSync("calc.exe"))\n---RCE';
(async () => {
await mdToPdf({ content: payload }, { dest: './output.pdf'});
})();
Running the PoC on Windows launches the calculator application, demonstrating arbitrary code execution.
Impact
- Remote code execution in the process that performs Markdown->PDF conversion.
- If the converter is run in a web app or cloud service, an attacker uploading malicious Markdown can execute arbitrary commands on the
NVD (es)
md-to-pdf es una herramienta CLI para convertir archivos Markdown a PDF usando Node.js y Chrome sin interfaz gráfica. Versiones anteriores a la versión 5.2.5, un bloque de metadatos (front-matter) de Markdown que contiene un delimitador de JavaScript provoca que el motor JS en la biblioteca gray-matter ejecute código arbitrario en el proceso del conversor de Markdown a PDF de la biblioteca md-to-pdf, resultando en ejecución remota de código. Este problema ha sido parcheado en la versión 5.2.5.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2025-65108 changed 2025-11-24 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-547r-qmjm-8hvw changed 2025-11-25 | CC-BY-4.0 |
| NVD | CVE-2025-65108 changed 2026-10-18 | Public domain |