{"id":"CVE-2021-23980","aliases":["CVE-2021-23980","GHSA-vv2x-vrpj-qqpq","PYSEC-2021-865"],"related":[],"kind":"vulnerability","state":"published","title":"Cross-site scripting in Bleach","summary":"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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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.","source":"cvelist"},{"lang":"en","text":"### Impact                                                                                                                                                                                                                                                    \n\nA [mutation XSS](https://cure53.de/fp170.pdf) affects users calling `bleach.clean` with all of:\n\n* `svg` or `math` in the allowed tags\n* `p` or `br` in allowed tags\n* `style`, `title`, `noscript`, `script`, `textarea`, `noframes`, `iframe`, or `xmp` in allowed tags\n* the keyword argument `strip_comments=False`\n\nNote: none of the above tags are in the default allowed tags and `strip_comments` defaults to `True`.\n\n### Patches\n\nUsers are encouraged to upgrade to bleach v3.3.0 or greater.\n\nNote: bleach v3.3.0 introduces a breaking change to escape HTML comments by default.\n\n### Workarounds\n\n* modify `bleach.clean` calls to at least one of:\n  * not allow the `style`, `title`, `noscript`, `script`, `textarea`, `noframes`, `iframe`, or `xmp` tag\n  * not allow `svg` or `math` tags\n  * not allow `p` or `br` tags\n  * set `strip_comments=True`\n\n* A strong [Content-Security-Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) without `unsafe-inline` and `unsafe-eval` [`script-src`s](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src)) will also help mitigate the risk.\n\n### References\n\n* https://bugzilla.mozilla.org/show_bug.cgi?id=1689399\n* https://advisory.checkmarx.net/advisory/CX-2021-4303\n* https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-23980\n* https://cure53.de/fp170.pdf\n\n### Credits\n\n* Reported by [Yaniv Nizry](https://twitter.com/ynizry) from the CxSCA AppSec group at Checkmarx\n* Additional eject tags not mentioned in the original advisory and the CSP mitigation line being truncated in the revised advisory reported by [Michał Bentkowski](https://twitter.com/SecurityMB) at Securitum\n\n### For more information\n\nIf you have any questions or comments about this advisory:\n\n* Open an issue at [https://github.com/mozilla/bleach/issues](https://github.com/mozilla/bleach/issues)\n* Email us at [security@mozilla.org](mailto:security@mozilla.org)","format":"markdown","source":"ghsa"},{"lang":"es","text":"Una mutación XSS afecta a los usuarios que llaman a bleach.clean con todo: svg o math en las etiquetas permitidas p o br en las etiquetas permitidas estilo, título, noscript, script, textarea, noframes, iframe o xmp en las etiquetas permitidas el argumento de palabra clave strip_comments= Falso Nota: ninguna de las etiquetas anteriores está en las etiquetas permitidas predeterminadas y strip_comments tiene el valor predeterminado Verdadero.","source":"nvd"},{"lang":"en","text":"In Mozilla Bleach before 3.3.0, a mutation XSS affects users calling bleach.clean with math or svg; p or br; and style, title, noscript, script, textarea, noframes, iframe, or xmp tags with strip_comments=False.","format":"markdown","source":"pysec"}],"published":"2021-02-02T17:58:00.000Z","modified":"2026-07-08T06:27:25.981Z","severity":{"scorer":"CISA-ADP","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","score":6.1,"rating":"MEDIUM"},"severities":[{"scorer":"CISA-ADP","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","score":6.1,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","score":6.1,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N","rating":"MEDIUM"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","score":6.1,"rating":"MEDIUM"}],"cwes":["CWE-79"],"affected":[{"ranges":[{"type":"custom","introduced":"unspecified","fixed":"3.3.0","status":"affected"}],"vendor":"Mozilla","product":"Mozilla Bleach","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"3.3.0"}],"ecosystem":"PyPI","package":"bleach","purl":"pkg:pypi/bleach","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"3.3.0"}],"vendor":"mozilla","product":"bleach","cpe":"cpe:2.3:a:mozilla:bleach:*:*:*:*:*:*:*:*","source":"nvd"},{"ranges":[{"type":"git","introduced":"0","status":"affected","fixed":"79b7a3c5e56a09d1d323a5006afa59b56162eb13"},{"type":"ecosystem","introduced":"0","status":"affected","fixed":"3.3.0"}],"ecosystem":"PyPI","package":"bleach","purl":"pkg:pypi/bleach","repo":"https://github.com/mozilla/bleach","source":"pysec"}],"references":[{"url":"https://github.com/mozilla/bleach/security/advisories/GHSA-vv2x-vrpj-qqpq","tags":["advisory","vendor-advisory","web","x-transferred"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://bugzilla.mozilla.org/show_bug.cgi?id=CVE-2021-23980","tags":["exploit","issue-tracking","web","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2021-23980","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/mozilla/bleach/commit/79b7a3c5e56a09d1d323a5006afa59b56162eb13","tags":["fix","web"],"sources":["ghsa","pysec"]},{"url":"https://advisory.checkmarx.net/advisory/CX-2021-4303","tags":["advisory","web"],"sources":["ghsa","pysec"]},{"url":"https://bugzilla.mozilla.org/show_bug.cgi?id=1689399","tags":["web"],"sources":["ghsa"]},{"url":"https://cure53.de/fp170.pdf","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/mozilla/bleach","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/mozilla/bleach/blob/79b7a3c5e56a09d1d323a5006afa59b56162eb13/CHANGES#L4","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/pypa/advisory-database/tree/main/vulns/bleach/PYSEC-2021-865.yaml","tags":["web"],"sources":["ghsa"]},{"url":"https://pypi.org/project/bleach","tags":["web"],"sources":["ghsa"]}],"credits":[],"assigner":"mozilla","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2025-03-19T15:18:14.680Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2021-23980","url":"https://www.cve.org/CVERecord?id=CVE-2021-23980","licence":"CVE Terms of Use","modified":"2025-03-19T15:18:23.189Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-vv2x-vrpj-qqpq","url":"https://github.com/advisories/GHSA-vv2x-vrpj-qqpq","licence":"CC-BY-4.0","modified":"2026-07-08T06:27:25.981Z"},{"source":"nvd","name":"NVD","id":"CVE-2021-23980","url":"https://nvd.nist.gov/vuln/detail/CVE-2021-23980","licence":"Public domain","modified":"2026-06-17T03:39:06.300Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2021-865","url":"https://osv.dev/vulnerability/PYSEC-2021-865","licence":"CC-BY-4.0","modified":"2023-11-08T04:05:14.166Z"}],"updatedAt":"2026-11-25T22:58:08.212Z","epss":{"score":0.00488,"percentile":0.43604,"date":"2026-12-02T12:00:21.000Z"}}