Skip to content

Commit 9ebbf5b

Browse files
authored
Merge branch '20.0' into fix_20_sql_order_twice
2 parents 8150cc6 + 909fa44 commit 9ebbf5b

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

htdocs/main.inc.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,27 +214,27 @@ static function ($m) {
214214

215215
// 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
216216
$inj += preg_match('/on(mouse|drag|key|load|touch|pointer|select|transition)[a-z]*\s*=/i', $val); // onmousexxx can be set on img or any html tag like <img title='...' onmouseover=alert(1)>
217-
$inj += preg_match('/on(abort|after|animation|auxclick|before|blur|cancel|canplay|canplaythrough|change|click|close|contextmenu|cuechange|copy|cut)[a-z]*\s*=/i', $val);
217+
$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', $val);
218218
$inj += preg_match('/on(dblclick|drop|durationchange|emptied|end|ended|error|focus|focusin|focusout|formdata|gotpointercapture|hashchange|input|invalid)[a-z]*\s*=/i', $val);
219219
$inj += preg_match('/on(lostpointercapture|offline|online|pagehide|pageshow)[a-z]*\s*=/i', $val);
220220
$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', $val);
221221
$inj += preg_match('/on(timeupdate|toggle|unload|volumechange|waiting|wheel)[a-z]*\s*=/i', $val);
222222
// More not into the previous list
223-
$inj += preg_match('/on(repeat|begin|finish|beforeinput)[a-z]*\s*=/i', $val);
223+
$inj += preg_match('/on(repeat|begin|finish)[a-z]*\s*=/i', $val);
224224

225225
// We refuse html into html because some hacks try to obfuscate evil strings by inserting HTML into HTML.
226226
// Example: <img on<a>error=alert(1) or <img onerror<>=alert(1) to bypass test on onerror=
227227
$tmpval = preg_replace('/<[^<]*>/', '', $val);
228228

229229
// 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
230230
$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 <img title='...' onmouseover=alert(1)>
231-
$inj += preg_match('/on(abort|after|animation|auxclick|before|blur|cancel|canplay|canplaythrough|change|click|close|contextmenu|cuechange|copy|cut)[a-z]*\s*=/i', $tmpval);
231+
$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);
232232
$inj += preg_match('/on(dblclick|drop|durationchange|emptied|end|ended|error|focus|focusin|focusout|formdata|gotpointercapture|hashchange|input|invalid)[a-z]*\s*=/i', $tmpval);
233233
$inj += preg_match('/on(lostpointercapture|offline|online|pagehide|pageshow)[a-z]*\s*=/i', $tmpval);
234234
$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);
235235
$inj += preg_match('/on(timeupdate|toggle|unload|volumechange|waiting|wheel)[a-z]*\s*=/i', $tmpval);
236236
// More not into the previous list
237-
$inj += preg_match('/on(repeat|begin|finish|beforeinput)[a-z]*\s*=/i', $tmpval);
237+
$inj += preg_match('/on(repeat|begin|finish)[a-z]*\s*=/i', $tmpval);
238238

239239
//$inj += preg_match('/on[A-Z][a-z]+\*=/', $val); // To lock event handlers onAbort(), ...
240240
$inj += preg_match('/&#58;|&#0000058|&#x3A/i', $val); // refused string ':' encoded (no reason to have it encoded) to lock 'javascript:...'

test/phpunit/SecurityTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,13 @@ public function testSqlAndScriptInjectWithPHPUnit()
201201
$result = testSqlAndScriptInject($test, 0);
202202
$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject bbb');
203203

204+
$test='<marquee onbeforeintput="alert(1)">';
205+
$result=testSqlAndScriptInject($test, 0);
206+
$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject onbeforeintput');
207+
$test='<marquee onbounce="alert(1)">';
208+
$result=testSqlAndScriptInject($test, 0);
209+
$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject onbounce');
210+
204211
$test = '<SCRIPT SRC=http://xss.rocks/xss.js></SCRIPT>';
205212
$result = testSqlAndScriptInject($test, 0);
206213
$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject ccc');
@@ -1094,6 +1101,7 @@ public function testDolEval()
10941101
$this->assertEquals('358080.38', $result);
10951102

10961103
global $leftmenu; // Used into strings to eval
1104+
$conf->global->MAIN_FEATURES_LEVEL = 1;
10971105

10981106
$leftmenu = 'AAA';
10991107
$result = dol_eval('$conf->currency && preg_match(\'/^(AAA|BBB)/\',$leftmenu)', 1, 1, '1');
@@ -1116,7 +1124,7 @@ public function testDolEval()
11161124
print "result16 = ".$result."\n";
11171125
$this->assertFalse($result);
11181126

1119-
$string = '(isModEnabled("agenda") || isModEnabled("resource")) && getDolGlobalInt("MAIN_FEATURES_LEVEL") >= 0 && preg_match(\'/^(admintools|all|XXX)/\', $leftmenu)';
1127+
$string = '(isModEnabled("user") || isModEnabled("resource")) && getDolGlobalInt("MAIN_FEATURES_LEVEL") >= 0 && preg_match(\'/^(admintools|all|XXX)/\', $leftmenu)';
11201128
$result = dol_eval($string, 1, 1, '1');
11211129
print "result17 = ".$result."\n";
11221130
$this->assertTrue($result);

0 commit comments

Comments
 (0)