From 49e486ed2e429c14f1f21960a4a445a61bab6b1e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 9 Aug 2026 02:01:05 +0200 Subject: [PATCH] =?UTF-8?q?Fix:=20more=20complete=20blacklist=20in=20waf?= =?UTF-8?q?=20-=20reported=20by=20Pawe=C5=82=20Bednarz?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/waf.inc.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/htdocs/waf.inc.php b/htdocs/waf.inc.php index ba9230297c5..944ecb1e473 100644 --- a/htdocs/waf.inc.php +++ b/htdocs/waf.inc.php @@ -207,21 +207,24 @@ function testSqlAndScriptInject($val, $type) $inj += preg_match('/on(paste|pause|play|playing|progress|ratechange|reset|resize|scroll|select|search|seeked|seeking|show|stalled|start|submit|suspend)[a-z]*\s*=/i', $val); $inj += preg_match('/on(timeupdate|touch|transition|toggle|unload|volumechange|waiting|wheel)[a-z]*\s*=/i', $val); // More not into the previous list - $inj += preg_match('/on(repeat|begin|finish)[a-z]*\s*=/i', $val); + $inj += preg_match('/on(repeat|begin|finish|page|slot)[a-z]*\s*=/i', $val); + $inj += preg_match('/on(webkit|moz|ms|o)[a-z]*\s*=/i', $val); // We refuse html into html because some hacks try to obfuscate evil strings by inserting HTML into HTML. - // Example: error=alert(1) or =alert(1) to bypass test on onerror= + // Example:
click=alert(1) or =alert(1) to bypass test on onclick= + // What about cases like
>click=alert(1) ? Seems blocked by browsers $tmpval = preg_replace('/<[^<]*>/', '', $val); // List of dom events is on https://www.w3schools.com/jsref/dom_obj_event.asp and https://developer.mozilla.org/en-US/docs/Web/Events - $inj += preg_match('/on(mouse|drag|key|load|touch|pointer|select|transition)[a-z]*\s*=/i', $tmpval); // onmousexxx can be set on img or any html tag like - $inj += preg_match('/on(abort|after|animation|auxclick|before|blur|bounce|cancel|canplay|canplaythrough|change|click|close|contextmenu|cuechange|copy|cut)[a-z]*\s*=/i', $tmpval); - $inj += preg_match('/on(dblclick|drop|durationchange|emptied|end|ended|error|focus|focusin|focusout|formdata|gotpointercapture|hashchange|input|invalid)[a-z]*\s*=/i', $tmpval); - $inj += preg_match('/on(lostpointercapture|offline|online|pagehide|pageshow)[a-z]*\s*=/i', $tmpval); - $inj += preg_match('/on(paste|pause|play|playing|progress|ratechange|reset|resize|scroll|search|seeked|seeking|show|stalled|start|submit|suspend)[a-z]*\s*=/i', $tmpval); - $inj += preg_match('/on(timeupdate|toggle|unload|volumechange|waiting|wheel)[a-z]*\s*=/i', $tmpval); + $inj += preg_match('/on(abort|after|animation|auxclick|before|blur|bounce|cancel|canplay|canplaythrough|change|click|close|content|contextmenu|cuechange|copy|cut)[a-z]*\s*=/i', $tmpval); + $inj += preg_match('/on(dblclick|drag|drop|durationchange|emptied|end|ended|error|focus|focusin|focusout|formdata|gotpointercapture|hashchange|input|invalid)[a-z]*\s*=/i', $tmpval); + $inj += preg_match('/on(key|load|lostpointercapture|mouse)[a-z]*\s*=/i', $tmpval); // onmousexxx can be set on img or any html tag like + $inj += preg_match('/on(offline|online|pagehide|pageshow|pointer)[a-z]*\s*=/i', $tmpval); + $inj += preg_match('/on(paste|pause|play|playing|progress|ratechange|reset|resize|scroll|select|search|seeked|seeking|show|stalled|start|submit|suspend)[a-z]*\s*=/i', $tmpval); + $inj += preg_match('/on(timeupdate|touch|transition|toggle|unload|volumechange|waiting|wheel)[a-z]*\s*=/i', $tmpval); // More not into the previous list - $inj += preg_match('/on(repeat|begin|finish)[a-z]*\s*=/i', $tmpval); + $inj += preg_match('/on(repeat|begin|finish|page|slot)[a-z]*\s*=/i', $tmpval); + $inj += preg_match('/on(webkit|moz|ms|o)[a-z]*\s*=/i', $tmpval); //$inj += preg_match('/on[A-Z][a-z]+\*=/', $val); // To lock event handlers onAbort(), ... $inj += preg_match('/:|:|:/i', $val); // refused string ':' encoded (no reason to have it encoded) to lock 'javascript:...'