JGS-Portal — 1 vulnerability check

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

← All products · Feeds on GitHub

JGS-Portal jgs_portal_statistik.php 'year' SQL Injection

CVECVE-2005-1633
Severityhigh · CVSS 7.5
Categorysqli — SQL injection
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 97
Feedtests/vulnerabilities/jgs-portal/CVE-2005-1633.yaml

Tests the JGS-Portal add-on for WoltLab Burning Board 2 (3.0.2 and earlier) for the unauthenticated SQL injection through the year parameter of jgs_portal_statistik.php. In the web root and in the /wbb2, /wbb, /forum and /board directories, once the statistics page answers a plain request without a database error, the feed sends a year value that makes the database raise an XPath error carrying the product of two random numbers, first as a bare number and then inside quotes. The correct product in the board's database error page confirms that the database ran the injected expression; the product is not part of the request, so a page that only echoes the URL is not reported. On databases without the EXTRACTVALUE function, the feed instead reports the board's database error page showing the statistics query and a MySQL syntax error after a single quote is appended to year, provided the plain request showed no such error. The probes read no table row and change nothing.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. Parses / computes the next value with a Rhai script
  3. HTTP(S) request GET {{dir}}/jgs_portal_statistik.php?meinaction=themen&month=1&year=1
  4. Parses / computes the next value with a Rhai script
  5. HTTP(S) request GET {{dir}}/jgs_portal_statistik.php?meinaction=themen&month=1&year=1%20AND%20extractvalu…
  6. Parses / computes the next value with a Rhai script
  7. HTTP(S) request GET {{dir}}/jgs_portal_statistik.php?meinaction=themen&month=1&year=1%27%20AND%20extractv…
  8. Parses / computes the next value with a Rhai script
  9. Checks proof for ^XPATH syntax error: ~[0-9]+$ → finding QoD 97: JGS-Portal jgs_portal_statistik.php 'year' SQL Injection (CVE-2005-1633)
  10. HTTP(S) request GET {{dir}}/jgs_portal_statistik.php?meinaction=themen&month=1&year=1%27{{m.tag}}
  11. Parses / computes the next value with a Rhai script
  12. Checks syn for ^SQL-DATABASE ERROR quoting Noctis[a-zA-Z0-9]+$ → finding QoD 75: JGS-Portal jgs_portal_statistik.php 'year' SQL Injection (CVE-2005-1633)

References:

Feed source — tests/vulnerabilities/jgs-portal/CVE-2005-1633.yaml
# JGS-XA JGS-Portal <= 3.0.2 jgs_portal_statistik.php 'year' SQL injection — CVE-2005-1633
#
# JGS-Portal is a portal add-on for WoltLab Burning Board 2. Its statistics page
# jgs_portal_statistik.php pastes the raw year GET value into
#   SELECT starttime FROM bb<n>_threads WHERE FROM_UNIXTIME(...) ...
# and the Burning Board database class dies with its "SQL-DATABASE ERROR" page,
# which carries the failing query and mysql_error() (inside an HTML comment
# when the board hides errors — still in the response body). Public advisory:
# SePro / Security-Project, 2005-05-09 (BID 13650, EDB 25673).
# The JGS-Portal source is no longer published, so the context of the value
# (bare number or inside quotes) is not known: both are probed.
#
# Detection (benign, read-only), per candidate install directory
# ("", /wbb2, /wbb, /forum, /board):
#   1. Control: GET <dir>/jgs_portal_statistik.php?meinaction=themen&month=1&year=1
#      must answer 200 without an SQL-DATABASE ERROR page (also gates the probes:
#      nothing is injected into a server without the page).
#   2. year=1 AND extractvalue(1,concat(0x7e,<a>*<b>)) (numeric context) then,
#      if nothing showed, year=1' AND extractvalue(1,concat(0x7e,<a>*<b>)) AND '1'='1
#      (quoted context). MySQL raises "XPATH syntax error: '~<a×b>'", printed in
#      the error page. The product of two random 6-digit operands is not in the
#      request, so a page that echoes the URL (the error page itself prints
#      REQUEST_URI) cannot produce it. MySQL folds the constant: no row is read.
#      QoD 97.
#   3. Fallback (MySQL < 5.1 has no EXTRACTVALUE): year=1'<marker> must return the
#      Burning Board "SQL-DATABASE ERROR" page quoting the statistics query
#      (SELECT starttime FROM bb<n>_threads WHERE FROM_UNIXTIME) and a MySQL
#      syntax error, while the control showed no such page. QoD 75.
#
# Improvements over the source NASL: a database-computed proof (QoD 97), an
# error-free control request, any bb<n>_ table prefix (not only bb1_), and the
# usual board directories besides the web root.
#
# CVE mapping: the issue lists CVE-2005-1633/1634/1635. Only CVE-2005-1633 (the
# SQL injections) is proven here; CVE-2005-1634 (XSS through the same values) and
# CVE-2005-1635 (path disclosure on direct requests) are other bugs.
# CVSS: CVE-2005-1633 v2 7.5 (NVD has no v3 score).
#
# Ported from OpenVAS/Greenbone NVT pre2008/jgsportal_sql.nasl
# (OID 1.3.6.1.4.1.25623.1.0.18289, GPL-2.0-only).
uid: c5fa8638-7611-4136-b543-d5f3474c87c7
name: "JGS-Portal jgs_portal_statistik.php 'year' SQL Injection (CVE-2005-1633)"
description: |
  Tests the JGS-Portal add-on for WoltLab Burning Board 2 (3.0.2 and earlier)
  for the unauthenticated SQL injection through the year parameter of
  jgs_portal_statistik.php. In the web root and in the /wbb2, /wbb, /forum and
  /board directories, once the statistics page answers a plain request without
  a database error, the feed sends a year value that makes the database raise
  an XPath error carrying the product of two random numbers, first as a bare
  number and then inside quotes. The correct product in the board's database
  error page confirms that the database ran the injected expression; the
  product is not part of the request, so a page that only echoes the URL is not
  reported. On databases without the EXTRACTVALUE function, the feed instead
  reports the board's database error page showing the statistics query and a
  MySQL syntax error after a single quote is appended to year, provided the
  plain request showed no such error. The probes read no table row and change
  nothing.
cves: [CVE-2005-1633]
cvss: 7.5
severity: high
category: sqli
confidence_base: 0.30
tags: [jgs-portal, woltlab, burning-board, php, mysql, sqli, error-based, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2005-1633"
  - "https://www.exploit-db.com/exploits/25673"
  - "https://www.securityfocus.com/bid/13650/info"
  - "http://marc.info/?l=bugtraq&m=111627681218415&w=2"
  # OpenVAS/Greenbone NASL pre2008/jgsportal_sql.nasl (GPL-2.0-only)

steps:
  # Random operands and marker; the expected proof is computed locally.
  - id: mint
    action: script
    code: '#{ a: rand_int(100000, 999999), b: rand_int(100000, 999999), tag: "Noctis" + rand_str(10) }'
    store_as: m

  - id: mint-product
    action: script
    code: '"" + (m.a * m.b)'
    store_as: prod

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

  # ── Loop group: every step below runs once per candidate install dir ─────
  - id: init-ctl-r
    action: set_var
    var_name: ctl_r
    var_value: {status: 0, body: ""}
    loop:
      over: ["", "/wbb2", "/wbb", "/forum", "/board"]
      var: dir

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

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

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

  - id: control
    action: http_request
    method: GET
    path: "{{dir}}/jgs_portal_statistik.php?meinaction=themen&month=1&year=1"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    condition: 'proof == ""'
    store_as: ctl_r

  - id: gate
    action: script
    code: |
      proof == "" && ctl_r.status == 200 && type_of(ctl_r.body) == "string" && stridx(ctl_r.body, "SQL-DATABASE ERROR") < 0 && stridx(ctl_r.body, "XPATH syntax error") < 0
    store_as: ok

  # Numeric context: year=1 AND extractvalue(1,concat(0x7e,<a>*<b>))
  - id: inject-numeric
    action: http_request
    method: GET
    path: "{{dir}}/jgs_portal_statistik.php?meinaction=themen&month=1&year=1%20AND%20extractvalue(1,concat(0x7e,{{m.a}}*{{m.b}}))"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    condition: 'ok == true'
    store_as: num_r

  # The error text may be HTML-escaped by a front end; accept the quote in any
  # common form, or none.
  - id: verdict-numeric
    action: script
    code: |
      if ok == true && type_of(num_r.body) == "string" && egrep("XPATH syntax error: (?:'|&#0?39;|&#x27;|&apos;)?~" + prod + "(?:[^0-9]|$)", num_r.body) != "" { "XPATH syntax error: ~" + prod } else { proof }
    store_as: proof

  # Quoted context: year=1' AND extractvalue(...) AND '1'='1
  - id: inject-quoted
    action: http_request
    method: GET
    path: "{{dir}}/jgs_portal_statistik.php?meinaction=themen&month=1&year=1%27%20AND%20extractvalue(1,concat(0x7e,{{m.a}}*{{m.b}}))%20AND%20%271%27=%271"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    condition: 'ok == true && proof == ""'
    store_as: quo_r

  - id: verdict-quoted
    action: script
    code: |
      if proof == "" && ok == true && type_of(quo_r.body) == "string" && egrep("XPATH syntax error: (?:'|&#0?39;|&#x27;|&apos;)?~" + prod + "(?:[^0-9]|$)", quo_r.body) != "" { "XPATH syntax error: ~" + prod } else { proof }
    store_as: proof

  - id: report-xpath
    action: match
    source: proof
    pattern: "^XPATH syntax error: ~[0-9]+$"
    on_match:
      finding:
        title: "JGS-Portal jgs_portal_statistik.php 'year' SQL Injection (CVE-2005-1633)"
        description: "An unauthenticated GET to jgs_portal_statistik.php with SQL appended to the year parameter made the database compute the product of two random numbers, which came back in the board's database error page. Any query the board's database user may run can be injected the same way, including reading the forum accounts and their password hashes."
        remediation: "JGS-Portal is no longer maintained. Remove the portal add-on (its jgs_portal*.php files) from the board, or restrict access to it."
        confidence_delta: 0.65
        qod: 97
        evidence: "GET {{dir}}/jgs_portal_statistik.php with an injected year computing {{m.a}}*{{m.b}} returned the database-computed result: {{proof}}"
      stop: true

  # Fallback for MySQL < 5.1: the board's SQL error page quoting the statistics
  # query, while the control showed none.
  - id: inject-marker
    action: http_request
    method: GET
    path: "{{dir}}/jgs_portal_statistik.php?meinaction=themen&month=1&year=1%27{{m.tag}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    condition: 'ok == true && proof == ""'
    store_as: mark_r

  - id: verdict-marker
    action: script
    code: |
      if proof == "" && ok == true && type_of(mark_r.body) == "string" && stridx(mark_r.body, "SQL-DATABASE ERROR") >= 0 && egrep("SELECT starttime FROM bb[0-9]+_threads WHERE FROM_UNIXTIME", mark_r.body) != "" && egrep("SQL syntax.{0,300}" + m.tag, mark_r.body) != "" { "SQL-DATABASE ERROR quoting " + m.tag } else { "" }
    store_as: syn

  - id: report-syntax
    action: match
    source: syn
    pattern: "^SQL-DATABASE ERROR quoting Noctis[a-zA-Z0-9]+$"
    on_match:
      finding:
        title: "JGS-Portal jgs_portal_statistik.php 'year' SQL Injection (CVE-2005-1633)"
        description: "An unauthenticated GET to jgs_portal_statistik.php with a single quote and a random marker in the year parameter returned the board's database error page showing the statistics query and a MySQL syntax error quoting the marker, while the same page with a plain year showed no error: the parameter is pasted into the query unescaped. Any query the board's database user may run can be injected the same way."
        remediation: "JGS-Portal is no longer maintained. Remove the portal add-on (its jgs_portal*.php files) from the board, or restrict access to it."
        confidence_delta: 0.50
        qod: 75
        evidence: "GET {{dir}}/jgs_portal_statistik.php?meinaction=themen&month=1&year=1'{{m.tag}} returned SQL-DATABASE ERROR with the statistics query and a MySQL syntax error quoting {{m.tag}}; the same page with year=1 returned status {{ctl_r.status}} with no SQL error"
      stop: true

View these feeds on GitHub