Średnia

Bleach clean() / Cleaner() fails to sanitize dangerous URI schemes in allowed formaction attributes

  • Ujawniono: 16.06.2026
  • Aktualizacja: 11.10.2026 15:17

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
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
(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
from bleach import clean

print(clean(
    '<form><button formaction="javascript:alert(1)">go</button></form>',
    tags={'form', 'button'},
    attributes={'button': ['formaction']},
))

Actual output:

html
<form><button formaction="javascript:alert(1)">go</button></form>

Expected output:

html
<form><button>go</button></form>

2) <input type="submit">

python
print(clean(
    '<form><input type="submit" formaction="javascript:alert(1)" value="go"></form>',
    tags={'form', 'input'},
    attributes={'input': ['type', 'formaction', 'value']},
))

Actual output:

html
<form><input type="submit" formaction="javascript:alert(1)" value="go"></form>

Expected output:

html
<form><input type="submit" value="go"></form>

3) <input type="image">

python
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
<form><input type="image" formaction="javascript:alert(1)" src="/foo.png"></form>

Expected output:

html
<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

Czego dotyczy

Kliknij technologię, aby zobaczyć wszystkie dotyczące jej podatności.

PlatformaPaczkaPodatne wersjePoprawka w wersji
Python (PyPI) bleach < 6.4.0 6.4.0

Odnośniki

Ocena CVSS 6.1/10
Wektor CVSS
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
Słabość (CWE)
CWE-79
Platforma
Python (PyPI)
Paczka
bleach
Ujawniono
16.06.2026
Aktualizacja
11.10.2026 15:17

Źródła i licencje

OSV / GitHub Advisory Database - GHSA-gj48-438w-jh9v - CC BY 4.0

Historia podatności: bleach

Wszystkie opisane podatności tej paczki (Python (PyPI)), od najnowszej. Widać, czy to jednorazowa wpadka, czy paczka, której trzeba pilnować.

Wszystkich wpisów
8
Pierwsza → ostatnia
03.2018 06.2026
Bez poprawki
1
Wykorzystywana w atakach
0

Rozkład istotności

  • Krytyczna 1
  • Wysoka 1
  • Średnia 5
  • Niska 1

Ujawnienia w latach

  1. 2018: 1
  2. 2019: 0
  3. 2020: 3
  4. 2021: 1
  5. 2022: 0
  6. 2023: 0
  7. 2024: 0
  8. 2025: 0
  9. 2026: 3
  1. Bleach clean() / Cleaner() fails to sanitize dangerous URI schemes in allowed formaction attributes ten wpis
    Średnia · 6.1 ghsa-gj48-438w-jh9v < 6.4.0 6.4.0
  2. Średnia · 4.3 ghsa-g75f-g53v-794x = 6.3.0 brak poprawki
  3. Średnia · 6.1 CVE-2021-23980 < 3.3.0 3.3.0
  4. Wysoka · 7.5 CVE-2020-6817 < 3.1.4 3.1.4
  5. Średnia · 6.1 CVE-2020-6802 < 3.1.1 3.1.1
  6. Krytyczna · 9.8 CVE-2018-7753 >= 2.1.0, < 2.1.3 2.1.3

Dowiedz się, które podatności dotyczą Twojej aplikacji

Po podłączeniu integracji DockRay i włączeniu raportowania oprogramowania DockRay porównuje zgłoszone wersje komponentów ze znanymi podatnościami i powiadamia o potwierdzonych dopasowaniach. Zakres zależy od obsługiwanej technologii i dostępnych biuletynów.

Podłącz swoją aplikację
Newsletter DockRay

Bezpieczeństwo aplikacji w Twojej skrzynce

Najważniejsze podatności, konkretne zalecenia i praktyczne wskazówki dla Twoich aplikacji. Wybierz technologie i śledź to, co ma znaczenie dla Twojego projektu.

  • Codzienne zestawienie nowych podatności, także krytycznych.
  • Powiadomienia o ważnych aktualizacjach.
  • Praktyczne porady o bezpieczeństwie i monitoringu aplikacji.

Pozostaw puste, aby otrzymywać informacje o wszystkich technologiach.

Zapis jest bezpłatny. Wypiszesz się jednym kliknięciem w wiadomości.