CVE-2025-65108: md-to-pdf is vulnerable to arbitrary JavaScript code execution when parsing front matter

Published Nov 20, 2025
·
Updated

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("childprocess")).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

Other sources

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.

MITRE

Affected Software

1 affected componentFixes available
npm/md-to-pdf<5.2.5
5.2.5

Event History

Nov 20, 2025
Advisory Published
via GitHub·05:48 PM
Data Sourced
via GitHub·05:48 PM
DescriptionSeverityWeaknessAffected Software
Nov 21, 2025
CVE Published
via MITRE·09:52 PM
Data Sourced
via MITRE·09:52 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·10:16 PM
DescriptionSeverityWeakness
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2025-65108?

CVE-2025-65108 is classified as a remote code execution vulnerability, which poses a significant security risk.

2

How do I fix CVE-2025-65108?

To mitigate CVE-2025-65108, upgrade the md-to-pdf library to version 5.2.5 or later.

3

What causes CVE-2025-65108?

CVE-2025-65108 is caused by a Markdown front-matter block containing a JavaScript delimiter that leads to arbitrary code execution.

4

Which library is affected by CVE-2025-65108?

The CVE-2025-65108 vulnerability affects the md-to-pdf library that utilizes the gray-matter library.

5

Can CVE-2025-65108 be exploited remotely?

Yes, CVE-2025-65108 can be exploited by an attacker remotely, potentially leading to complete system compromise.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203