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 and CVE-2023-27570
- Published at: 2023-03-15
- Advisory source: Friends-Of-Presta
- Vendor: 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 compromized _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 from 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.
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 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 recommandations
- Upgrade PrestaShop beyond 1.7.8.8 (and 8.0.1) to disable multiquery executions (separated by “;”).
- Change the default database prefix ps_ by a new longer arbitrary prefix. Nethertheless, be warned that this is useless against blackhat 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 | Discovery of the vulnerability by TouchWeb.fr |
2023-02-25 | Vulnerability confirmed by Profileo |
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 |