# CVE-2025-65108: md-to-pdf RCE — Fixed in 5.2.5

📦

📦 npm

Not in CISA KEV

CRITICAL severity

# CVE-2025-65108 — md-to-pdf

CRITICAL [Fix: simonhaenisch/md-to-pdf@46bdcf2](https://github.com/simonhaenisch/md-to-pdf/commit/46bdcf2051c8d1758b391c1353185a179a47a4d9)

CVE-2025-65108 is a critical-severity (CVSS 10) Code Injection vulnerability in md-to-pdf. A fix is available for md-to-pdf — see the affected versions and patch details below.

md-to-pdf is vulnerable to arbitrary JavaScript code execution when parsing front matter

Also known as[GHSA-547r-qmjm-8hvw](/vulnerability/GHSA-547r-qmjm-8hvw)

Published

Nov 21, 2025

Updated

Oct 28, 2026

Affected

1 pkg

Patched

1 / 1

Exploits

None indexed

Exploitation data as of Nov 8, 2026 · OSV.dev, NVD, FIRST.org (EPSS)

## Exploitation Status

### Proof-of-concept exploit code exists

-   CISA’s SSVC triage found public proof-of-concept exploit code for this CVE, though no confirmed active exploitation.
-   CISA assesses this as automatable — exploitation doesn’t require manual, per-target effort, which raises the odds of mass scanning and opportunistic attacks.
-   A successful exploit gives an attacker total control of the affected component, not partial access.

Exploitation and automatability from CISA’s SSVC triage for CVE-2025-65108.

## EPSS Exploitation Probability

[via FIRST.org ↗](https://www.first.org/epss/)

1.0%probability of exploitation in next 30 days

Lower Risk0.00%

Lower risk than most CVEs62th percentile — riskier than 62% of all scored CVEsHighest risk

0.00%0.49%0.97%1.46%0.3%1.0%May 26Sep 26Nov 26

Probability of exploitation in the next 30 days, from [FIRST.org EPSS](https://www.first.org/epss/).

## How urgent is this, really

## Where this sits among everything scored

## Real-World Exposure

1 pkg affected

How broadly this vulnerability is actually deployed: weekly install volume shows current usage, and reverse-dependency count shows how many other packages break if it stays unpatched.

81other npm packages depend on this — each one inherits the vulnerability until it's patched upstream

`md-to-pdf`npm

839Kdownloads / week

## Description

#### 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

## Affected Packages

1 total 1 fixed

Ecosystem

Package

Vulnerable range

Fix

📦npm

`md-to-pdf` 

all versions

5.2.5`npm install md-to-pdf@5.2.5`

## Detection & mitigation playbook

Open-source dependency

1.  ### Detect
    
    Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for md-to-pdf, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
    
2.  ### Fix
    
    Update md-to-pdf to 5.2.5 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms CVE-2025-65108 is resolved across your whole dependency graph.
    
3.  ### Workarounds
    
    Stop passing untrusted input into the interpreter or shell: call the affected binary with an argument array rather than a composed command string, reject anything outside a strict allowlist of expected values, and run the component under an account that cannot reach beyond the work it legitimately does.
    

## Frequently Asked Questions

\### 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 ma

O3 Security · Impact-Aware SCA

### Is CVE-2025-65108 in your dependencies?

Find it across npm, including transitive dependencies.

[Scan my dependencies](/book-demo) [How O3 SCA works](/impact-aware-sca)