[CVE-2023-33665] Improper neutralization of a SQL parameter in aitable from ai-dev module for PrestaShop

In the module “Attributes table” (aitable) for PrestaShop, an attacker can perform a SQL injection up to 0.2.1. Release 0.2.2 fixed this security issue.

Summary

  • CVE ID: CVE-2023-33665
  • Published at: 2023-08-01
  • Advisory source: Friends-Of-Presta.org
  • Platform: PrestaShop
  • Product: aitable
  • Impacted release: <= 0.2.1 (0.2.2 fixed issue)
  • Product author: ai-dev
  • Weakness: CWE-89
  • Severity: critical (9.8)

Description

Up to 0.2.2, a sensitive SQL call in file includes/ajax.php can be executed with a trivial http call and exploited to forge a blind SQL injection throught the POST or GET submitted attributes variables.

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

  • Technical and personal data leaks
  • Obtain admin access
  • Remove all data of the linked PrestaShop
  • Display sensitives tables to front-office to unlock potential admin’s ajax scripts of modules protected by token on the ecosystem

Patch

--- a/modules/aitable/includes/ajax.php
+++ b/modules/aitable/includes/ajax.php
        $data = array();
        foreach ($lines as $line) {
            foreach ($columns as $col) {
                $result = Db::getInstance()->getRow(
                    'SELECT COUNT(pac.id_product_attribute) AS count, pa.* FROM '._DB_PREFIX_.'product_attribute AS pa LEFT JOIN '._DB_PREFIX_.'product_attribute_combination AS pac ON pac.id_product_attribute = pa.id_product_attribute WHERE '.
-                    'pac.id_attribute IN ('.pSql($attributes).','.(int)$line['id_attribute'].','.(int)$col['id_attribute'].') AND pa.id_product = '.(int)$product_id.' GROUP BY pa.id_product_attribute HAVING count = '.(int)$count
+                    'pac.id_attribute IN ('.implode(',', array_map('intval', explode(',', $attributes))).','.(int)$line['id_attribute'].','.(int)$col['id_attribute'].') AND pa.id_product = '.(int)$product_id.' GROUP BY pa.id_product_attribute HAVING count = '.(int)$count
                );

Other recommandations

  • Upgrade PrestaShop to the latest version to disable multiquery execution (separated by “;”) – be warned that this functionality WILL NOT protect your SHOP against injection SQL which uses the UNION clause to steal data.
  • 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

DateAction
2023-05-08Vunlnerability found during a audit by 202 ecommerce
2023-05-10Contact the author
2023-05-12The author confirm the issue and supply a fixed release
2023-05-12Request a CVE ID
2023-08-01Publication of this advisory

CLICK FOR MORE INFORMATION