CVE-2018-3770: Markdown pdf Remote Code Execution Vulnerability
MODERATECVE-2018-3770 is a MODERATE (CVSS 5.5) remote code execution vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Markdown pdf libraries in the npm ecosystem. The issue involves remote code execution in markdown-pdf. Remediation is available by upgrading affected packages to version 9.0.0.
CVE-2018-3770 at a Glance
Security Impact
CVSS: 5.5
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N).
How to Fix CVE-2018-3770
To remediate this vulnerability, upgrade all affected Markdown pdf dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install markdown-pdf@9.0.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls markdown-pdf
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2018-3770, inspect your project dependencies using npm:
npm ls markdown-pdf
Analyze the terminal output to locate any version of Markdown pdf in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 9.0.0), your application is affected.
Note: The npm ls markdown-pdf command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In Markdown pdf, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2018-3770 Affected Markdown pdf Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
markdown-pdf
|
npm |
< 9.0.0
|
9.0.0
|
References
Frequently Asked Questions
What is CVE-2018-3770?
Which Markdown pdf versions are affected?
What version fixes CVE-2018-3770?
Is markdown-pdf affected?
What is the CVSS score of CVE-2018-3770?
What CWE is associated with CVE-2018-3770?
How can I check npm dependencies for CVE-2018-3770?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-p7c9-jqhq-vr3v",
"modified" : "2023-03-01T01:36:36Z",
"published" : "2018-07-27T17:03:46Z",
"aliases" : [ "CVE-2018-3770" ],
"summary" : "Remote Code Execution in markdown-pdf",
"details" : "Versions of `markdown-pdf` prior to 9.0.0 are vulnerable to Remote Code Execution. The package fails to sanitize HTML code in markdown files. If markdown files with malicious HTML are converted to PDF, the resulting PDF file will execute any JavaScript code in the original markdown file. This may allow attackers to execute Remote Code.\n\n\n## Recommendation\n\nUpgrade to version 9.0.0 or later.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "markdown-pdf"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "9.0.0"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2018-3770"
}, {
"type" : "WEB",
"url" : "https://hackerone.com/reports/360727"
}, {
"type" : "ADVISORY",
"url" : "https://github.com/advisories/GHSA-p7c9-jqhq-vr3v"
}, {
"type" : "WEB",
"url" : "https://www.npmjs.com/advisories/991"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-22" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2020-06-16T21:48:26Z",
"nvd_published_at" : "2018-07-20T22:29:00Z"
}
}