CVE-2018-3770: Markdown pdf Remote Code Execution Vulnerability

MODERATE
Advisory Identifier: GHSA-p7c9-jqhq-vr3v
CVSS 5.5
CWE-22
Published
Advisory Summary

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

CVE Identifier CVE-2018-3770
GHSA Identifier GHSA-p7c9-jqhq-vr3v
Severity MODERATE
CVSS v3.1 Base Score 5.5
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product Markdown pdf
Package Ecosystem npm
Published Date
Last Updated

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).

Attack Vector Local (AV:L)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity None (I:N)
Availability None (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.

markdown-pdf fixed: 9.0.0
npm install markdown-pdf@9.0.0
Verify Direct and Transitive Dependencies

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

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. ## Recommendation Upgrade to version 9.0.0 or later.

CVE-2018-3770 Affected Markdown pdf Versions

1 component(s)
Fixed Versions:
9.0.0
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?
CVE-2018-3770 is a security vulnerability in Markdown pdf involving Remote Code Execution in markdown-pdf under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which Markdown pdf versions are affected?
Affected versions include releases prior to 9.0.0 across affected packages: markdown-pdf.
What version fixes CVE-2018-3770?
Upgrading to 9.0.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is markdown-pdf affected?
Yes, markdown-pdf is affected in releases prior to 9.0.0. Upgrade your dependency to 9.0.0 or later.
What is the CVSS score of CVE-2018-3770?
CVE-2018-3770 has a CVSS v3.1 base score of 5.5 (MODERATE) with vector string CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N.
What CWE is associated with CVE-2018-3770?
CVE-2018-3770 is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') (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.).
How can I check npm dependencies for CVE-2018-3770?
Run the dependency tree command: 'npm ls markdown-pdf'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "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"
  }
}