CVE-2018-19787: Lxml Improper Neutralization Of Input During Vulnerability
MODERATECVE-2018-19787 is a MODERATE (CVSS 6.1) improper neutralization of input during vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting Lxml libraries in the PyPI ecosystem. The issue involves improper neutralization of input during web page generation in lxml. Remediation is available by upgrading affected packages to version 4.2.5.
CVE-2018-19787 at a Glance
Security Impact
CVSS: 6.1
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:C/C:L/I:L/A:N).
How to Fix CVE-2018-19787
To remediate this vulnerability, upgrade all affected Lxml dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install lxml>=4.2.5
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show lxml
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2018-19787, inspect your installed packages using pip:
pip show lxml
Analyze the terminal output to locate any version of Lxml in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.2.5), your application is affected.
Note: The pip show lxml command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In Lxml, 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-19787 Affected Lxml Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
lxml
|
PyPI |
< 4.2.5
|
4.2.5
|
References
Frequently Asked Questions
What is CVE-2018-19787?
Which Lxml versions are affected?
What version fixes CVE-2018-19787?
Is lxml affected?
What is the CVSS score of CVE-2018-19787?
What CWE is associated with CVE-2018-19787?
How can I check PyPI dependencies for CVE-2018-19787?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-xp26-p53h-6h2p",
"modified" : "2025-12-20T05:24:54Z",
"published" : "2022-05-13T01:13:21Z",
"aliases" : [ "CVE-2018-19787" ],
"summary" : "Improper Neutralization of Input During Web Page Generation in LXML",
"details" : "An issue was discovered in lxml before 4.2.5. lxml/html/clean.py in the lxml.html.clean module does not remove javascript: URLs that use escaping, allowing a remote attacker to conduct XSS attacks, as demonstrated by \"j a v a s c r i p t:\" in Internet Explorer. This is a similar issue to CVE-2014-3146.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N"
}, {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "lxml"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "4.2.5"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2018-19787"
}, {
"type" : "WEB",
"url" : "https://github.com/lxml/lxml/commit/6be1d081b49c97cfd7b3fbd934a193b668629109"
}, {
"type" : "ADVISORY",
"url" : "https://github.com/advisories/GHSA-xp26-p53h-6h2p"
}, {
"type" : "WEB",
"url" : "https://github.com/lxml/lxml"
}, {
"type" : "WEB",
"url" : "https://github.com/pypa/advisory-database/tree/main/vulns/lxml/PYSEC-2018-12.yaml"
}, {
"type" : "WEB",
"url" : "https://lists.debian.org/debian-lts-announce/2018/12/msg00001.html"
}, {
"type" : "WEB",
"url" : "https://lists.debian.org/debian-lts-announce/2020/11/msg00044.html"
}, {
"type" : "WEB",
"url" : "https://usn.ubuntu.com/3841-1"
}, {
"type" : "WEB",
"url" : "https://usn.ubuntu.com/3841-2"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-79" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2022-06-28T23:26:59Z",
"nvd_published_at" : "2018-12-02T10:29:00Z"
}
}