In this post, we will delve into a SQL injection vulnerability found in Canteen Management System v1. that puts the integrity of the application and the underlying database at risk. The discovery of this vulnerability has earned it a spot in the Common Vulnerabilities and Exposures database under the identifier CVE-2022-43276.

Outlined below are the technical details of this vulnerability, including a sample code snippet illustrating the problematic SQL code, as well as links to both the original references and more information on the exploit.

Vulnerability Details

Canteen Management System v1. has been discovered to contain a SQL injection vulnerability in the productId parameter, found within the /php_action/fetchSelectedfood.php script. An attacker can exploit this vulnerability to inject malicious SQL code to alter, delete, or extract sensitive data from the database.

Code Snippet

The following code snippet demonstrates how the vulnerable SQL statement is constructed in the fetchSelectedfood.php script:

// fetchSelectedfood.php

// ...

$productId = $_POST['productId'];

// ...

$sql = "SELECT * FROM food_stocks WHERE food_id = $productId";

// Execute the SQL query
$result = $connect->query($sql);

// ...

In this code, the productId variable, coming directly from a user's POST request, is incorporated into the SQL query string without any form of filtering or sanitization. As a result, this code is susceptible to SQL injection.


The SQL injection vulnerability can be exploited by an attacker through sending a crafted POST request that contains malicious SQL code within the productId parameter. An example exploit is shown below:

POST /php_action/fetchSelectedfood.php HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Content-Length: 45


In this example, the attacker attempts to retrieve data from the users table in the database by exploiting the SQL injection. The productId parameter contains the malicious SQL injection payload: 5 OR 1=1 UNION SELECT * FROM users.

For more details on the SQL injection vulnerability, CWE-89, visit this link:


More information about Canteen Management System v1. can be found on the project's GitHub page:

Additional details on CVE-2022-43276 can be found in the National Vulnerability Database (NVD):

In conclusion, SQL injection vulnerabilities like the one found in Canteen Management System v1. highlight the importance of securely handling user input in web applications. Developers should stay vigilant in keeping their applications secure, always taking into account the principles of secure coding and input validation. In addition, security professionals and system administrators should perform regular security tests on web applications - such as penetration testing, static code analysis, and dynamic analysis - to ensure that all potential risks and vulnerabilities are quickly identified, documented, and addressed.


Published on: 10/28/2022 14:15:00 UTC
Last modified on: 10/28/2022 18:30:00 UTC