SDCMS PHP EE v3.1 Front-End Search SQL Injection Vulnerability
Vulnerability type: SQL injection (time-based blind)
Affected version: SDCMS PHP EE 3.1
Entry point: /?m=search
Privileges required: Anonymous front-end access
Test environment: PHP 7.4.3, MySQL 5.7.26
Verification status: Reproduced locally; the vendor released a fixed version on 2026-11-08.
This document is intended for cybersecurity research and defensive purposes only. Do not use the techniques or code described here to attack any system without authorization. Because the vendor had already released a fix at the time of publication, any unauthorized exploitation, together with the resulting legal and associated liability, rests solely with the attacker and has no connection to the author.
1. Overview
The front-end search function in SDCMS PHP EE 3.1 is vulnerable to SQL injection. After some parameter processing, the user-supplied keyword is concatenated directly into a SQL query. An attacker can craft special input without logging in and infer the result of the SQL query from the response time.
2. Analysis
The flaw is located in the search() method of app/home/controller/other.php:
$where = "islock=1";
$where .= " and (";
$where .= " title like '%{$keyword}%' or intro like '%{$keyword}%' ";
$where .= ")";
$rs = $this->db->row(
"select id from sd_content $join where $where order by id desc limit 1"
);
$keyword is placed directly into the LIKE condition and then passed to the database as part of the SQL statement. No prepared statement is used here, and the search term is never supplied through parameter binding.
The front-end search follows a two-step "store first, retrieve later" flow, and the SQL query occurs in the second step.
-
POST stores the keyword. The search form submits via POST. The application first applies uniform escaping to all request parameters at the entry point, then F() extracts
keywordand passes it tofilter_html()andenhtml(). Insideenhtml(),urldecode()runs first, followed byhtmlspecialchars()for special-character escaping. The controller then callsurldecode()onkeyworda second time, writes the result to the session, and redirects to the search page with a 302. No database query occurs at any point during the POST request. -
GET executes the query. The browser follows the 302 with a GET request whose URL no longer carries
keyword. The application reads the previously stored keyword from the session, callsurldecode()once more, and concatenates the result into the search statement. The delay appears on this request; replaying the POST packet alone only returns a 302 response.
The root cause lies in the order of escaping and decoding. The server performs URL decoding three times: PHP form parsing, the urldecode() call inside enhtml(), and the urldecode() call in the controller. Both the entry-point escaping and htmlspecialchars() sit in the middle of that decoding chain, at which point the quote is still URL-encoded and reaches htmlspecialchars() as %27 — there is no quote character left to escape. Only the controller's final urldecode() restores %27 to a single quote, closing the string in the LIKE condition so that whatever follows becomes part of the SQL statement.
In this vulnerability the keyword is concatenated into three SQL statements: the controller's probe query, plus the template's count query and list query. An injected sleep() therefore executes multiple times, and the number of executions depends on how many rows in the table have islock=1. The more published content there is, the more rows the database has to examine, and the delay scales linearly with that count.
3. Verification
Prerequisites
The search statement includes islock=1 (the article is published), so the time-based blind test requires published content satisfying that condition in the sd_content table. A fresh installation contains no such records by default, and an administrator must add one content record manually.
Time-based blind injection
Submit the following payload in the front-end search box, or intercept the request and modify it in Burp Suite. A browser applies an additional layer of encoding when submitting a form, so the value entered in the search box is the double-encoded form:
%2527 and if(1=1,sleep(2),0)=0 ) limit 1 #
Alternatively, send the following request with Burp Suite: first extract the hidden token field from the search page form and fill it in, then reuse the same cookie to follow the 302 redirect and observe the response time of the resulting GET request.
POST /?m=search HTTP/1.1
Host: <Target>
Content-Type: application/x-www-form-urlencoded
Content-Length: 153
Cookie: PHPSESSID=<Your_SESSION_ID>
Connection: close
c=other&a=search&token=<Your_TOKEN>&keyword=%252527%252520and%252520if%2525281%25253D1%25252Csleep%2525282%252529%25252C0%252529%25253D0%252520%252529%252520limit%2525201%252520%252523
4. Impact
Privileges required: The injection is reachable by unauthenticated users; no account is required.
Affected version: SDCMS PHP EE 3.1 (fixed in version 3.2).
Affected component: Front-end search (/?m=search).
Exposed data layer: Sensitive database records, including sd_admin (administrator password hashes), sd_user (member information), and sd_config (payment and cloud storage configurations).
Escalation path: The direct consequence is disclosure of sensitive data. If the administrator uses a weak password, an attacker may recover the plaintext password through offline cracking and sign in to the admin panel. Because the CMS admin panel permits direct editing of template files with PHP code, the attacker can ultimately achieve remote code execution (RCE).
5. Remediation Recommendations
Use prepared statements and parameterized queries. Bind user-supplied values as query parameters to prevent SQL injection. Input filtering and blacklist-based mechanisms should not be considered primary defenses against SQL injection.
Standardize input decoding and processing. Clearly define the boundaries between HTTP parameter parsing and application-level input handling. Avoid repeatedly URL-decoding parameters that have already been parsed, as this can invalidate previous escaping operations.
6. Fix status
After receiving the report, the vendor released a new version on 2026-11-08 that fixes the issue. The fixed version was available for download at the time of publication.