Improper Limitation of a Pathname leads to a Path Traversal vulnerability in the module King-Avis for Prestashop, allowing a user knowing the download token to read arbitrary local files.This issue affects King-Avis: before 17.3.15.

Summary

  • CVE ID: CVE-2023-3031
  • Published at: 2023-06-01
  • Advisory source: borelenzo.github.io
  • Platform: PrestaShop
  • Product: King-Avis
  • Impacted release: < 17.3.15
  • Product author: Webbax
  • Weakness: CWE-22
  • Severity: medium (6.5)

Description

King-Avis is a Prestashop module developed by Webbax. In versions older than 17.3.15, the latter suffers from an authenticated path traversal, leading to local file read.

There was a file download.php, that could be used to download statistical reports as CSV files. To protect from unauthorised access, the download feature was protected by a token. If the token is incorrect, the file exits and no content is returned. However, if the token is correct, the path is extracted from the parameter file and used without being sanitised.

It means that administrators (supposed to know this token) can read arbitrary local files. Also, there is no need to have an active admin session to browse to this file.

CVSS base metrics

  • Attack vector: network
  • Attack complexity: low
  • Privilege required: low
  • User interaction: none
  • Scope: unchanged
  • Confidentiality: high
  • Integrity: none
  • Availability: none

Vector string: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N

Possible malicious usage

  • Stealing secrets to unlock admin controllers based on ajax script
  • Exfiltrate all modules with all versions to facilitate pentesting
  • Stealing table_prefix to greatly facilitate SQL injections for kiddies who don’t know how exploit DBMS design’s vulnerabilities
  • Stealing database access to log in to exposed PHPMyAdmin / Adminer / etc.
  • Bypass WAF / htaccess restrictions to read forbidden files (such as logs on predictable paths of banks’s modules inside /var/log/)

Patch for < 17.3.15

diff --git a/modules/kingavis/downloads/download.php b/modules/kingavis/downloads/download.php
--- a/modules/kingavis/downloads/download.php
+++ b/modules/kingavis/downloads/download.php
@@ -17 +17 @@ if($token!==_COOKIE_IV_){die('token error');}
-$file = Tools::getValue('file');
+$file = basename(Tools::getValue('file'));

Other recommendations

  • Upgrade the module to the most recent version
  • Upgrade PrestaShop to the latest version to disable multiquery executions (separated by “;”)
  • 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
24-05-2023 Vendor notified
25-05-2023 Vendor acknowledged and published a patch
26-05-2023 NCSC notified