This repository was archived by the owner on Jun 10, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,6 +28,12 @@ Version 6.4.0 (TBD)
2828
2929 See the advisory for details.
3030
31+ * Fix GHSA-gj48-438w-jh9v.
32+
33+ Fix issue where URI sanitization wasn't happening in formaction attributes.
34+
35+ See the advisory for details.
36+
3137**Bug fixes**
3238
3339* Add support for pypy 3.11. (#764)
Original file line number Diff line number Diff line change 1+ diff --git bleach/_vendor/html5lib/filters/sanitizer.py b/bleach/_vendor/html5lib/filters/sanitizer.py
2+ index a37c9d8..dd5a6a6 100644
3+ --- bleach/_vendor/html5lib/filters/sanitizer.py
4+ +++ bleach/_vendor/html5lib/filters/sanitizer.py
5+ @@ -534,6 +534,7 @@ attr_val_is_uri = frozenset((
6+ (None, 'dynsrc'),
7+ (None, 'lowsrc'),
8+ (None, 'ping'),
9+ + (None, 'formaction'),
10+ (namespaces['xlink'], 'href'),
11+ (namespaces['xml'], 'base'),
12+ ))
Original file line number Diff line number Diff line change 534534 (None , 'dynsrc' ),
535535 (None , 'lowsrc' ),
536536 (None , 'ping' ),
537+ (None , 'formaction' ),
537538 (namespaces ['xlink' ], 'href' ),
538539 (namespaces ['xml' ], 'base' ),
539540))
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ pip install --no-binary all --no-compile --no-deps -r "${BLEACH_VENDOR_DIR}/vend
1313# Apply patches
1414(cd " ${DEST} " && patch -p2 < 01_html5lib_six.patch)
1515(cd " ${DEST} " && patch -p2 < 02_html5lib_wbr.patch)
16+ (cd " ${DEST} " && patch -p2 < 03_html5lib_formaction.patch)
1617
1718# install Python 3.6.14 urllib.urlparse for #536
1819curl --proto ' =https' --tlsv1.2 -o " ${DEST} /parse.py" https://raw.githubusercontent.com/python/cpython/v3.6.14/Lib/urllib/parse.py
Original file line number Diff line number Diff line change @@ -427,6 +427,21 @@ def test_poster_attribute():
427427 assert clean (ok , tags = tags , attributes = attrs ) == ok
428428
429429
430+ def test_formaction_attribute ():
431+ """formaction attributes should not allow javascript (GHSA-gj48-438w-jh9v)."""
432+ tags = {"button" , "input" }
433+ attrs = {"button" : ["formaction" ], "input" : ["formaction" , "type" ]}
434+
435+ test = '<button formaction="javascript:alert(1)">x</button>'
436+ assert clean (test , tags = tags , attributes = attrs ) == "<button>x</button>"
437+
438+ test = '<input type="submit" formaction="javascript:alert(1)">'
439+ assert clean (test , tags = tags , attributes = attrs ) == '<input type="submit">'
440+
441+ ok = '<button formaction="/foo">x</button>'
442+ assert clean (ok , tags = tags , attributes = attrs ) == ok
443+
444+
430445def test_attributes_callable ():
431446 """Verify attributes can take a callable"""
432447
You can’t perform that action at this time.
0 commit comments