In the module “M4 PDF Extensions” (m4pdf) up to version 3.3.2 from PrestaAddons for PrestaShop, a guest can perform PHP code injection in affected versions.

Summary

  • CVE ID: CVE-2023-50029
  • Published at: 2024-06-20
  • Platform: PrestaShop
  • Product: m4pdf
  • Impacted release: <= 3.3.1 (3.3.2 fixed the vulnerability - see WARNING below)
  • Product author: PrestaAddons
  • Weakness: CWE-94
  • Severity: critical (10)

Description

The method M4PDF::saveTemplate() has sensitive action that can be executed with a trivial http call and exploited to forge a Code injection.

Note : A useless predictable token protect these methods.

This exploit uses a PrestaShop front controller and most attackers can conceal the module controller’s path during the exploit, 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 : The module still own sensitive to critical issues because author refuse to update its logical authentication flaw, you should consider to delete it or put its front controller under IP restriction, if you do so, you must be aware of this.

Edit 2024-09-10 - WARNING : This exploit is actively used to deploy webskimmer to massively steal credit cards. Since POC is now exploited, it is considered public.

CVSS base metrics

  • Attack vector: network
  • Attack complexity: low
  • Privilege required: none
  • User interaction: none
  • Scope: changed
  • 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 admin’s ajax scripts
  • Rewrite SMTP settings to hijack emails

Proof of concept

curl -v -X POST -d 'fc=module&module=m4pdf&controller=pdf&nav=1&action=save&action_target=test.php&template=test&m4token=PREDICTABLE_TOKEN&editor_content=<?= 42;' 'https://preprod.X/' && curl -v 'https://preprod.X/modules/m4pdf/tpl/test.php'

Other recommendations

  • It’s recommended to delete the module m4pdf since author refuse to review its authentication design based on predictable token
  • Activate OWASP 933’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.

Timeline

Date Action
2023-10-19 Issue discovered during a code review by realdev and document by TouchWeb.fr
2023-10-19 Realdev report it to author
2023-09-21 Contact PrestaShop Addons security Team to confirm version scope by author
2023-11-08 PrestaShop Addons security Team confirms version scope
2023-12-12 Received CVE ID
2024-01-16 Relaunch author for patch
2024-04-17 Relaunch author for patch
2024-06-20 Publish this security advisory