CVE-2018-5158: Pdfjs dist Malicious PDF Can Inject JavaScript Vulnerability
HIGHCVE-2018-5158 is a HIGH (CVSS 8.8) malicious pdf can inject javascript vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Pdfjs dist libraries in the npm ecosystem. The issue involves malicious pdf can inject javascript into pdf viewer. Remediation is available by upgrading affected packages to version 2.0.550, 1.10.100.
CVE-2018-5158 at a Glance
Security Impact
CVSS: 8.8
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H).
How to Fix CVE-2018-5158
To remediate this vulnerability, upgrade all affected Pdfjs dist 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 pdfjs-dist@2.0.550
npm install pdfjs-dist@1.10.100
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls pdfjs-dist
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2018-5158, inspect your project dependencies using npm:
npm ls pdfjs-dist
Analyze the terminal output to locate any version of Pdfjs dist in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.0.550), your application is affected.
Note: The npm ls pdfjs-dist 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-94: Improper Control of Generation of Code ('Code Injection'), where the product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. In Pdfjs dist, 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-5158 Affected Pdfjs dist Versions
2 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
pdfjs-dist
|
npm |
≥ 2.0.0
< 2.0.550
|
2.0.550
|
|
pdfjs-dist
|
npm |
< 1.10.100
|
1.10.100
|
References
Frequently Asked Questions
What is CVE-2018-5158?
Which Pdfjs dist versions are affected?
What version fixes CVE-2018-5158?
Is pdfjs-dist affected?
What is the CVSS score of CVE-2018-5158?
What CWE is associated with CVE-2018-5158?
How can I check npm dependencies for CVE-2018-5158?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-7jg2-jgv3-fmr4",
"modified" : "2024-05-28T20:43:53Z",
"published" : "2022-05-14T01:22:02Z",
"aliases" : [ "CVE-2018-5158" ],
"summary" : "Malicious PDF can inject JavaScript into PDF Viewer",
"details" : "The PDF viewer does not sufficiently sanitize PostScript calculator functions, allowing malicious JavaScript to be injected through a crafted PDF file. This JavaScript can then be run with the permissions of the PDF viewer by its worker. This vulnerability affects Firefox ESR < 52.8, Firefox < 60 and PDF.js < 2.0.550.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "pdfjs-dist"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "2.0.0"
}, {
"fixed" : "2.0.550"
} ]
} ]
}, {
"package" : {
"ecosystem" : "npm",
"name" : "pdfjs-dist"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "1.10.100"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2018-5158"
}, {
"type" : "WEB",
"url" : "https://github.com/mozilla/pdf.js/pull/9659"
}, {
"type" : "WEB",
"url" : "https://github.com/mozilla/pdf.js/commit/2dc4af525d1612c98afcd1e6bee57d4788f78f97"
}, {
"type" : "WEB",
"url" : "https://access.redhat.com/errata/RHSA-2018:1414"
}, {
"type" : "WEB",
"url" : "https://access.redhat.com/errata/RHSA-2018:1415"
}, {
"type" : "WEB",
"url" : "https://bugzilla.mozilla.org/show_bug.cgi?id=1452075"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/mozilla/pdf.js"
}, {
"type" : "WEB",
"url" : "https://lists.debian.org/debian-lts-announce/2018/05/msg00007.html"
}, {
"type" : "WEB",
"url" : "https://security.gentoo.org/glsa/201810-01"
}, {
"type" : "WEB",
"url" : "https://usn.ubuntu.com/3645-1"
}, {
"type" : "WEB",
"url" : "https://www.debian.org/security/2018/dsa-4199"
}, {
"type" : "WEB",
"url" : "https://www.mozilla.org/security/advisories/mfsa2018-11"
}, {
"type" : "WEB",
"url" : "https://www.mozilla.org/security/advisories/mfsa2018-12"
}, {
"type" : "WEB",
"url" : "http://www.securityfocus.com/bid/104136"
}, {
"type" : "WEB",
"url" : "http://www.securitytracker.com/id/1040896"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-94" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2024-05-28T20:43:53Z",
"nvd_published_at" : "2018-06-11T21:29:00Z"
}
}