In recent times, a vulnerability classified as CVE-2021-38733 has grabbed the attention of security researchers and developers using SEMCMS SHOP v1.1, a widely used e-commerce platform. This vulnerability, an SQL injection, allows malicious attackers to exploit the 'Ant_BlogCat.php' file, which could lead to severe consequences. In this long-read post, we will delve into the details of this vulnerability, its implications, and potential steps to mitigate its effects. We will also provide necessary code snippets, links to original references, and exposition about the exploit.

Understanding the Vulnerability

The CVE-2021-38733 vulnerability specifically targets SEMCMS SHOP v1.1, a web application written in PHP language, which powers many online shops. This application is susceptible to SQL injection via the 'Ant_BlogCat.php' file, which can be abused by attackers to execute arbitrary SQL commands on the targeted web server. Consequently, they may exfiltrate sensitive data, manipulate records, or gain unauthorized access to the entire system.

SQL injection (SQLi) is a widely known and prevalent attack technique where a perpetrator injects malicious SQL code into an input field, resulting in the execution of unauthorized and potentially harmful SQL operations.

Code Snippet

In the SEMCMS SHOP v1.1, the 'Ant_BlogCat.php' file is responsible for managing categories of the blog section. A part of the vulnerable code from 'Ant_BlogCat.php' reads as follows:

$cid = empty($_GET['cid']) ? '' : $_GET['cid'];
$sql = "SELECT * FROM ".$qianzui."blogcat WHERE 1=1 AND id=$cid";
$result = mysql_query($sql);

Here, the $cid variable captures user input directly from the $_GET variable without any filtering or proper sanitization. Consequently, the unfiltered input reaches the SQL query in the $sql variable, which is then executed with the mysql_query function. The lack of input validation and sanitization introduces the SQL injection vulnerability.

Exploit Details

To demonstrate the extent of the vulnerability, consider the following URL for an online store powered by SEMCMS SHOP v1.1:[payload]

An attacker can exploit the SQL injection vulnerability by simply appending a malicious SQL payload to the cid parameter, such as:,2,version(),4,5--

The payload, 1%20UNION%20SELECT%201,2,version(),4,5--, combines a valid category ID and the UNION keyword to execute an SQL query that discloses the backend MySQL server version. The %20 character in the URL acts as a white space.

1. CVE-2021-38733 Official Listing
2. National Vulnerability Database (NVD) Explanation


To protect your application against the CVE-2021-38733 vulnerability, we recommend taking the following measures:

1. Update your application to the latest version or patch: The software vendor may release updates or security patches that address this specific vulnerability, so it is crucial to update your software as soon as possible.
2. Input Validation and Sanitization: Implement proper input validation and sanitization techniques, such as employing prepared statements with parameterized queries and using built-in PHP functions like 'filter_input'.
3. Error Handling: Disable verbose error messages, as it will help to prevent attackers from gaining valuable information regarding your underlying system.


SQL injection vulnerabilities like CVE-2021-38733 pose a significant threat, but understanding their mechanics and adopting appropriate security practices can help you to reduce the risk and protect your applications. Stay vigilant and stay secure!


Published on: 10/28/2022 16:15:00 UTC
Last modified on: 10/28/2022 18:49:00 UTC