Skip to content

Commit

Permalink
Add TaintedCallable sinks for 4 core generic functions
Browse files Browse the repository at this point in the history
  • Loading branch information
cgocast committed Sep 6, 2024
1 parent 7c53c9d commit cf148ac
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
20 changes: 20 additions & 0 deletions stubs/CoreGenericFunctions.phpstub
Original file line number Diff line number Diff line change
Expand Up @@ -1803,3 +1803,23 @@ function exec(string $command, &$output = null, int &$result_code = null): strin
* @psalm-ignore-falsable-return
*/
function get_browser(?string $user_agent = null, bool $return_array = false): object|array|false {}

/**
* @psalm-taint-sink callable $callback
*/
function forward_static_call(callable $callback, mixed ...$args): mixed {}

/**
* @psalm-taint-sink callable $callback
*/
function forward_static_call_array(callable $callback, array $args): mixed {}

/**
* @psalm-taint-sink callable $callback
*/
function register_shutdown_function(callable $callback, mixed ...$args): void {}

/**
* @psalm-taint-sink callable $callback
*/
function register_tick_function(callable $callback, mixed ...$args): bool {}
36 changes: 36 additions & 0 deletions tests/TaintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2527,6 +2527,42 @@ public static function getPrevious(string $s): string {
$result = $mysqli->execute_query($query);',
'error_message' => 'TaintedSql',
],
'taintedRegisterShutdownFunction' => [
'code' => '<?php
$foo = $_GET["foo"];
register_shutdown_function($foo);',
'error_message' => 'TaintedCallable',
],
'taintedRegisterTickFunction' => [
'code' => '<?php
$foo = $_GET["foo"];
register_tick_function($foo);',
'error_message' => 'TaintedCallable',
],
'taintedForwardStaticCall' => [
'code' => '<?php
$foo = $_GET["foo"];
class B
{
public static function test($foo) {
forward_static_call($foo, "one", "two");
}
}
B::test($foo);',
'error_message' => 'TaintedCallable',
],
'taintedForwardStaticCallArray' => [
'code' => '<?php
$foo = $_GET["foo"];
class B
{
public static function test($foo) {
forward_static_call_array($foo, array("one", "two"));
}
}
B::test($foo);',
'error_message' => 'TaintedCallable',
],
];
}

Expand Down

0 comments on commit cf148ac

Please sign in to comment.