CubeCart — 1 vulnerability check

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

← All products · Feeds on GitHub

CubeCart 4.3.3 searchStr SQL injection

CVECVE-2010-4903
Severityhigh · CVSS 7.5
Categorysqli — SQL injection
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 75
Feedtests/vulnerabilities/cubecart/CVE-2010-4903.yaml

CubeCart 4.3.3 uses the searchStr parameter of index.php (with _a=viewCat) in an SQL query without sufficient escaping, so an unauthenticated visitor can inject SQL into the shop database.

Under the web root and the usual shop paths, this check requests the category search with a random token as a control, then with a single quote appended to the token, and then with two quotes. The vulnerability is reported when only the single-quote request prints a MySQL syntax error that also quotes the statement selecting from the CubeCart_search table, while the control and the balanced two-quote request print none. Nothing is written and no data is read from the database.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET {{adir}}/index.php?{{q.ctl}}
  3. HTTP(S) request GET {{adir}}/index.php?{{q.one}}
  4. HTTP(S) request GET {{adir}}/index.php?{{q.two}}
  5. Parses / computes the next value with a Rhai script
  6. Checks res.ok for ^true$ → finding QoD 75: CubeCart searchStr SQL injection (CVE-2010-4903)

References:

Feed source — tests/vulnerabilities/cubecart/CVE-2010-4903.yaml
# CubeCart 4.3.3 — index.php searchStr SQL injection (CVE-2010-4903)
#
# With _a=viewCat, CubeCart 4 stores the search term in its CubeCart_search table and
# builds the query from searchStr without enough escaping, so a lone quote breaks the
# query and the page prints MySQL's syntax error together with the failing statement
# ("> SELECT id FROM <prefix>CubeCart_search WHERE searchstr=...").
#
# Detection (QoD 75), per candidate install dir (web root, /store, /cubecart, /shop, /cart):
#   1. index.php?searchStr=<random token>&_a=viewCat&Submit=Go (control) has no SQL error.
#   2. searchStr=<token>' (one quote) answers with a MySQL syntax error AND the echoed
#      statement "SELECT id FROM ...CubeCart_search WHERE searchstr=" (product marker).
#   3. searchStr=<token>'' (two quotes, a quoted literal quote in SQL) answers with no
#      SQL error: the page is not simply printing an error for any quote.
# Read-only: the payloads are quote characters; nothing is written or read from the DB.
#
# Better than the source NASL: it fires on a quote probe alone; here a clean control and
# a balanced-quote probe rule out pages that print an error for any quote character.
# CVSS: NVD carries only a CVSS v2 score (7.5) for this CVE.
#
# Source: OpenVAS/Greenbone NVT 2011/gb_cubecart_mult_xss_n_sql_inj_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.802199, GPL-2.0-only). The WorldPay return.php XSS part of the
# NASL's advisory is not covered by this feed.
uid: 07a8c486-53a0-4337-abdd-c10d33d02abc
name: "CubeCart 4.3.3 searchStr SQL injection (CVE-2010-4903)"
description: |
  CubeCart 4.3.3 uses the searchStr parameter of index.php (with _a=viewCat) in an SQL
  query without sufficient escaping, so an unauthenticated visitor can inject SQL into
  the shop database.

  Under the web root and the usual shop paths, this check requests the category search
  with a random token as a control, then with a single quote appended to the token, and
  then with two quotes. The vulnerability is reported when only the single-quote request
  prints a MySQL syntax error that also quotes the statement selecting from the
  CubeCart_search table, while the control and the balanced two-quote request print none.
  Nothing is written and no data is read from the database.
cves: [CVE-2010-4903]
cvss: 7.5  # NVD publishes only a CVSS v2 base score (7.5) for this CVE
severity: high
category: sqli
confidence_base: 0.30
tags: [cubecart, php, sqli, error-based]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2010-4903"

steps:
  - id: gen
    action: script
    code: |
      let t = "nc" + rand_hex(5);
      #{ ctl: "searchStr=" + t + "&_a=viewCat&Submit=Go",
         one: "searchStr=" + t + "%27&_a=viewCat&Submit=Go",
         two: "searchStr=" + t + "%27%27&_a=viewCat&Submit=Go" }
    store_as: q

  # A loop: step runs together with every following non-loop step once per directory, so
  # the three init steps below reset all stored results at the start of each iteration.
  - id: init-ctl
    action: set_var
    var_name: ctl_resp
    var_value: {status: 0, body: null}
    loop:
      over: ["", "/store", "/cubecart", "/shop", "/cart"]
      var: adir

  - id: init-one
    action: set_var
    var_name: one_resp
    var_value: {status: 0, body: null}

  - id: init-two
    action: set_var
    var_name: two_resp
    var_value: {status: 0, body: null}

  - id: control
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{adir}}/index.php?{{q.ctl}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    store_as: ctl_resp

  - id: inject-one
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{adir}}/index.php?{{q.one}}"
    condition: 'ctl_resp.status == 200 && type_of(ctl_resp.body) == "string" && !ereg("(?i)(error in your SQL syntax|mysql_fetch|MySQL server version)", ctl_resp.body)'
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    store_as: one_resp

  - id: inject-two
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{adir}}/index.php?{{q.two}}"
    condition: 'one_resp.status >= 200 && one_resp.status < 500 && type_of(one_resp.body) == "string" && ereg("error in your SQL syntax", one_resp.body)'
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    store_as: two_resp

  - id: check
    action: script
    code: |
      let o = if type_of(one_resp.body) == "string" { one_resp.body } else { "" };
      let t = if type_of(two_resp.body) == "string" { two_resp.body } else { "" };
      let ok = two_resp.status == 200
        && ereg("error in your SQL syntax", o)
        && ereg("SELECT id FROM [A-Za-z0-9_]*CubeCart_search WHERE searchstr=", o)
        && !ereg("(?i)(error in your SQL syntax|mysql_fetch|MySQL server version)", t);
      #{ ok: ok }
    store_as: res

  - id: report
    action: match
    source: res.ok
    pattern: "^true$"
    condition: "res.ok"
    on_match:
      finding:
        title: "CubeCart searchStr SQL injection (CVE-2010-4903)"
        description: "A single quote appended to the searchStr parameter of index.php (_a=viewCat) made CubeCart print a MySQL syntax error quoting its CubeCart_search query, while the same request without the quote and with a balanced pair of quotes printed none: the value reaches an SQL statement unescaped, so an unauthenticated attacker can run arbitrary SQL against the shop database."
        remediation: "Upgrade CubeCart to a release later than 4.3.3 that escapes searchStr, or migrate to a supported CubeCart version."
        confidence_delta: 0.45
        qod: 75
        evidence: "{{adir}}/index.php: searchStr=<token> answers without a database error, searchStr=<token>' answers with an SQL syntax error quoting the CubeCart_search query, searchStr=<token>'' answers without one"
      stop: true

View these feeds on GitHub