OpenCart — 1 vulnerability check

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

← All products · Feeds on GitHub

OpenCart page Parameter SQL Injection

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

OpenCart 1.3.2 and earlier compute the LIMIT offset of its product listings (special offers, search results, categories) from the page parameter without any lower bound and paste it into the SQL query, without authentication (SQL injection, CVE-2010-0956). A failed query ends the page with the MySQL error and the whole SQL statement.

This check requests the special offers page, then the product search with the keyword "e" and then the wildcard "%", under the web root and the usual install paths, with a random negative page number. The vulnerability is confirmed when the reply carries the MySQL syntax error and the negative offset the application computed from that number (twelve times the number plus one), which never appears in the request. Nothing is written and no stored data is read.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET {{dir}}/index.php?route=product/special&page={{sc.page}}
  3. Parses / computes the next value with a Rhai script
  4. HTTP(S) request GET {{dir}}/index.php?route=product/search&keyword=e&page={{sc.page}}
  5. Parses / computes the next value with a Rhai script
  6. HTTP(S) request GET {{dir}}/index.php?route=product/search&keyword=%25&page={{sc.page}}
  7. Parses / computes the next value with a Rhai script
  8. Checks hit for ^/ → finding QoD 75: OpenCart page Parameter SQL Injection (CVE-2010-0956)

References:

Feed source — tests/vulnerabilities/opencart/CVE-2010-0956.yaml
# OpenCart <= 1.3.2 — "page" parameter SQL injection — CVE-2010-0956
#
# OpenCart 1.3.2 (catalog/controller/product/special.php, search.php, category.php…) turns
# the page parameter into the LIMIT offset with PHP arithmetic and the product model pastes
# it with no lower bound (git tag commit 710037f26 "v1.3.2"):
#     getProductSpecials($sort, $order, ($page - 1) * 12, 12);
#     $sql .= " LIMIT " . (int)$start . "," . (int)$limit;
# A page value below 1 gives a negative offset, the query fails and the mysql driver ends
# the request with exit('Error: ' . mysql_error() . '<br />Error No: ' . mysql_errno() .
# '<br />' . $sql). Fixed in 1.4.0 by commit 8f19ea75e (2009-11-05): `if ($start < 0)
# $start = 0;` before every LIMIT of the product model.
#
# Detection, per candidate install dir (web root and the usual install paths):
#   (QoD 75) index.php?route=product/special&page=-N, then
#   index.php?route=product/search&keyword=e&page=-N and keyword=%25, with a random N. The
#   vulnerable store answers with the MySQL syntax error and the failed query, quoting the
#   offset -12*(N+1) that PHP computed from our value — a number the request never
#   carries, so a page that only reflects the parameter cannot match. Read-only.
#
# Better than the source NASL:
#   - the reference check sends page=' (a quote): OpenCart only applies htmlentities() and
#     the "injection" is PHP arithmetic ("&#039;" - 1 = -1 on PHP 5, the only PHP the 1.x
#     mysql_* driver runs on). A negative number gives the same offset, and a computed one;
#   - the reference check only requests product/special, whose query runs only when the
#     store has at least one special offer (most stores have none: false negative). The
#     same unbounded LIMIT is reached through product/search, with the keyword "e" and
#     then "%" (LIKE '%%%' matches every product name, in any language);
#   - it matches "You have an error in your SQL syntax" alone; the computed offset is
#     required here;
#   - the usual install dirs are probed, not only the detected one.
#
# Source: OpenVAS/Greenbone NVT 2010/gb_opencart_38605.nasl (OID 1.3.6.1.4.1.25623.1.0.100561),
# GPL-2.0-only; BID 38605.
uid: 4dad8d9c-4fc4-4d2c-af66-c010bdc14273
name: "OpenCart page Parameter SQL Injection (CVE-2010-0956)"
description: |
  OpenCart 1.3.2 and earlier compute the LIMIT offset of its product listings (special
  offers, search results, categories) from the page parameter without any lower bound and
  paste it into the SQL query, without authentication (SQL injection, CVE-2010-0956). A
  failed query ends the page with the MySQL error and the whole SQL statement.

  This check requests the special offers page, then the product search with the keyword
  "e" and then the wildcard "%", under the web root and the usual install paths, with a
  random negative page number. The vulnerability is confirmed when the reply carries the MySQL syntax error and
  the negative offset the application computed from that number (twelve times the number
  plus one), which never appears in the request. Nothing is written and no stored data is
  read.
cves: [CVE-2010-0956]
cvss: 7.5
severity: high
category: sqli
confidence_base: 0.30
tags: [opencart, sqli, error-based, php]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2010-0956"
  - "https://www.securityfocus.com/bid/38605"
  - "https://github.com/opencart/opencart/commit/8f19ea75e"

steps:
  # ── Random page number and the offset PHP computes from it ────────────────
  - id: gen-proof
    action: script
    code: |
      let n = rand_int(100, 999);
      let off = "-" + (12 * (n + 1));
      #{ page: "-" + n, want: off + ",12" }
    store_as: sc

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

  # ── Per candidate install path (loop group) ───────────────────────────────
  - id: init-resp
    action: set_var
    var_name: special_resp
    var_value: {status: 0, body: ""}
    loop:
      var: dir
      over: ["", "/opencart", "/shop", "/store", "/upload", "/catalog"]

  - id: init-search-e
    action: set_var
    var_name: search_e_resp
    var_value: {status: 0, body: ""}

  - id: init-search-any
    action: set_var
    var_name: search_any_resp
    var_value: {status: 0, body: ""}

  - id: special-probe
    action: http_request
    method: GET
    path: "{{dir}}/index.php?route=product/special&page={{sc.page}}"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 15
    condition: 'hit == ""'
    store_as: special_resp

  - id: check-special
    action: script
    condition: 'hit == ""'
    code: |
      let body = if type_of(special_resp.body) == "string" { special_resp.body } else { "" };
      if body.contains("You have an error in your SQL syntax") && body.contains(sc.want) {
        dir + "/index.php?route=product/special&page=" + sc.page
      } else { "" }
    store_as: hit

  - id: search-e-probe
    action: http_request
    method: GET
    path: "{{dir}}/index.php?route=product/search&keyword=e&page={{sc.page}}"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 15
    condition: 'hit == ""'
    store_as: search_e_resp

  - id: check-search-e
    action: script
    condition: 'hit == ""'
    code: |
      let body = if type_of(search_e_resp.body) == "string" { search_e_resp.body } else { "" };
      if body.contains("You have an error in your SQL syntax") && body.contains(sc.want) {
        dir + "/index.php?route=product/search&keyword=e&page=" + sc.page
      } else { "" }
    store_as: hit

  - id: search-any-probe
    action: http_request
    method: GET
    path: "{{dir}}/index.php?route=product/search&keyword=%25&page={{sc.page}}"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 15
    condition: 'hit == ""'
    store_as: search_any_resp

  - id: check-search-any
    action: script
    condition: 'hit == ""'
    code: |
      let body = if type_of(search_any_resp.body) == "string" { search_any_resp.body } else { "" };
      if body.contains("You have an error in your SQL syntax") && body.contains(sc.want) {
        dir + "/index.php?route=product/search&keyword=%25&page=" + sc.page
      } else { "" }
    store_as: hit

  # ── Finding (inside the loop group: stop ends the scan at the first hit) ──
  - id: report
    action: match
    source: hit
    pattern: "^/"
    on_match:
      finding:
        title: "OpenCart page Parameter SQL Injection (CVE-2010-0956)"
        description: "An unauthenticated product listing request with a negative page number returned the MySQL syntax error and the SQL query carrying the LIMIT offset the application computed from that number: the page parameter reaches the SQL query unchecked."
        remediation: "Upgrade OpenCart to 1.4.0 or later (current releases are recommended: the 1.x branch is no longer supported)."
        confidence_delta: 0.55
        qod: 75
        evidence: "{{hit}} returned \"You have an error in your SQL syntax\" with the computed offset LIMIT {{sc.want}} (page {{sc.page}})"
      stop: true

View these feeds on GitHub