GHSA-gj48-438w-jh9v: Bleach Bleach Clean() / Cleaner() Fails Vulnerability

MODERATE
CVSS 6.1
CWE-79
Published
Advisory Summary

GHSA-gj48-438w-jh9v is a MODERATE (CVSS 6.1) bleach clean() / cleaner() fails vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting Bleach libraries in the PyPI ecosystem. The issue involves bleach clean() / cleaner() fails to sanitize dangerous uri schemes in allowed formaction attributes. Remediation is available by upgrading affected packages to version 6.4.0.

GHSA-gj48-438w-jh9v at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-gj48-438w-jh9v
Severity MODERATE
CVSS v3.1 Base Score 6.1
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product Bleach
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 6.1

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability None (A:N)

How to Fix GHSA-gj48-438w-jh9v

To remediate this vulnerability, upgrade all affected Bleach dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

bleach fixed: 6.4.0
pip install bleach>=6.4.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show bleach

How to Check if You Are Affected

To determine whether your Python environment is affected by GHSA-gj48-438w-jh9v, inspect your installed packages using pip:

pip show bleach

Analyze the terminal output to locate any version of Bleach in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 6.4.0), your application is affected.

Note: The pip show bleach 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 Bleach, 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

### Summary Bleach `clean()` / `Cleaner()` fails to sanitize dangerous URI schemes in allowed `formaction` attributes. Bleach applies URI protocol sanitization only to attributes listed in `attr_val_is_uri`. While URI-bearing attributes such as `action`, `href`, `src`, and `poster` are included in that set, `formaction` is not. As a result, if a downstream application explicitly allows `formaction` on submit-capable controls in untrusted HTML, Bleach preserves dangerous values such as `javascript:alert(1)` instead of stripping them. This can lead to **submit-triggered JavaScript execution** in applications that rely on Bleach to sanitize untrusted HTML and allow the relevant tag/attribute combination. --- ### Details The issue appears to be a URI-sanitization coverage gap in Bleach’s sanitizer logic. Relevant code paths: * `bleach/sanitizer.py` — `BleachSanitizerFilter.allow_token` (around line 553) * `bleach/_vendor/html5lib/filters/sanitizer.py` — `attr_val_is_uri` (around line 525) In `BleachSanitizerFilter.allow_token`, URI protocol sanitization is only applied when: ```python id="pft79m" if namespaced_name in self.attr_val_is_uri: ``` However, `(None, 'formaction')` is currently missing from `attr_val_is_uri`. This creates an inconsistency where `action` is protocol-sanitized, but `formaction` is not. As a result, if a downstream application allows: * tags such as `<button>` or `<input>` * the `formaction` attribute then Bleach preserves dangerous URI schemes such as `javascript:` in `formaction`. Examples of affected submit-capable controls include: * `<button>` (default submit behavior unless `type="button"` is set) * `<input type="submit">` * `<input type="image">` This appears to be a real library-side sanitizer gap rather than only an application misuse issue, because Bleach already treats similar URI-bearing attributes (such as `action`) as protocol-sensitive and sanitizes them. Suggested minimal fix: Add: ```python id="4v4fkn" (None, 'formaction') ``` to `attr_val_is_uri` in: * `bleach/_vendor/html5lib/filters/sanitizer.py` I also prepared a minimal patch and focused regression tests if helpful. --- ### PoC Below are minimal reproductions using `bleach.clean()`. #### 1) `<button>` ```python id="d3g0v7" from bleach import clean print(clean( '<form><button formaction="javascript:alert(1)">go</button></form>', tags={'form', 'button'}, attributes={'button': ['formaction']}, )) ``` **Actual output:** ```html id="i4nd7s" <form><button formaction="javascript:alert(1)">go</button></form> ``` **Expected output:** ```html id="g4d2r1" <form><button>go</button></form> ``` --- #### 2) `<input type="submit">` ```python id="l4dy0j" print(clean( '<form><input type="submit" formaction="javascript:alert(1)" value="go"></form>', tags={'form', 'input'}, attributes={'input': ['type', 'formaction', 'value']}, )) ``` **Actual output:** ```html id="h8lgbt" <form><input type="submit" formaction="javascript:alert(1)" value="go"></form> ``` **Expected output:** ```html id="6y8mws" <form><input type="submit" value="go"></form> ``` --- #### 3) `<input type="image">` ```python id="g8q0x8" print(clean( '<form><input type="image" formaction="javascript:alert(1)" src="/foo.png"></form>', tags={'form', 'input'}, attributes={'input': ['type', 'formaction', 'src']}, )) ``` **Actual output:** ```html id="fd22kg" <form><input type="image" formaction="javascript:alert(1)" src="/foo.png"></form> ``` **Expected output:** ```html id="z6t6je" <form><input type="image" src="/foo.png"></form> ``` --- ### Impact This is a **client-side HTML sanitization bypass / dangerous URI preservation issue**. If an application relies on Bleach to sanitize untrusted HTML and explicitly allows: * `formaction` * and submit-capable controls such as `<button>` or `<input>` then Bleach can emit sanitized output that still contains a dangerous `javascript:` URI in `formaction`. That can lead to **submit-triggered JavaScript execution** when the user activates the control. Impact is limited to configurations that explicitly allow the relevant tag/attribute combination, but the issue is still security-relevant because: * `formaction` is a real browser sink * Bleach already protocol-sanitizes similar URI-bearing attributes like `action` * the omission creates inconsistent sanitizer coverage for dangerous URI schemes I would currently assess this as **Medium severity**. If useful, I also have: * a minimal patch * focused regression tests for: * `<button formaction="javascript:...">` * `<input type="submit" formaction="javascript:...">` * `<input type="image" formaction="javascript:...">` * a safe control case where `formaction="/submit"` is preserved

GHSA-gj48-438w-jh9v Affected Bleach Versions

1 component(s)
Fixed Versions:
6.4.0
Product / Package Ecosystem Affected Versions Fixed Version
bleach
PyPI
< 6.4.0
6.4.0

References

Frequently Asked Questions

What is GHSA-gj48-438w-jh9v?
GHSA-gj48-438w-jh9v is a security vulnerability in Bleach involving Bleach clean() / Cleaner() fails to sanitize dangerous URI schemes in allowed formaction attributes under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which Bleach versions are affected?
Affected versions include releases prior to 6.4.0 across affected packages: bleach.
What version fixes GHSA-gj48-438w-jh9v?
Upgrading to 6.4.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is bleach affected?
Yes, bleach is affected in releases prior to 6.4.0. Upgrade your dependency to 6.4.0 or later.
What is the CVSS score of GHSA-gj48-438w-jh9v?
GHSA-gj48-438w-jh9v has a CVSS v3.1 base score of 6.1 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N.
What CWE is associated with GHSA-gj48-438w-jh9v?
GHSA-gj48-438w-jh9v is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (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.).
How can I check PyPI dependencies for GHSA-gj48-438w-jh9v?
Run the dependency tree command: 'pip show bleach'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-gj48-438w-jh9v",
  "modified" : "2026-06-16T14:07:49Z",
  "published" : "2026-06-16T14:07:49Z",
  "aliases" : [ ],
  "summary" : "Bleach clean() / Cleaner() fails to sanitize dangerous URI schemes in allowed formaction attributes",
  "details" : "### Summary\n\nBleach `clean()` / `Cleaner()` fails to sanitize dangerous URI schemes in allowed `formaction` attributes.\n\nBleach applies URI protocol sanitization only to attributes listed in `attr_val_is_uri`. While URI-bearing attributes such as `action`, `href`, `src`, and `poster` are included in that set, `formaction` is not. As a result, if a downstream application explicitly allows `formaction` on submit-capable controls in untrusted HTML, Bleach preserves dangerous values such as `javascript:alert(1)` instead of stripping them.\n\nThis can lead to **submit-triggered JavaScript execution** in applications that rely on Bleach to sanitize untrusted HTML and allow the relevant tag/attribute combination.\n\n---\n\n### Details\n\nThe issue appears to be a URI-sanitization coverage gap in Bleach’s sanitizer logic.\n\nRelevant code paths:\n\n* `bleach/sanitizer.py` — `BleachSanitizerFilter.allow_token` (around line 553)\n* `bleach/_vendor/html5lib/filters/sanitizer.py` — `attr_val_is_uri` (around line 525)\n\nIn `BleachSanitizerFilter.allow_token`, URI protocol sanitization is only applied when:\n\n```python id=\"pft79m\"\nif namespaced_name in self.attr_val_is_uri:\n```\n\nHowever, `(None, 'formaction')` is currently missing from `attr_val_is_uri`.\n\nThis creates an inconsistency where `action` is protocol-sanitized, but `formaction` is not.\n\nAs a result, if a downstream application allows:\n\n* tags such as `<button>` or `<input>`\n* the `formaction` attribute\n\nthen Bleach preserves dangerous URI schemes such as `javascript:` in `formaction`.\n\nExamples of affected submit-capable controls include:\n\n* `<button>` (default submit behavior unless `type=\"button\"` is set)\n* `<input type=\"submit\">`\n* `<input type=\"image\">`\n\nThis appears to be a real library-side sanitizer gap rather than only an application misuse issue, because Bleach already treats similar URI-bearing attributes (such as `action`) as protocol-sensitive and sanitizes them.\n\nSuggested minimal fix:\n\nAdd:\n\n```python id=\"4v4fkn\"\n(None, 'formaction')\n```\n\nto `attr_val_is_uri` in:\n\n* `bleach/_vendor/html5lib/filters/sanitizer.py`\n\nI also prepared a minimal patch and focused regression tests if helpful.\n\n---\n\n### PoC\n\nBelow are minimal reproductions using `bleach.clean()`.\n\n#### 1) `<button>`\n\n```python id=\"d3g0v7\"\nfrom bleach import clean\n\nprint(clean(\n    '<form><button formaction=\"javascript:alert(1)\">go</button></form>',\n    tags={'form', 'button'},\n    attributes={'button': ['formaction']},\n))\n```\n\n**Actual output:**\n\n```html id=\"i4nd7s\"\n<form><button formaction=\"javascript:alert(1)\">go</button></form>\n```\n\n**Expected output:**\n\n```html id=\"g4d2r1\"\n<form><button>go</button></form>\n```\n\n---\n\n#### 2) `<input type=\"submit\">`\n\n```python id=\"l4dy0j\"\nprint(clean(\n    '<form><input type=\"submit\" formaction=\"javascript:alert(1)\" value=\"go\"></form>',\n    tags={'form', 'input'},\n    attributes={'input': ['type', 'formaction', 'value']},\n))\n```\n\n**Actual output:**\n\n```html id=\"h8lgbt\"\n<form><input type=\"submit\" formaction=\"javascript:alert(1)\" value=\"go\"></form>\n```\n\n**Expected output:**\n\n```html id=\"6y8mws\"\n<form><input type=\"submit\" value=\"go\"></form>\n```\n\n---\n\n#### 3) `<input type=\"image\">`\n\n```python id=\"g8q0x8\"\nprint(clean(\n    '<form><input type=\"image\" formaction=\"javascript:alert(1)\" src=\"/foo.png\"></form>',\n    tags={'form', 'input'},\n    attributes={'input': ['type', 'formaction', 'src']},\n))\n```\n\n**Actual output:**\n\n```html id=\"fd22kg\"\n<form><input type=\"image\" formaction=\"javascript:alert(1)\" src=\"/foo.png\"></form>\n```\n\n**Expected output:**\n\n```html id=\"z6t6je\"\n<form><input type=\"image\" src=\"/foo.png\"></form>\n```\n\n---\n\n### Impact\n\nThis is a **client-side HTML sanitization bypass / dangerous URI preservation issue**.\n\nIf an application relies on Bleach to sanitize untrusted HTML and explicitly allows:\n\n* `formaction`\n* and submit-capable controls such as `<button>` or `<input>`\n\nthen Bleach can emit sanitized output that still contains a dangerous `javascript:` URI in `formaction`.\n\nThat can lead to **submit-triggered JavaScript execution** when the user activates the control.\n\nImpact is limited to configurations that explicitly allow the relevant tag/attribute combination, but the issue is still security-relevant because:\n\n* `formaction` is a real browser sink\n* Bleach already protocol-sanitizes similar URI-bearing attributes like `action`\n* the omission creates inconsistent sanitizer coverage for dangerous URI schemes\n\nI would currently assess this as **Medium severity**.\n\nIf useful, I also have:\n\n* a minimal patch\n* focused regression tests for:\n\n  * `<button formaction=\"javascript:...\">`\n  * `<input type=\"submit\" formaction=\"javascript:...\">`\n  * `<input type=\"image\" formaction=\"javascript:...\">`\n  * a safe control case where `formaction=\"/submit\"` is preserved",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "bleach"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "6.4.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/mozilla/bleach/security/advisories/GHSA-gj48-438w-jh9v"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/mozilla/bleach"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/mozilla/bleach/releases/tag/v6.4.0"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-06-16T14:07:49Z",
    "nvd_published_at" : null
  }
}