[CVE-2023-26861] Improper neutralization of several SQL parameters in vivawallet module for PrestaShop
The deprecated module “vivawallet” (name of the directory) edited by Viva Wallet prior to 1.7.9 for PrestaShop has several SQL injections.
Summary
- CVE ID: CVE-2023-26861
- Published at: 2023-07-11
- Advisory source: Friends-Of-Presta.org
- Vendor: PrestaShop
- Product: vivawallet
- Impacted release: < 1.7.9
- Product author: Viva Wallet
- Weakness: CWE-89
- Severity: critical (9.8)
Description
The deprecated PrestaShop module VivaWallet removed on github on Oct 19, 2022 has sensitive SQL calls that can be exploited to manage a blind SQL injection on front controller fail.php, success.php and webhook.php.
This exploit uses a PrestaShop front controller and most attackers can conceal the module controller’s path during the exploit so you will never know within your conventional frontend logs that it exploits this vulnerability. You will only see “POST /” inside your conventional frontend logs. Activating the AuditEngine of mod_security (or similar) is the only way to get data to confirm this exploit.
CVSS base metrics
- Attack vector: network
- Attack complexity: low
- Privilege required: none
- User interaction: none
- Scope: unchanged
- Confidentiality: high
- Integrity: high
- Availability: high
Vector string: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
Possible malicious usage
- Obtain admin access
- Remove data from the associated PrestaShop
- Copy/paste data from sensitive tables to FRONT to exposed tokens and unlock admins’ ajax scripts
- Rewrite SMTP settings to hijack emails
Patches
Advice: Remove vivawallet and install vivawalletsmartcheckout instead.
--- a/vivawallet/controllers/front/fail.php
+++ b/vivawallet/controllers/front/fail.php
@@ -9,7 +9,7 @@ class VivawalletFailModuleFrontController
if(isset($_GET['s']) && $_GET['s']!=''){
- $OrderCode = stripslashes($_GET['s']);
+ $OrderCode = pSQL($_GET['s']);
$check_query = "select * from vivawallet_data where OrderCode='".$OrderCode."' ORDER BY id DESC";
$check = Db::getInstance()->executeS($check_query, $array = true, $use_cache = 0);
--- a/vivawallet/controllers/front/success.php
+++ b/vivawallet/controllers/front/success.php
@@ -9,7 +9,7 @@ class VivawalletSuccessModuleFrontContro
if(isset($_GET['s']) && $_GET['s']!=''){
$errors = '';
- $OrderCode = stripslashes($_GET['s']);
+ $OrderCode = pSQL($_GET['s']);
$check_query = "select * from vivawallet_data where OrderCode='".$OrderCode."' ORDER BY id DESC";
$check = Db::getInstance()->executeS($check_query, $array = true, $use_cache = 0);
--- a/vivawallet/controllers/front/webhook.php
+++ b/vivawallet/controllers/front/webhook.php
@@ -65,7 +65,7 @@ class VivawalletWebhookModuleFrontContro
$OrderCode = $resultObj->EventData->OrderCode;
$TransactionId = $resultObj->EventData->TransactionId;
- $check_query = "select * from vivawallet_data where OrderCode='".$OrderCode."' ORDER BY id DESC";
+ $check_query = "select * from vivawallet_data where OrderCode='".pSQL($OrderCode)."' ORDER BY id DESC";
$check = Db::getInstance()->executeS($transtat_query, $array = true, $use_cache = 0);
$oid = $transtat[0]['ref'];
@@ -106,11 +106,11 @@ class VivawalletWebhookModuleFrontContro
$currency = $this->context->currency;
$total = (float)$cart->getOrderTotal(true, Cart::BOTH);
- $transtat_query = "select * from vivawallet_data where OrderCode='".$OrderCode."' ORDER BY id DESC";
+ $transtat_query = "select * from vivawallet_data where OrderCode='".pSQL($OrderCode)."' ORDER BY id DESC";
$transtat = Db::getInstance()->executeS($transtat_query, $array = true, $use_cache = 0);
if($transtat[0]['order_state']=='I' && $StatusId=='F'){
- $update_query = "update vivawallet_data set order_state='P' where OrderCode='".$OrderCode."'";
+ $update_query = "update vivawallet_data set order_state='P' where OrderCode='".pSQL($OrderCode)."'";
$update = Db::getInstance()->execute($update_query);
$details = array(
Other recommandations
-
- To help improve the security of your PrestaShop installation, we recommend upgrading to the latest version. One of the benefits of upgrading is that it will disable the use of multiquery executions (separated by semicolons). However, please be aware that this will not protect your shop against SQL injection attacks that use the UNION clause to steal data. Additionally, it’s important to note that PrestaShop includes a function called pSQL, which includes a strip_tags function. This helps protect your shop against Stored XSS (also known as XSS T2) of Category 1. If a pSQL function is missing, it could potentially expose your project to critical Stored XSS vulnerabilities due to edge cases. Therefore, it’s crucial to ensure that all relevant functions are properly implemented and used consistently throughout your project.
- Change the default database prefix
ps_by a new longer arbitrary prefix. Nevertheless, be warned that this is useless against blackhats with DBA senior skills because of a design vulnerability in DBMS - Activate OWASP 942’s rules on your WAF (Web application firewall), be warned that you will probably break your backoffice and you will need to pre-configure some bypasses against these set of rules.
Timeline
| Date | Action |
|---|---|
| 2023-02-12 | Vulnerabity discovered during an audit by Touch Web and 202 ecommerce |
| 2023-02-23 | Contact the author |
| 2023-02-23 | Response of the author that a new module replace the impacted module |
| 2023-02-25 | Inform the author that a CVE ID is requested |
| 2023-03-17 | Propose a delay of 90 days before disclosing the CVE |
| 2023-03-17 | Request a CVE ID |
| 2023-07-17 | Publication of this CVE |
Links
DISCLAIMER: The French Association Friends Of Presta (FOP) acts as an intermediary to help hosting this advisory. While we strive to ensure the information and advice provided are accurate, FOP cannot be held liable for any consequences arising from reported vulnerabilities or any subsequent actions taken.
This advisory and patch is licensed under CC BY-SA 4.0