Upb — 1 vulnerability check

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

← All products · Feeds on GitHub

Ultimate PHP Board viewforum.php XSS and Path Disclosure

CVECVE-2005-1614, CVE-2005-1615, CVE-2005-1616
Severityhigh · CVSS 7.5
Categoryxss — XSS
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 75
Feedtests/vulnerabilities/upb/upb-viewforum-xss-path-disclosure.yaml

Ultimate PHP Board (UPB) 1.8 through 1.9.6 writes the postorder parameter of viewforum.php back into the page without escaping (cross-site scripting) and builds a data file name from the id parameter without checking it, so an unknown forum id makes the board print a PHP warning that discloses the installation path. The same parameter handling is also reported to expose board data (CVE-2005-1615).

This check requests index.php under the web root, /upb, /forum, /forums and /board and keeps the pages that show the UPB footer. It then requests viewforum.php with a random nine-digit forum id and a postorder value carrying a random HTML tag. Cross-site scripting is confirmed when that tag comes back unencoded; path disclosure is confirmed when the reply carries the file-open warning naming the random id and the server path of textdb.inc.php. When neither proof fires, a UPB footer reporting a version older than 1.9.7 is reported at a lower confidence. Nothing is written on the board.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET {{dir}}/index.php
  3. Parses / computes the next value with a Rhai script
  4. Parses / computes the next value with a Rhai script
  5. HTTP(S) request GET {{dir}}/viewforum.php?id={{sc.fid}}&postorder=%22%3E%3C{{sc.tag}}%3E
  6. Parses / computes the next value with a Rhai script
  7. Parses / computes the next value with a Rhai script
  8. HTTP(S) request GET {{dir}}/viewforum.php?id={{real_id}}&postorder=%22%3E%3C{{sc.tag}}%3E
  9. Parses / computes the next value with a Rhai script
  10. Parses / computes the next value with a Rhai script
  11. Checks hit_xss for ^/ → finding QoD 75: Ultimate PHP Board viewforum.php postorder Cross-Site Scripting (CVE-2005-1614)
  12. Checks hit_pd for ^/ → finding QoD 75: Ultimate PHP Board viewforum.php id Full Path Disclosure (CVE-2005-1616)
  13. Checks fallback for ^/ → finding QoD 70: Ultimate PHP Board < 1.9.7 Multiple Vulnerabilities (CVE-2005-1614, CVE-2005-1615, CVE-2005-1616)

References:

Feed source — tests/vulnerabilities/upb/upb-viewforum-xss-path-disclosure.yaml
# Ultimate PHP Board (UPB) 1.8 - 1.9.6 — viewforum.php postorder XSS and
# id full path disclosure — CVE-2005-1614 / CVE-2005-1615 / CVE-2005-1616
#
# UPB keeps its data in flat files handled by textdb.inc.php. viewforum.php
# builds the name of the forum's sorted topic file from the id parameter
# unchecked, so an unknown id makes textdb.inc.php print
#     Warning: fopen(./db/<id>_sorted.dat): failed to open stream: No such
#     file or directory in /home/.../forum/textdb.inc.php on line 246
# (CVE-2005-1616, full path disclosure), and the postorder parameter is
# written back into the page without escaping (CVE-2005-1614, XSS). The
# exposure of board data through postorder in textdb.inc.php (CVE-2005-1615,
# "possibly SQL injection" per its record) has no published reproducer; it
# is only reported by the version fallback. Every page ends with "Powered by UPB Version : <x.y.z>";
# 1.9.7 fixed the three.
#
# Detection, per install dir whose index.php carries the UPB footer, with one
# request viewforum.php?id=<random 9 digits>&postorder="><noctis<random>>:
#   QoD 75 (CVE-2005-1614) — the page carries the tag <noctis<random>> raw
#          (not HTML-encoded), i.e. postorder reaches the HTML unescaped.
#   QoD 75 (CVE-2005-1616) — the page carries the fopen() warning naming
#          ./db/<random id>_sorted.dat and a server path to textdb.inc.php.
#   Both can be reported for the same target (independent sinks). When the
#   unknown id gives no reflection (a board that stops before rendering the
#   sort links), the XSS probe is repeated once with the first real forum id
#   linked from index.php.
#   QoD 70 (all three CVEs) — neither proof fired anywhere, but a footer
#          reads UPB version < 1.9.7 (display_errors off and a filter on
#          viewforum.php, for instance).
#
# Better than the source NASL, which only reads the version footer of
# index.php: the two flaws are now proven in-band with random values (a
# server that is UPB 1.9.6 by its footer but no longer reflects/discloses
# gets the lower-QoD version finding only), each finding names the CVE it
# proves, and /upb, /forum, /forums and /board are probed as well as the
# web root (the NASL relies on the web crawler for sub-directories).
#
# Source: OpenVAS/Greenbone NVT pre2008/upd_xss_sql_injection.nasl
# (OID 1.3.6.1.4.1.25623.1.0.18260, GPL-2.0-only); Morinex advisory
# (Bugtraq 2005-05-13, "Ultimate PHP Board (UPB) Security Advisory").
uid: d9925c89-8aea-4405-be93-3b968fc2f1bf
name: "Ultimate PHP Board viewforum.php XSS and Path Disclosure (CVE-2005-1614, CVE-2005-1616)"
description: |
  Ultimate PHP Board (UPB) 1.8 through 1.9.6 writes the postorder parameter
  of viewforum.php back into the page without escaping (cross-site
  scripting) and builds a data file name from the id parameter without
  checking it, so an unknown forum id makes the board print a PHP warning
  that discloses the installation path. The same parameter handling is also
  reported to expose board data (CVE-2005-1615).

  This check requests index.php under the web root, /upb, /forum, /forums
  and /board and keeps the pages that show the UPB footer. It then requests
  viewforum.php with a random nine-digit forum id and a postorder value
  carrying a random HTML tag. Cross-site scripting is confirmed when that
  tag comes back unencoded; path disclosure is confirmed when the reply
  carries the file-open warning naming the random id and the server path of
  textdb.inc.php. When neither proof fires, a UPB footer reporting a version
  older than 1.9.7 is reported at a lower confidence. Nothing is written on
  the board.
cves: [CVE-2005-1614, CVE-2005-1615, CVE-2005-1616]
cvss: 7.5
severity: high
category: xss
confidence_base: 0.30
tags: [upb, ultimate-php-board, xss, path-disclosure, php]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2005-1614"
  - "https://nvd.nist.gov/vuln/detail/CVE-2005-1615"
  - "https://nvd.nist.gov/vuln/detail/CVE-2005-1616"
  - "http://marc.info/?l=bugtraq&m=111600262424876&w=2"
  - "https://www.securityfocus.com/bid/13621"
  - "https://www.securityfocus.com/bid/13622"
  # OpenVAS/Greenbone NASL pre2008/upd_xss_sql_injection.nasl (GPL-2.0-only)

steps:
  # ── Random forum id and tag ───────────────────────────────────────────────
  - id: gen-proof
    action: script
    code: |
      let fid = "" + rand_int(100000000, 999999999);
      let tag = "noctis" + rand_int(100000000, 999999999);
      #{ fid: fid,
         tag: tag,
         raw_tag: "<" + tag + ">",
         pd_re: "fopen\\(\\./db/" + fid + "_sorted\\.dat\\)[^\\n]{0,160}?\\s+in\\s+(?:<b>)?\\s*((?:[A-Za-z]:)?[/\\\\][^<>\\s]{0,200}textdb\\.inc\\.php)" }
    store_as: sc

  - id: init-xss
    action: set_var
    var_name: hit_xss
    var_value: ""

  - id: init-pd
    action: set_var
    var_name: hit_pd
    var_value: ""

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

  # ── Per candidate install dir (loop group) ────────────────────────────────
  - id: init-landing
    action: set_var
    var_name: landing
    var_value: {status: 0, body: ""}
    loop:
      var: dir
      over: ["", "/upb", "/forum", "/forums", "/board"]

  - id: init-is-upb
    action: set_var
    var_name: is_upb
    var_value: false

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

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

  - id: init-real-id
    action: set_var
    var_name: real_id
    var_value: ""

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

  - id: gate
    action: script
    condition: 'hit_xss == "" || hit_pd == ""'
    code: |
      let body = if type_of(landing.body) == "string" { landing.body } else { "" };
      landing.status == 200 && ereg("Powered by UPB Version", body, true)
    store_as: is_upb

  - id: keep-version
    action: script
    condition: 'is_upb == true'
    code: |
      let body = if type_of(landing.body) == "string" { landing.body } else { "" };
      let m = eregmatch("Powered by UPB Version\\s*:[^\\n0-9]{0,80}(0\\.[0-9][0-9.]*|1\\.[0-8](?:\\.[0-9]+)*|1\\.9(?:\\.[1-6])?)(?:[^0-9.]|$)", body, true);
      if fallback == "" && m.len() > 1 {
        (if dir == "" { "/" } else { dir }) + " (version " + m[1] + ")"
      } else { fallback }
    store_as: fallback

  - id: probe-viewforum
    action: http_request
    method: GET
    path: "{{dir}}/viewforum.php?id={{sc.fid}}&postorder=%22%3E%3C{{sc.tag}}%3E"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 15
    condition: 'is_upb == true'
    store_as: probe

  - id: check-xss
    action: script
    condition: 'is_upb == true && hit_xss == ""'
    code: |
      let body = if type_of(probe.body) == "string" { probe.body } else { "" };
      if probe.status == 200 && stridx(body, sc.raw_tag) >= 0 {
        if dir == "" { "/" } else { dir }
      } else { "" }
    store_as: hit_xss

  - id: find-real-id
    action: script
    condition: 'is_upb == true && hit_xss == ""'
    code: |
      let body = if type_of(landing.body) == "string" { landing.body } else { "" };
      let m = eregmatch("viewforum\\.php\\?id=([0-9]{1,9})", body);
      if m.len() > 1 && m[1] != sc.fid { m[1] } else { "" }
    store_as: real_id

  - id: probe-viewforum-real-id
    action: http_request
    method: GET
    path: "{{dir}}/viewforum.php?id={{real_id}}&postorder=%22%3E%3C{{sc.tag}}%3E"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 15
    condition: 'is_upb == true && hit_xss == "" && real_id != ""'
    store_as: probe2

  - id: check-xss-real-id
    action: script
    condition: 'is_upb == true && hit_xss == "" && real_id != ""'
    code: |
      let body = if type_of(probe2.body) == "string" { probe2.body } else { "" };
      if probe2.status == 200 && stridx(body, sc.raw_tag) >= 0 {
        (if dir == "" { "/" } else { dir }) + " (forum id " + real_id + ")"
      } else { "" }
    store_as: hit_xss

  - id: check-pd
    action: script
    condition: 'is_upb == true && hit_pd == ""'
    code: |
      let body = if type_of(probe.body) == "string" { probe.body } else { "" };
      let m = eregmatch(sc.pd_re, body, true);
      if m.len() > 1 {
        (if dir == "" { "/" } else { dir }) + " (path " + m[1] + ")"
      } else { "" }
    store_as: hit_pd

  # ── Findings (run once, after every dir was tried) ────────────────────────
  # A step carrying its own loop: closes the per-dir loop group above, so the
  # report steps below run once with the verdicts of all dirs.
  - id: report-once
    action: set_var
    var_name: reported
    var_value: true
    loop:
      var: pass
      over: ["once"]

  - id: report-xss
    action: match
    source: hit_xss
    pattern: "^/"
    on_match:
      finding:
        title: "Ultimate PHP Board viewforum.php postorder Cross-Site Scripting (CVE-2005-1614)"
        description: "A request to viewforum.php with a postorder value carrying a random HTML tag returned that tag unencoded: postorder is written into the page without escaping, so a crafted link runs attacker script in the browser of any board user who follows it, including administrators."
        remediation: "Upgrade Ultimate PHP Board to 1.9.7 or later, or replace it: the 1.x branch is no longer maintained."
        cves: [CVE-2005-1614]
        cvss: 6.8
        severity: medium
        confidence_delta: 0.50
        qod: 75
        evidence: "install dir {{hit_xss}}: viewforum.php?postorder=\"><{{sc.tag}}> returned the tag <{{sc.tag}}> unencoded"

  - id: report-pd
    action: match
    source: hit_pd
    pattern: "^/"
    on_match:
      finding:
        title: "Ultimate PHP Board viewforum.php id Full Path Disclosure (CVE-2005-1616)"
        description: "A request to viewforum.php with a random unknown forum id returned a PHP fopen() warning naming the data file built from that id and the server path of textdb.inc.php: the id parameter is used to build a file name without validation and PHP errors are shown to visitors, which discloses the installation path."
        remediation: "Upgrade Ultimate PHP Board to 1.9.7 or later, or replace it: the 1.x branch is no longer maintained. Set display_errors to Off in php.ini."
        cves: [CVE-2005-1616]
        cvss: 7.5
        severity: high
        confidence_delta: 0.50
        qod: 75
        evidence: "install dir {{hit_pd}}: viewforum.php?id={{sc.fid}} returned a fopen(./db/{{sc.fid}}_sorted.dat) warning disclosing the server path"

  - id: report-version
    action: match
    source: fallback
    pattern: "^/"
    condition: 'hit_xss == "" && hit_pd == ""'
    on_match:
      finding:
        title: "Ultimate PHP Board < 1.9.7 Multiple Vulnerabilities (CVE-2005-1614, CVE-2005-1615, CVE-2005-1616)"
        description: "The board footer reports an Ultimate PHP Board version older than 1.9.7. Those versions write the postorder parameter of viewforum.php into the page unescaped (cross-site scripting), are reported to expose board data through the same parameter, and disclose the installation path on an unknown forum id. The in-band probes did not confirm the flaws on this host."
        remediation: "Upgrade Ultimate PHP Board to 1.9.7 or later, or replace it: the 1.x branch is no longer maintained."
        confidence_delta: 0.40
        qod: 70
        evidence: "install dir {{fallback}}: footer \"Powered by UPB Version\" older than 1.9.7"

View these feeds on GitHub