sivann / itdb

IT Items Database
http://www.sivann.gr/software/itdb/
GNU General Public License v3.0
153 stars 104 forks source link

SQL Injection #59

Closed MoD01 closed 7 years ago

MoD01 commented 7 years ago

in your inventory management tool, it is possible to do SQL injection(s).

How to reproduce:

➡️ This will delete all items stored in the database!

What is the problem:

How to patch this vulnerability:

Replace lines 24-25 (https://github.com/sivann/itdb/blob/master/php/edititem.php#L24) with this:

$sql=$mysqli->prepare("DELETE from item2file where itemid=?"); // ? := placeholder for variable content
$sql->bind_param('i', $delid); // i := corresponding variable has type integer
$sql->execute(); // execute prepared statement
$sql->close(); // close statement and connection

And use mysqli for the db connections instead, e.g.: $mysqli = new mysqli('localhost', 'my_user', 'my_password', 'world'); Here you can find more information/examples : http://php.net/manual/en/mysqli-stmt.bind-param.php

How to fix the problem in general:

Vulnerability found by:

sivann commented 7 years ago

Hi, thanks for your analytical report; I know ITDB is not secure, it is aimed for intranets mostly. It was written on a few afternoons a very long time ago, before adding to github. I will add a security warning immediately on the frontpage as I have failed to do so. As stated in the "Welcomed pull requests" It needs a complete rewrite with PDO and prepared statements and a framework. I will not commit those changes as it's a drop in the ocean of security issues. Thank you for your understanding.