CVE-2021-23980 Cross-site scripting in Bleach

Medium 6.1 Published Updated

Mutation XSS in Bleach allows code execution when specific non-default tags and settings are used for HTML sanitization.

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

What is CVE-2021-23980?

CVE-2021-23980 is a medium-severity cross-site scripting vulnerability in Mozilla Bleach, published on 16 Feb 2023. 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

A mutation XSS affects users calling bleach.clean with all of: svg or math in the allowed tags p or br in allowed tags style, title, noscript, script, textarea, noframes, iframe, or xmp in allowed tags the keyword argument strip_comments=False Note: none of the above tags are in the default allowed tags and strip_comments defaults to True.

Weakness: CWE-79

Which versions are affected by CVE-2021-23980?

3 open source packages ship an affected version, including bleach. It affects 1 product.

PackageAffectedFixed in
bleach PyPIAll versions3.3.0
bleach PyPIAll versions3.3.0
bleach PyPIAll versions3.3.0

Products include Mozilla Bleach.

How do I fix CVE-2021-23980?

Upgrade bleach to 3.3.0 or later.

Escape output for the context it lands in and set a strict Content Security Policy. Upgrading the affected component is the real fix. More about Cross-site scripting.

Is CVE-2021-23980 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2021-23980 exists.

Sources

Also known as DEBIAN-CVE-2021-23980, DLA-2620-1, DSA-4892-1, GHSA-vv2x-vrpj-qqpq, MGASA-2021-0260, OESA-2022-1861 and 2 more.

Is CVE-2021-23980 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free