Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not detect sql injection in mysqli_query when $_POST content passed to a function #62

Closed
Jeremie-Kiwik opened this issue Jun 24, 2024 · 1 comment

Comments

@Jeremie-Kiwik
Copy link

I found a case where progpilot missed a sql injection

This works:

$link = mysqli_connect();
mysqli_query($mysqli, 'SELECT * FROM a WHERE id = '.$_POST['id']);

But when this query is called in a function, no:

function test_procedural($link, $id) {
    mysqli_query($link, 'SELECT * FROM table WHERE id = '.$id);
}
$link = mysqli_connect();
test_procedural($link, $_POST['id']); // should trigger, but no

The error occurs both in the procuderal and object way. So the behavior is the same here:

function test_object($mysqli, $id) {
    $mysqli->query('SELECT * FROM table WHERE id = '.$id);
}
$mysqli = new mysqli('host', 'user', 'password', 'database');
test_object($mysqli, $_POST['id']); // should trigger, but no
$mysqli->query('SELECT * FROM table WHERE id = '.$_POST['id']); // triggers

Here is how I launched the test:

$ php8.3 progpilot_v1.1.0.phar test1.php
[]

(just to precise: the result is the same with php8.2 and 8.1)

For me, the call inside the function should trigger a sql injection, as the variable in the signature is not casted. For example, this should be OK, as we are now sure that $id is an int:

function test_procedural(mysqli $link, int $id) {
    mysqli_query($link, 'SELECT * FROM table WHERE id = '.$id);
}
eric-therond added a commit that referenced this issue Jul 30, 2024
@eric-therond
Copy link
Collaborator

thank you so much for your feedback
it should be fixed now on master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants