[CVE-2023-46348] Improper neutralization of SQL parameter in SunnyToo – Urls module for PrestaShop

PrestaShop Security Advisory

In the module “Urls” (sturls) up to version 1.1.13 from SunnyToo for PrestaShop, a guest can perform SQL injection in affected versions.


  • CVE ID: CVE-2023-46348
  • Published at: 2023-12-07
  • Platform: PrestaShop
  • Product: sturls
  • Impacted release: <= 1.1.11 (1.1.13 fixed the vulnerability - WARNING : see WARNING below)
  • Product author: SunnyToo
  • Weakness: CWE-89
  • Severity: critical (9.8)


Methods StUrls::hookActionDispatcher and StUrls::getInstanceId have sensitive SQL calls that can be executed with a trivial http call and exploited to forge a SQL injection.

This exploit uses a hook Dispatcher with forged parameters 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.

WARNING : Since we noticed this vulnerability on a 1.1.13 version but the author confirm us that it only affects 1.1.11, be warned that there is maybe manufactured versions in the wild and you should check all version prior to 1.1.13.

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 expose tokens and unlock admins’s ajax scripts
  • Rewrite SMTP settings to hijack emails

Patch from 1.1.13

--- 1.1.13/modules/sturls/sturls.php
+++ XXXXXX/modules/sturls/sturls.php
@@ -1288,7 +1288,7 @@ class StUrls extends Module
                         FROM '._DB_PREFIX_.'category_lang l
                         LEFT JOIN '._DB_PREFIX_.'category a
                         ON (a.id_category=l.id_category)
-                        WHERE `link_rewrite` = "'.$top_parent_name.'"
+                        WHERE `link_rewrite` = "'.pSQL($top_parent_name).'"
                         AND a.`active` = 1
                         AND `id_lang` = '.(int)$this->context->language->id
@@ -1297,7 +1297,7 @@ class StUrls extends Module
                     FROM '._DB_PREFIX_.'category_lang l
                     LEFT JOIN '._DB_PREFIX_.'category a
                     ON (a.id_category=l.id_category)
-                    WHERE `link_rewrite` = "'.$parent_name.'"
+                    WHERE `link_rewrite` = "'.pSQL($parent_name).'"
                     AND a.`active` = 1'.
                     ($top_parent_name ? ' AND `id_parent` = ' . (int)$top_parent_id : '').'
                     AND `id_lang` = '.(int)$this->context->language->id
@@ -1344,11 +1344,11 @@ class StUrls extends Module
                 ON (a.id_'.$table.'=l.id_'.$table.')
                 '.($table != 'category' ? 'INNER JOIN '._DB_PREFIX_.$table.'_shop s
                 ON (a.id_'.$table.'=s.id_'.$table.' AND s.id_shop = '.(int)$this->context->shop->id.')' : '').'
-                WHERE `'.$field.'` = "'.$rewrite.'"
+                WHERE `'.bqSQL($field).'` = "'.pSQL($rewrite).'"
                 AND `id_lang` = '.(int)$this->context->language->id.'
                 '.($is_id_shop ? 'AND l.id_shop='.(int)$this->context->shop->id : '').'
-                '.($has_ref ? 'AND reference="'.$reference.'"' : '').'
-                '.($id_parent ? 'AND id_parent IN ('.implode(',',$id_parent).')' : '').'
+                '.($has_ref ? 'AND reference="'.pSQL($reference).'"' : '').'
+                '.($id_parent ? 'AND id_parent IN ('.implode(',', array_map('intval', $id_parent)).')' : '').'
             if ($id) {
                 Configuration::updateValue($this->_prefix_st.'sha1_'.$sig, (int)$id);
@@ -1513,7 +1513,7 @@ class StUrls extends Module
                         SELECT bl.id_st_blog FROM '._DB_PREFIX_.'st_blog_lang bl
                         INNER JOIN '._DB_PREFIX_.'st_blog_shop bs
                         ON(bl.`id_st_blog` = bs.`id_st_blog`)
-                        WHERE link_rewrite = "'.$rewrite.'"
+                        WHERE link_rewrite = "'.pSQL($rewrite).'"
                         AND id_lang = '.(int)Context::getContext()->language->id.'
                         AND id_shop = '.(int)$this->context->shop->id.'
@@ -1536,7 +1536,7 @@ class StUrls extends Module
                         SELECT l.id_st_blog_category FROM '._DB_PREFIX_.'st_blog_category_lang l
                         INNER JOIN '._DB_PREFIX_.'st_blog_category_shop s
                         ON(l.`id_st_blog_category` = s.`id_st_blog_category`)
-                        WHERE link_rewrite = "'.$rewrite.'"
+                        WHERE link_rewrite = "'.$pSQL($rewrite).'"
                         AND id_lang = '.(int)Context::getContext()->language->id.'
                         AND id_shop = '.(int)$this->context->shop->id.'

Other recommendations

  • It’s recommended to upgrade to the latest version of the module sturls.
  • Upgrade PrestaShop to the latest version to disable multiquery executions (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_ with 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 this set of rules.


2023-08-31Issue discovered during a code review by TouchWeb.fr
2023-08-31Contact Author to confirm versions scope
2023-09-09Author confirm versions scope
2023-09-16Author provide a patch
2023-10-17Request a CVE ID
2023-10-23Received CVE ID
2023-12-07Publish this security advisory