In the module Tracking et Conversions (eo_tags) prior to version 1.4.19, an anonymous user can perform an SQL injection attack.
Summary
- CVE ID: CVE-2023-27569, CVE-2023-27570
- Published at: 2023-03-15
- Advisory source: security.profileo.com
- Platform: PrestaShop
- Product: eo_tags
- Impacted release: >= 1.2.0, < 1.4.19 (1.4.19 fixed the vulnerability)
- Product author: Profileo
- Weakness: CWE-89
- Severity: critical (9.8)
Description
From version 1.2.0 published on Nov 17, 2017 to 1.4.18 published on Feb 21, 2023 (fixed in 1.4.19, published on Feb 28, 2023), an HTTP request can be forged with a compromised _ga
cookie in order to exploit an insecure parameter in function saveGanalyticsCookie()
and gaParseCookie()
, which could lead to a SQL injection.
From version 1.2.0 published on Nov 17, 2017 to 1.2.19 published on Oct 22, 2019 (fixed in 1.3.0), an HTTP request can be forged with a compromised User-Agent or Referer in order to exploit insecure parameters in trackReferrer()
function, which could lead to a SQL injection. As of 1.2.1, the code has been migrated to classes/EoTagsStats.php (EoTagsStats::setNewGuest()
) and the vulnerability now requires Privileges (PR) and user interaction (UI) to be exploited, reducing the severity to 8.0.
This exploit uses cookies (and referer) to perform the attack, therefore the module name will be hidden during the exploit, so you won’t be able to identify this vulnerability in your conventional frontend logs. You will only see “GET /” or “POST /” inside your conventional frontend logs.. The compromised referer will be visible in your access logs, however you’ll not be able to see the compromised cookie.
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
- Technical and personal data leaks
Patch
If present in eo_tags.php
--- a/eo_tags.php
+++ b/eo_tags.php
@@ -1495,8 +1495,8 @@ class Eo_Tags extends Module
$old_cid = $this->getAnalyticsCID($this->context->cart->id);
$data = array(
'id_cart' => $this->context->cart->id,
- 'cid' => $cid,
- 'cookie' => serialize($_COOKIE['_ga']),
+ 'cid' => pSQL($cid),
+ 'cookie' => pSQL(serialize($_COOKIE['_ga'])),
);
if (!$old_cid) {
Db::getInstance()->insert('eo_tags_ga_cookie', $data);
--- a/eo_tags.php
+++ b/eo_tags.php
@@ -1356,11 +1356,11 @@ class Eo_Tags extends Module
';
if ($referral = Db::getInstance()->getRow($sql2)) {
$data = array(
- 'id_guest' => $cookie->id_guest,
+ 'id_guest' => (int)$cookie->id_guest,
'ip_address' => $referral['ip_address'],
- 'http_referer' => $referral['http_referer'],
- 'request_uri' => $referral['request_uri'],
- 'user_agent' => $user_agent,
+ 'http_referer' => pSQL($referral['http_referer']),
+ 'request_uri' => pSQL($referral['request_uri']),
+ 'user_agent' => pSQL($user_agent),
'date_add' => $referral['date_add'],
);
}
@@ -1397,11 +1397,11 @@ class Eo_Tags extends Module
$request_uri = substr($request_uri, 0, 255);
$data = array(
- 'id_guest' => $cookie->id_guest,
+ 'id_guest' => (int)$cookie->id_guest,
'ip_address' => $ip_address,
- 'http_referer' => $http_referer,
- 'request_uri' => $request_uri,
- 'user_agent' => $user_agent,
+ 'http_referer' => pSQL($http_referer),
+ 'request_uri' => pSQL($request_uri),
+ 'user_agent' => pSQL($user_agent),
'date_add' => date('Y-m-d H:i:s'),
);
}
If present in classes/EoTagsStats.php
EoTagsStats::setNewGuest()
--- a/classes/EoTagsStats.php
+++ b/classes/EoTagsStats.php
@@ -26,7 +26,7 @@ class EoTagsStats {
$data = array(
'id_customer' => $id_customer,
'ip_address' => $ip_address,
- 'user_agent' => $user_agent,
+ 'user_agent' => pSQL($user_agent),
'date_add' => date('Y-m-d H:i:s'),
);
Profileo thanks TouchWeb.fr for its help in discovering the vulnerability. Feel free to contact security/at/profileo.com if you wish to receive a PHP script to automatically detect and patch this vulnerability on your website.
Other recommendations
- 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_ by a new longer arbitrary prefix. Nevertheless, be warned that this is useless against blackhats with DBA senior skill 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-24 | Vulnerability discovered by TouchWeb.fr |
2023-02-25 | Vulnerability confirmed by Profileo.com |
2023-02-28 | Patch created by Profileo and release of version 1.4.19 fixing the issue |
2023-03-01 | Patch released to customers |
2023-03-15 | Publication on security.profileo.com |