forked from Wavyzz/dolibarr
18.0 fix CVE 2024 40137 (#34762)
* Sec: Remove all functions that accept callable params - CVE-2024-40137 * FIX #34746 - More complete fix for CVE-2024-40137 --------- Co-authored-by: ldestailleur <eldy@destailleur.fr>
This commit is contained in:
committed by
GitHub
parent
96a74c4976
commit
01aa901f93
@@ -730,7 +730,8 @@ class SecurityTest extends PHPUnit\Framework\TestCase
|
||||
{
|
||||
$stringtotest = 'eée';
|
||||
$decodedstring = dol_string_onlythesehtmlattributes($stringtotest);
|
||||
$this->assertEquals('eée', $decodedstring, 'Function did not sanitize correclty with test 1');
|
||||
//$this->assertEquals('eée', $decodedstring, 'Function did not sanitize correctly with test 1');
|
||||
$this->assertEquals('eée', $decodedstring, 'Function did not sanitize correctly with test 1');
|
||||
|
||||
$stringtotest = '<div onload="ee"><a href="123"><span class="abc">abc</span></a></div>';
|
||||
$decodedstring = dol_string_onlythesehtmlattributes($stringtotest);
|
||||
@@ -986,6 +987,22 @@ class SecurityTest extends PHPUnit\Framework\TestCase
|
||||
print "result = ".$result."\n";
|
||||
$this->assertStringContainsString('Bad string syntax to evaluate', $result);
|
||||
|
||||
$result = dol_eval('json_encode(array_map(implode("",["ex","ec"]), ["id"]))', 1, 1, '1'); // result of dol_eval may be an object Closure
|
||||
print "result4a = ".json_encode($result)."\n";
|
||||
$this->assertStringContainsString('Bad string syntax to evaluate', json_encode($result), 'The string was not detected as evil, it should due to the [ char and method "2"');
|
||||
|
||||
$result = dol_eval('json_encode(array_map(implode("",["ex","ec"]), ["id"]))', 1, 1, '2'); // result of dol_eval may be an object Closure
|
||||
print "result4b = ".json_encode($result)."\n";
|
||||
$this->assertStringContainsString('Bad string syntax to evaluate', json_encode($result), 'The string was not detected as evil, it should due to the use of array_map');
|
||||
|
||||
$result = dol_eval('json_encode(array_map(implode("",array("ex","ec"), array("id")))', 1, 1, '1'); // result of dol_eval may be an object Closure
|
||||
print "result4c = ".json_encode($result)."\n";
|
||||
$this->assertStringContainsString('Bad string syntax to evaluate', json_encode($result), 'The string was not detected as evil, it should due to the use of array_map');
|
||||
|
||||
$result = dol_eval('$a=function() { }; $a', 1, 1, '0'); // result of dol_eval may be an object Closure
|
||||
print "result5 = ".json_encode($result)."\n";
|
||||
$this->assertStringContainsString('Bad string syntax to evaluate', json_encode($result), 'The string was not detected as evil');
|
||||
|
||||
$result=dol_eval('$a=exec ("ls")', 1, 1);
|
||||
print "result = ".$result."\n";
|
||||
$this->assertStringContainsString('Bad string syntax to evaluate', $result);
|
||||
|
||||
Reference in New Issue
Block a user