Description
The 'bookisbn' parameter of the cart.php resource does not validate the characters received and they are sent unfiltered to the database. The relevant vulnerable code is:
cart.php:
if(isset($_SESSION['cart']) && (array_count_values($_SESSION['cart']))){
$_SESSION['total_price'] = total_price($_SESSION['cart']);
$_SESSION['total_items'] = total_items($_SESSION['cart']);if(isset($_SESSION['cart']) && (array_count_values($_SESSION['cart']))){
$_SESSION['total_price'] = total_price($_SESSION['cart']);
$_SESSION['total_items'] = total_items($_SESSION['cart']);if(isset($_SESSION['cart']) && (array_count_values($_SESSION['cart']))){
$_SESSION['total_price'] = total_price($_SESSION['cart']);
$_SESSION['total_items'] = total_items($_SESSION['cart']);if(isset($_SESSION['cart']) && (array_count_values($_SESSION['cart']))){
$_SESSION['total_price'] = total_price($_SESSION['cart']);
$_SESSION['total_items'] = total_items($_SESSION['cart']);cart_functions.php:
function total_price($cart){
$price = 0.0;
if(is_array($cart)){
foreach($cart as $isbn => $qty){
$bookprice = getbookprice($isbn);
if($bookprice){
$price += $bookprice * $qty;
}
}
}
return $price;
}function total_price($cart){
$price = 0.0;
if(is_array($cart)){
foreach($cart as $isbn => $qty){
$bookprice = getbookprice($isbn);
if($bookprice){
$price += $bookprice * $qty;
}
}
}
return $price;
}function total_price($cart){
$price = 0.0;
if(is_array($cart)){
foreach($cart as $isbn => $qty){
$bookprice = getbookprice($isbn);
if($bookprice){
$price += $bookprice * $qty;
}
}
}
return $price;
}function total_price($cart){
$price = 0.0;
if(is_array($cart)){
foreach($cart as $isbn => $qty){
$bookprice = getbookprice($isbn);
if($bookprice){
$price += $bookprice * $qty;
}
}
}
return $price;
}database_functions.php:
function getbookprice($isbn){
$conn = db_connect();
$query = "SELECT book_price FROM books WHERE book_isbn = '$isbn'";
$result = mysqli_query($conn, $query);
if(!$result){
echo "get book price failed! " . mysqli_error($conn);
exit;
}
$row = mysqli_fetch_assoc($result);
return $row['book_price'];
}function getbookprice($isbn){
$conn = db_connect();
$query = "SELECT book_price FROM books WHERE book_isbn = '$isbn'";
$result = mysqli_query($conn, $query);
if(!$result){
echo "get book price failed! " . mysqli_error($conn);
exit;
}
$row = mysqli_fetch_assoc($result);
return $row['book_price'];
}function getbookprice($isbn){
$conn = db_connect();
$query = "SELECT book_price FROM books WHERE book_isbn = '$isbn'";
$result = mysqli_query($conn, $query);
if(!$result){
echo "get book price failed! " . mysqli_error($conn);
exit;
}
$row = mysqli_fetch_assoc($result);
return $row['book_price'];
}function getbookprice($isbn){
$conn = db_connect();
$query = "SELECT book_price FROM books WHERE book_isbn = '$isbn'";
$result = mysqli_query($conn, $query);
if(!$result){
echo "get book price failed! " . mysqli_error($conn);
exit;
}
$row = mysqli_fetch_assoc($result);
return $row['book_price'];
}Our security policy
We have reserved the ID CVE-2023-43739 to refer to this issue from now on. Disclosure policy
System Information
Version: Online Book Store Project v1.0
Operating System: Any
Mitigation
There is currently no patch available for this vulnerability.
References