GHSA-547r-qmjm-8hvw
CRITICALmd-to-pdf vulnerable to arbitrary JavaScript code execution when parsing front matter
EPSS Exploitation Probability
EPSS (Exploit Prediction Scoring System) is a daily probability model maintained by FIRST.org. It estimates the likelihood a CVE will be exploited in production environments within the next 30 days, derived from real-world threat intelligence signals.
Blast Radius
Weekly download volume for affected packages — a proxy for how broadly this vulnerability is deployed.
md-to-pdfnpmDescription
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
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 📦npm | md-to-pdf | all versions | 5.2.5 |
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for md-to-pdf. O3's reachability analysis confirms whether the vulnerable code path is actually invoked in your application, so you act on real exposure instead of every transitive match.
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 GHSA-547r-qmjm-8hvw is resolved across your whole dependency graph.
Workarounds
If you can't upgrade right away: gate or disable the affected feature, validate untrusted input at the boundary, and avoid passing attacker-controlled data into the vulnerable path. O3's runtime protection blocks exploitation in production as an interim safeguard until the upgrade lands.
How O3 protects you
O3 pinpoints whether GHSA-547r-qmjm-8hvw is reachable in your code and exactly where to fix it, then blocks exploitation in production at runtime until the patched version is deployed.
Tailored to GHSA-547r-qmjm-8hvw. Runtime protection reduces exposure until a permanent patch is applied and verified — it complements patching, it doesn't replace it.
Frequently Asked Questions
Is GHSA-547r-qmjm-8hvw in your dependencies?
O3 detects GHSA-547r-qmjm-8hvw across npm dependencies and uses function-level reachability to confirm whether the vulnerable code path is actually reachable — not just present. No false positives.