Koobi CMS — 1 vulnerability check

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

← All products · Feeds on GitHub

Dream4 Koobi CMS index.php p / q SQL injection

CVECVE-2005-1373
Severityhigh · CVSS 7.5
Categorysqli — SQL injection
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 97
Feedtests/vulnerabilities/koobi-cms/CVE-2005-1373.yaml

Dream4 Koobi CMS 4.2.3 places the p (page) and q (search) parameters of index.php into its MySQL queries without escaping them, so a remote, unauthenticated attacker can run arbitrary SQL against the site database.

For the web root and /koobi, and for each of the two parameters, this check sends an EXTRACTVALUE expression built from two random numbers. The injection is confirmed when the database error returned by the page carries the product of those numbers, which only the database can have computed. On older MySQL servers without EXTRACTVALUE, it falls back to a stray quote followed by a random word: the flaw is reported when the MySQL syntax error quotes that word while the same parameter without a quote causes no SQL error. The requests only make the query fail; nothing is read or written.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET {{v.d}}/index.php?{{v.p}}=x%27%20AND%20extractvalue(1,concat(0x7e,{{sc.a}}*{{sc.b}}))…
  3. HTTP(S) request GET {{v.d}}/index.php?{{v.p}}=extractvalue(1,concat(0x7e,{{sc.a}}*{{sc.b}}))
  4. Parses / computes the next value with a Rhai script
  5. Checks xv for XPATH syntax error carrying ~[0-9]+ → finding QoD 97: Dream4 Koobi CMS index.php SQL injection (CVE-2005-1373)
  6. HTTP(S) request GET {{v.d}}/index.php?{{v.p}}=%27{{sc.tok}}
  7. HTTP(S) request GET {{v.d}}/index.php?{{v.p}}={{sc.ctl}}
  8. Parses / computes the next value with a Rhai script
  9. Checks fallback for MySQL syntax error quoting the injected marker → finding QoD 75: Dream4 Koobi CMS index.php SQL injection (CVE-2005-1373)

References:

Feed source — tests/vulnerabilities/koobi-cms/CVE-2005-1373.yaml
# Dream4 Koobi CMS — index.php p / q SQL injection (CVE-2005-1373).
#
# Koobi CMS 4.2.3 (Dream4, commercial PHP + MySQL) splices the p (page) and q
# (search) parameters of index.php into its MySQL queries unescaped
# (BID 13412 / 13413, EDB-25555 / 25556):
#   index.php?p='[SQL code]      index.php?area=1&p='[SQL code]
#   index.php?q='[SQL code]
# On a failed query Koobi prints its KOOBI-ERROR page carrying the MySQL error.
# The product sources were never published; the vectors follow the advisories.
#
# Detection, read-only, for the web root and /koobi × the p and q parameters:
#   1. QoD 97 — p / q = x' AND extractvalue(1,concat(0x7e,A*B)) AND '1'='1
#      (quoted context) and extractvalue(1,concat(0x7e,A*B)) (unquoted context,
#      a harmless string where the value is quoted). A, B: random 6-digit
#      numbers. MySQL >= 5.1 evaluates the constant expression while preparing
#      the query and fails with "XPATH syntax error: '~<A*B>'": the product never
#      appears in the request, so only the database can have computed it. No row
#      is read or written.
#   2. QoD 75 fallback (MySQL < 5.1 has no EXTRACTVALUE) — p / q = 'NOCTIS<rand>
#      (the reference check's stray quote): the MySQL syntax error quotes the
#      random word ("near 'NOCTIS…"), or Koobi's KOOBI-ERROR page shows an SQL /
#      MySQL error quoting it, while a control value without a quote shows no
#      SQL error at all. A page that merely echoes the URL has no parser message
#      in front of the word and is not reported. This fallback is reported only
#      when no directory / parameter gave the stage 1 proof.
#
# Reference: OpenVAS/Greenbone NVT `pre2008/dream4_koobi_cms_sql.nasl`
# (OID 1.3.6.1.4.1.25623.1.0.18254, GPL-2.0-only) — sends index.php?p='vt-test
# and matches "SQL.*MySQL.* 'vt-test" next to KOOBI-ERROR. This feed adds a
# computed (QoD 97) proof, the q parameter named by the CVE, a control request
# and HTML-escaped quotes in the error text.
# Both stages also require Koobi's KOOBI-ERROR page or Koobi / dream4 branding
# in the reply, so a different product's SQL injection on index.php?p= / ?q=
# is not reported as this CVE. The control value is digits only: it raises no
# error in quoted, LIKE or numeric context.
# Known limit: a value spliced inside double quotes (c_name="<p>") is not
# broken out of by these payloads (the reference check has the same gap).
# CVSS: NVD carries only a CVSS v2 score (7.5).
uid: 061248ff-3a36-4132-9174-a9d710127d0b
name: "Dream4 Koobi CMS index.php p / q SQL injection (CVE-2005-1373)"
description: |
  Dream4 Koobi CMS 4.2.3 places the p (page) and q (search) parameters of
  index.php into its MySQL queries without escaping them, so a remote,
  unauthenticated attacker can run arbitrary SQL against the site database.

  For the web root and /koobi, and for each of the two parameters, this check
  sends an EXTRACTVALUE expression built from two random numbers. The
  injection is confirmed when the database error returned by the page carries
  the product of those numbers, which only the database can have computed.
  On older MySQL servers without EXTRACTVALUE, it falls back to a stray quote
  followed by a random word: the flaw is reported when the MySQL syntax error
  quotes that word while the same parameter without a quote causes no SQL
  error. The requests only make the query fail; nothing is read or written.
cves: [CVE-2005-1373]
cvss: 7.5
severity: high
category: sqli
confidence_base: 0.30
tags: [koobi, dream4, cms, php, mysql, sqli]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2005-1373"
  - "http://www.securityfocus.com/bid/13412"
  - "http://www.securityfocus.com/bid/13413"
  - "https://www.exploit-db.com/exploits/25555"
  - "https://www.exploit-db.com/exploits/25556"

steps:
  # ── Random operands and markers (shared by every pass) ────────────────────
  - id: gen
    action: script
    code: |
      let a = rand_int(100000, 999999);
      let b = rand_int(100000, 999999);
      #{ a: a, b: b, prod: "~" + (a * b),
         tok: "NOCTIS" + rand_int(10000000, 99999999) + "Q",
         ctl: "" + rand_int(10000000, 99999999) }
    store_as: sc

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

  # ── Per install dir × parameter (loop group) ──────────────────────────────
  # Pre-initialise every stored result a script reads: a failed request leaves
  # store_as unset and an undefined var would abort the whole test.
  - id: init-xvq
    action: set_var
    var_name: xvq
    var_value: {status: 0, body: ""}
    loop:
      var: v
      over:
        - {d: "", p: "p"}
        - {d: "", p: "q"}
        - {d: "/koobi", p: "p"}
        - {d: "/koobi", p: "q"}

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

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

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

  # Stage 1: EXTRACTVALUE error carrying the database-computed product —
  # quoted context first …
  - id: xv-quoted
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{v.d}}/index.php?{{v.p}}=x%27%20AND%20extractvalue(1,concat(0x7e,{{sc.a}}*{{sc.b}}))%20AND%20%271%27=%271"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: xvq

  # … then unquoted (skipped when index.php is absent from this dir).
  - id: xv-numeric
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{v.d}}/index.php?{{v.p}}=extractvalue(1,concat(0x7e,{{sc.a}}*{{sc.b}}))"
    condition: "xvq.status != 0 && xvq.status != 404"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: xvn

  - id: check-xv
    action: script
    code: |
      let bq = if type_of(xvq.body) == "string" { xvq.body } else { "" };
      let bn = if type_of(xvn.body) == "string" { xvn.body } else { "" };
      let re = "XPATH syntax error: (?:'|&#0?39;|&#x27;|&apos;)?" + sc.prod + "(?:[^0-9]|$)";
      // Koobi only: its error page (KOOBI-ERROR) or branding must be in the
      // reply, so another product's index.php?p= / ?q= SQLi is not reported.
      let kre = "(?i)koobi|dream4";
      let hq = ereg(re, bq) && ereg(kre, bq);
      let hn = !hq && ereg(re, bn) && ereg(kre, bn);
      if hq {
        v.d + "/index.php " + v.p + "=x' AND extractvalue(1,concat(0x7e," + sc.a + "*" + sc.b + ")) AND '1'='1: XPATH syntax error carrying " + sc.prod + " (HTTP " + xvq.status + ")"
      } else if hn {
        v.d + "/index.php " + v.p + "=extractvalue(1,concat(0x7e," + sc.a + "*" + sc.b + ")): XPATH syntax error carrying " + sc.prod + " (HTTP " + xvn.status + ")"
      } else { "" }
    store_as: xv

  - id: report-xv
    action: match
    source: xv
    pattern: "XPATH syntax error carrying ~[0-9]+"
    condition: 'xv != ""'
    on_match:
      finding:
        title: "Dream4 Koobi CMS index.php SQL injection (CVE-2005-1373)"
        description: "Koobi CMS ran an SQL expression injected through a parameter of index.php: the database error returned by the page carries the product of two random numbers chosen by the scanner, which never appear in the request. An unauthenticated attacker can run arbitrary SQL against the site database (read or change accounts and content)."
        remediation: "Koobi CMS is no longer maintained and no fixed 4.2.x release is documented: take the site offline or move to a maintained CMS. If you maintain the code, escape (or bind as query parameters) p and q in index.php, and do not print database errors to visitors."
        confidence_delta: 0.65
        qod: 97
        evidence: "Error-based SQLi confirmed: {{xv}}"
      stop: true

  # Stage 2 (MySQL < 5.1): syntax error quoting a random marker + control.
  - id: qm-probe
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{v.d}}/index.php?{{v.p}}=%27{{sc.tok}}"
    condition: 'fallback == "" && xvq.status != 0 && xvq.status != 404'
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: qm

  - id: ctl-probe
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{v.d}}/index.php?{{v.p}}={{sc.ctl}}"
    condition: 'fallback == "" && qm.status != 0'
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: ctl

  # The marker must follow the parser message ("near '…" in the MySQL syntax
  # error, or an SQL / MySQL error line on the KOOBI-ERROR page; quotes may be
  # HTML-escaped), and the control must show no SQL error. Keeps the first
  # candidate only.
  - id: check-qm
    action: script
    code: |
      if fallback != "" { fallback } else {
        let b = if type_of(qm.body) == "string" { qm.body } else { "" };
        let cb = if type_of(ctl.body) == "string" { ctl.body } else { "" };
        let q = "(?:'|&#0?39;|&#x27;|&apos;)";
        let isk = ereg("(?i)koobi|dream4", b);
        let syn = isk && ereg("(?i)error in your SQL syntax[^\\n]{0,200}near " + q + "[^\\n]{0,24}" + sc.tok, b);
        let kob = b.contains("KOOBI-ERROR") && ereg("SQL[^\\n]*MySQL[^\\n]* " + q + "{1,2}" + sc.tok, b);
        let cerr = ereg("(?i)error in your SQL syntax|KOOBI-ERROR|XPATH syntax error", cb);
        if ctl.status != 0 && (syn || kob) && !cerr {
          v.d + "/index.php " + v.p + "='" + sc.tok + ": MySQL syntax error quoting the injected marker (HTTP " + qm.status + "), control " + v.p + "=" + sc.ctl + " without SQL error (HTTP " + ctl.status + ")"
        } else { "" }
      }
    store_as: fallback

  # ── Fallback report (no stage 1 proof in any dir / parameter) ─────────────
  - id: once
    action: set_var
    var_name: done
    var_value: true
    loop:
      var: o
      over: ["once"]

  - id: report-qm
    action: match
    source: fallback
    pattern: "MySQL syntax error quoting the injected marker"
    condition: 'fallback != ""'
    on_match:
      finding:
        title: "Dream4 Koobi CMS index.php SQL injection (CVE-2005-1373)"
        description: "A single quote sent in a parameter of Koobi CMS index.php broke the SQL query: the MySQL syntax error quotes the random text that followed it, while the same parameter without a quote caused no SQL error. The parameter reaches the query unescaped, so an unauthenticated attacker can run arbitrary SQL against the site database."
        remediation: "Koobi CMS is no longer maintained and no fixed 4.2.x release is documented: take the site offline or move to a maintained CMS. If you maintain the code, escape (or bind as query parameters) p and q in index.php, and do not print database errors to visitors."
        confidence_delta: 0.50
        qod: 75
        evidence: "Error-based SQLi: {{fallback}}"
      stop: true

View these feeds on GitHub