# CVE-2021-43818: HTML Cleaner allows crafted and SVG embedded scripts to pass through

> Attackers can inject malicious scripts via crafted HTML or embedded SVGs, leading to XSS, affecting users of the lxml library.

- **Severity:** High 8.2 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:H/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 13 Dec 2021
- **Updated:** 18 Dec 2025
- **Also known as:** ALPINE-CVE-2021-43818, ALSA-2022:1763, ALSA-2022:1932, AZL-7025, CLSA-2024-1729629058, CLSA-2026-1792442901, DEBIAN-CVE-2021-43818, DLA-2871-1, DSA-5043-1, GHSA-55x5-fj6c-h6m8, MGASA-2021-0595, OESA-2022-1482, PYSEC-2021-852, RHSA-2022:1664, RHSA-2022:1763, RHSA-2022:1932, RLSA-2022:1763, RLSA-2022:1932, UBUNTU-CVE-2021-43818, USN-5225-1, openSUSE-SU-2024:11713-1

## What is CVE-2021-43818?

CVE-2021-43818 is a high-severity cross-site scripting vulnerability in Debian Debian Linux, published on 13 Dec 2021. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

### Official description

lxml is a library for processing XML and HTML in the Python language. Prior to version 4.6.5, the HTML Cleaner in lxml.html lets certain crafted script content pass through, as well as script content in SVG files embedded using data URIs. Users that employ the HTML cleaner in a security relevant context should upgrade to lxml 4.6.5 to receive a patch. There are no known workarounds available.

Weakness: CWE-79 (Improper Neutralization of Input During Web Page Generation), CWE-74 (Improper Neutralization of Special Elements in Output Used by a Downstream Component)

## Which versions are affected by CVE-2021-43818?

3 open source packages ship an affected version, including lxml. It affects 11 products.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `lxml` | PyPI | All versions | 4.6.5 |
| `lxml` | PyPI | All versions | 4.6.5 |
| `lxml` | PyPI | All versions | 4.6.5 |
| `python3-lxml` | AlmaLinux:8 | All versions | 4.2.3-4.el8 |
| `python39` | AlmaLinux:8 | All versions | 3.9.7-1.module_el8.6.0+2780+a40f65e1 |
| `python39-Cython` | AlmaLinux:8 | All versions | 0.29.21-5.module_el8.6.0+2780+a40f65e1 |
| `python39-PyMySQL` | AlmaLinux:8 | All versions | 0.10.1-2.module_el8.6.0+2780+a40f65e1 |
| `python39-attrs` | AlmaLinux:8 | All versions | 20.3.0-2.module_el8.6.0+2780+a40f65e1 |
| `python39-cffi` | AlmaLinux:8 | All versions | 1.14.3-2.module_el8.6.0+2780+a40f65e1 |
| `python39-chardet` | AlmaLinux:8 | All versions | 3.0.4-19.module_el8.6.0+2780+a40f65e1 |
| `python39-cryptography` | AlmaLinux:8 | All versions | 3.3.1-2.module_el8.6.0+2780+a40f65e1 |
| `python39-debug` | AlmaLinux:8 | All versions | 3.9.7-1.module_el8.6.0+2780+a40f65e1 |
| `python39-devel` | AlmaLinux:8 | All versions | 3.9.7-1.module_el8.6.0+2780+a40f65e1 |
| `python39-idle` | AlmaLinux:8 | All versions | 3.9.7-1.module_el8.6.0+2780+a40f65e1 |
| `python39-idna` | AlmaLinux:8 | All versions | 2.10-3.module_el8.6.0+2780+a40f65e1 |
| `python39-iniconfig` | AlmaLinux:8 | All versions | 1.1.1-2.module_el8.6.0+2780+a40f65e1 |
| `python39-libs` | AlmaLinux:8 | All versions | 3.9.7-1.module_el8.6.0+2780+a40f65e1 |
| `python39-lxml` | AlmaLinux:8 | All versions | 4.6.5-1.module_el8.6.0+2780+a40f65e1 |
| `python39-mod_wsgi` | AlmaLinux:8 | All versions | 4.7.1-4.module_el8.6.0+2780+a40f65e1 |
| `python39-more-itertools` | AlmaLinux:8 | All versions | 8.5.0-2.module_el8.6.0+2780+a40f65e1 |
| `python39-numpy` | AlmaLinux:8 | All versions | 1.19.4-3.module_el8.6.0+2780+a40f65e1 |
| `python39-numpy-doc` | AlmaLinux:8 | All versions | 1.19.4-3.module_el8.6.0+2780+a40f65e1 |
| `python39-numpy-f2py` | AlmaLinux:8 | All versions | 1.19.4-3.module_el8.6.0+2780+a40f65e1 |
| `python39-packaging` | AlmaLinux:8 | All versions | 20.4-4.module_el8.6.0+2780+a40f65e1 |
| `python39-pip` | AlmaLinux:8 | All versions | 20.2.4-7.module_el8.6.0+2780+a40f65e1 |
| `python39-pip-wheel` | AlmaLinux:8 | All versions | 20.2.4-7.module_el8.6.0+2780+a40f65e1 |
| `python39-pluggy` | AlmaLinux:8 | All versions | 0.13.1-3.module_el8.6.0+2780+a40f65e1 |
| `python39-ply` | AlmaLinux:8 | All versions | 3.11-10.module_el8.6.0+2780+a40f65e1 |
| `python39-psutil` | AlmaLinux:8 | All versions | 5.8.0-4.module_el8.6.0+2780+a40f65e1 |
| `python39-psycopg2` | AlmaLinux:8 | All versions | 2.8.6-2.module_el8.6.0+2780+a40f65e1 |
| `python39-psycopg2-doc` | AlmaLinux:8 | All versions | 2.8.6-2.module_el8.6.0+2780+a40f65e1 |
| `python39-psycopg2-tests` | AlmaLinux:8 | All versions | 2.8.6-2.module_el8.6.0+2780+a40f65e1 |
| `python39-py` | AlmaLinux:8 | All versions | 1.10.0-1.module_el8.6.0+2780+a40f65e1 |
| `python39-pybind11` | AlmaLinux:8 | All versions | 2.7.1-1.module_el8.6.0+2780+a40f65e1 |
| `python39-pybind11-devel` | AlmaLinux:8 | All versions | 2.7.1-1.module_el8.6.0+2780+a40f65e1 |
| `python39-pycparser` | AlmaLinux:8 | All versions | 2.20-3.module_el8.6.0+2780+a40f65e1 |
| `python39-pyparsing` | AlmaLinux:8 | All versions | 2.4.7-5.module_el8.6.0+2780+a40f65e1 |
| `python39-pysocks` | AlmaLinux:8 | All versions | 1.7.1-4.module_el8.6.0+2780+a40f65e1 |
| `python39-pytest` | AlmaLinux:8 | All versions | 6.0.2-2.module_el8.6.0+2780+a40f65e1 |
| `python39-pyyaml` | AlmaLinux:8 | All versions | 5.4.1-1.module_el8.6.0+2780+a40f65e1 |

Products: Debian Debian Linux, Fedoraproject Fedora, Lxml Lxml, Netapp Hci Storage Node Firmware, Netapp Solidfire, Netapp Solidfire Enterprise Sds, Oracle Communications Cloud Native Core Binding Support Function, Oracle Communications Cloud Native Core Network Exposure Function, Oracle Communications Cloud Native Core Policy, Oracle Http Server, Oracle Zfs Storage Appliance Kit.

## How do I fix CVE-2021-43818?

Upgrade lxml to 4.6.5 or later.

## Is CVE-2021-43818 being exploited?

There is no known exploitation of CVE-2021-43818 in the wild and no public exploit code.

## Other vulnerabilities in Debian Debian Linux

- [CVE-2015-3306](https://insights.sbomify.com/CVE-2015-3306/): ProFTPD Improper Access Control (critical 10.0, exploited in the wild)
- [CVE-2025-49113](https://insights.sbomify.com/CVE-2025-49113/): RoundCube Webmail Deserialization of Untrusted Data (critical 9.9, exploited in the wild)
- [CVE-2026-24061](https://insights.sbomify.com/CVE-2026-24061/): GNU InetUtils Argument Injection (critical 9.8, exploited in the wild)
- [CVE-2025-39682](https://insights.sbomify.com/CVE-2025-39682/): Linux Kernel Improper Check for Unusual or Exceptional Conditions (critical 9.8, exploited in the wild)
- [CVE-2024-9680](https://insights.sbomify.com/CVE-2024-9680/): Mozilla Firefox Use-After-Free (critical 9.8, exploited in the wild)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2021-43818 and fix it if it is affected.

What it is: CVE-2021-43818 is a high-severity cross-site scripting vulnerability in Debian Debian Linux, published on 13 Dec 2021. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of CVE-2021-43818 in the wild and no public exploit code.

Affected packages and fixed versions:
- lxml (PyPI): affected all versions; fixed in 4.6.5
- lxml (PyPI): affected all versions; fixed in 4.6.5
- lxml (PyPI): affected all versions; fixed in 4.6.5

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2021-43818/ (Markdown: https://insights.sbomify.com/CVE-2021-43818/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2021-43818
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2021-43818
- OSV: https://osv.dev/vulnerability/CVE-2021-43818

---
From sbomify Insights: https://insights.sbomify.com/CVE-2021-43818/
Summaries are generated and may contain mistakes; the official description above is the record.
