CVE-2020-6802: XSS in Bleach when noscript and raw tag whitelisted

bleach Updated 02 Oct 2025

Summary

24/02/2020
Yes i
Moderate
6.1

CVE-2020-6802: XSS in Bleach when noscript and raw tag whitelisted. Affects bleach versions < 3.1.1. Fixed in 3.1.1. How to fix ↓

Also tracked for

The same CVE-2020-6802 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

Bleach is an open-source Python library that sanitizes and cleans HTML input to prevent cross-site scripting (XSS) attacks. It provides a set of functions to remove potentially dangerous tags and attributes from user-generated content. By doing so, Bleach helps protect web applications from malicious code injection.

Vulnerability Detail

This vulnerability, identified as CVE-2020-6802, is a mutation XSS (cross-site scripting) that affects users calling the bleach.clean function with noscript and a raw tag whitelisted. An attacker can exploit this vulnerability by injecting malicious code into the allowed tags, which will be executed when the sanitized HTML is rendered by the browser. The impact of this vulnerability can range from stealing sensitive user information to performing unauthorized actions on behalf of the user.

How To Fix

Latest published version: 6.4.0 as of 22 Oct 2026

pip install --upgrade "bleach==6.4.0"

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

3.1.1

This is the first release that contains the fix.

pip install --upgrade "bleach==3.1.1"

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

If updating the Bleach library is not immediately feasible, a temporary workaround is to modify the bleach.clean calls to exclude whitelisting of noscript and any of the following raw tags: title, textarea, script, style, noembed, noframes, iframe, xmp. By removing these tags from the allowed list, the risk of exploitation can be mitigated. Additionally, implementing a strong Content-Security-Policy (CSP) without unsafe-inline and unsafe-eval in the script-src directive can provide an extra layer of protection.

Conclusion

The vulnerability CVE-2020-6802 in Bleach exposes web applications to cross-site scripting attacks. It is crucial to update the Bleach library to version 3.1.1 or later to mitigate the risk. If immediate update is not possible, applying the mentioned workarounds and implementing a strong Content-Security-Policy can help protect against exploitation. For further support on vulnerability remediation, contact DevNack.com.

See every vulnerability recorded for bleach →

Share this vulnerability

FAQ

Bleach is a Python library used for sanitizing and cleaning HTML input to prevent cross-site scripting (XSS) attacks. It helps protect web applications from malicious code injection.

Mutation XSS is a type of cross-site scripting attack where the attacker injects malicious code into the allowed tags, which is then executed when the sanitized HTML is rendered by the browser.

An attacker can exploit this vulnerability by injecting malicious code into the allowed tags, such as noscript and raw tags, which will be executed when the sanitized HTML is rendered by the browser. This can lead to unauthorized actions or theft of sensitive user information.

To fix this vulnerability, update the Bleach library to version 3.1.1 or later. This update includes a patch that addresses the XSS vulnerability.

If updating the Bleach library is not immediately feasible, a temporary workaround is to modify the bleach.clean calls to exclude whitelisting of noscript and any of the following raw tags: title, textarea, script, style, noembed, noframes, iframe, xmp. Additionally, implementing a strong Content-Security-Policy (CSP) without unsafe-inline and unsafe-eval in the script-src directive can provide an extra layer of protection.

Related vulnerabilities

Recent vulnerabilities recorded for bleach.

How To Fix

Latest published version: 6.4.0 as of 22 Oct 2026

pip install --upgrade "bleach==6.4.0"

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

3.1.1

This is the first release that contains the fix.

pip install --upgrade "bleach==3.1.1"

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback