SQL-Ledger — 2 vulnerability checks

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

← All products · Feeds on GitHub

SQL-Ledger Administration Interface Accessible Without Password

CVECVE-2009-4402
Severityhigh · CVSS 7.5
Categoryauth-bypass — Auth bypass
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 97
Feedtests/vulnerabilities/sql-ledger/CVE-2009-4402.yaml

Tests whether the SQL-Ledger administration script, admin.pl, runs its functions for a request that does not know the administrator password, which is the case while the "root login" password is still empty, as after installation. In the /sql-ledger, /SQL-Ledger and /ledger directories and in the web root, the feed requests admin.pl with action=list_users (SQL-Ledger 2.x) and, when that does not answer, action=list_datasets (SQL-Ledger 3.x), each with a random password. The finding is reported when the reply is the administration panel itself (an admin page with the user or dataset list table and no password field), and when a request for a random, non-existent action does not return that same page, so a site that answers every request with one page is not reported. A protected install answers with a password prompt instead. The probe only lists users or datasets and changes nothing.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET {{dir}}/admin.pl?action=list_users&path=bin/mozilla&password={{rnd.pw}}
  3. HTTP(S) request GET {{dir}}/admin.pl?action=list_datasets&path=bin/mozilla&password={{rnd.pw}}
  4. Parses / computes the next value with a Rhai script
  5. HTTP(S) request GET {{dir}}/admin.pl?action={{rnd.act}}&path=bin/mozilla&password={{rnd.pw}}
  6. Parses / computes the next value with a Rhai script
  7. Checks proof for ^SQL-Ledger admin\.pl served .+ without the administrator password$ → finding QoD 97: SQL-Ledger Administration Interface Accessible Without Password (CVE-2009-4402)

References:

Feed source — tests/vulnerabilities/sql-ledger/CVE-2009-4402.yaml
# SQL-Ledger administration interface open without a root password — CVE-2009-4402
#
# SQL-Ledger's admin.pl (bin/mozilla/admin.pl, check_password) only checks the
# password of the "root login" member when that password is set. A fresh
# install writes users/members with "[root login] password=" (empty), so until
# the administrator sets one, admin.pl runs any action for any (or no)
# password: user / dataset administration, database creation and deletion,
# system lock, changing the admin password. The check is unchanged in every
# upstream release up to the 3.2 series, so the condition is reported on any
# version, not only 2.8.24.
#
# Detection (read-only), per candidate install dir (/sql-ledger, /SQL-Ledger,
# /ledger, web root):
#   1. GET <dir>/admin.pl?action=list_users&path=bin/mozilla&password=<random>
#      (2.x panel; 3.x has no such sub and dies, so retry with
#      action=list_datasets). The reply must be the administration panel:
#      200, <body class=admin>, "listheading" table rows and no password
#      input. A protected install answers the "Password / Continue" page
#      (getpassword) instead. These actions only list members / datasets; the
#      "login" action is avoided because it writes a session key file.
#   2. Control: the same request with a random action name must NOT return
#      the panel (real admin.pl dies on an unknown sub), so a front end that
#      serves one page for every URL is not reported.
#   Every request sends a browser User-Agent (without "lynx"): SQL-Ledger
#   picks its HTML terminal and prints its page head only when one is present.
#   Known gap: 3.0.00-3.0.07 with a non-English admin locale has no
#   list_datasets translation entry and is not reported.
#   QoD 97: the administration functions themselves are served.
#
# Improvements over the source NASL (version <= 2.8.24 from the login page):
#   - proves the unauthenticated admin access instead of inferring it from
#     the version; installs whose administrator set a password are not
#     reported, and later releases with an empty root password are.
#
# CVSS: NVD v2 7.5 (no v3 score published).
#
# Ported from OpenVAS/Greenbone NVT 2009/gb_sql_ledger_mult_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.902010, GPL-2.0-only); the other CVEs of that
# NVT are covered by sql-ledger-2-8-24-multiple-vulnerabilities.yaml.
uid: 364aa171-4030-4f0f-bb63-61570477482a
name: "SQL-Ledger Administration Interface Accessible Without Password (CVE-2009-4402)"
description: |
  Tests whether the SQL-Ledger administration script, admin.pl, runs its
  functions for a request that does not know the administrator password,
  which is the case while the "root login" password is still empty, as after
  installation. In the /sql-ledger, /SQL-Ledger and /ledger directories and in
  the web root, the feed requests admin.pl with action=list_users (SQL-Ledger
  2.x) and, when that does not answer, action=list_datasets (SQL-Ledger 3.x),
  each with a random password. The finding is reported when the reply is the
  administration panel itself (an admin page with the user or dataset list
  table and no password field), and when a request for a random, non-existent
  action does not return that same page, so a site that answers every request
  with one page is not reported. A protected install answers with a password
  prompt instead. The probe only lists users or datasets and changes nothing.
cves: [CVE-2009-4402]
cvss: 7.5
severity: high
category: auth-bypass
confidence_base: 0.30
tags: [sql-ledger, perl, erp, auth-bypass, admin-panel, empty-password]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2009-4402"
  - "https://github.com/Tekki/sql-ledger/blob/v2.8.24/bin/mozilla/admin.pl"
  # OpenVAS/Greenbone NASL 2009/gb_sql_ledger_mult_vuln.nasl (GPL-2.0-only)

steps:
  - id: mint
    action: script
    code: '#{ pw: "noctis" + rand_hex(6), act: "noctis" + rand_hex(6) }'
    store_as: rnd

  # ── Loop group: every step below runs once per candidate install dir ─────
  - id: init-v2
    action: set_var
    var_name: v2
    var_value: {status: 0, body: ""}
    loop:
      over: ["/sql-ledger", "/SQL-Ledger", "/ledger", ""]
      var: dir

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

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

  - id: list-users
    action: http_request
    method: GET
    path: "{{dir}}/admin.pl?action=list_users&path=bin/mozilla&password={{rnd.pw}}"
    port: "{{port}}"
    headers:
      User-Agent: "Mozilla/5.0 (compatible; noctis)"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    store_as: v2

  # SQL-Ledger 3.x renamed the panel sub to list_datasets.
  - id: list-datasets
    action: http_request
    method: GET
    path: "{{dir}}/admin.pl?action=list_datasets&path=bin/mozilla&password={{rnd.pw}}"
    port: "{{port}}"
    headers:
      User-Agent: "Mozilla/5.0 (compatible; noctis)"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    condition: 'v2.status != 200 || egrep("(?i)<body class=admin", v2.body) == ""'
    store_as: v3

  # The administration panel: admin body, list table, and no password field
  # (the getpassword page and the admin login screen both carry one).
  - id: panel
    action: script
    store_as: hit
    code: |
      let pick = "";
      for r in [v2, v3] {
        if pick == "" && r.status == 200 && type_of(r.body) == "string"
            && egrep("(?i)<body class=admin", r.body) != ""
            && egrep("(?i)class=listheading", r.body) != ""
            && egrep("(?i)type=password", r.body) == "" {
          pick = r.body;
        }
      }
      if pick == "" { #{ ok: false, what: "" } } else {
        let what = "the administration panel";
        if egrep("Change Admin Password", pick) != "" { what = "the user administration panel (Add User / Change Admin Password)"; }
        else if egrep("Add Dataset", pick) != "" { what = "the dataset administration panel (Add Dataset / Change Password)"; }
        #{ ok: true, what: what }
      }

  - id: control
    action: http_request
    method: GET
    path: "{{dir}}/admin.pl?action={{rnd.act}}&path=bin/mozilla&password={{rnd.pw}}"
    port: "{{port}}"
    headers:
      User-Agent: "Mozilla/5.0 (compatible; noctis)"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    condition: 'hit.ok == true'
    store_as: ctl

  - id: verdict
    action: script
    store_as: proof
    code: |
      let ctl_hit = ctl.status == 200 && type_of(ctl.body) == "string"
        && egrep("(?i)<body class=admin", ctl.body) != ""
        && egrep("(?i)class=listheading", ctl.body) != "";
      if hit.ok == true && ctl.status != 0 && !ctl_hit { "SQL-Ledger admin.pl served " + hit.what + " without the administrator password" } else { "" }

  - id: report
    action: match
    source: proof
    pattern: "^SQL-Ledger admin\\.pl served .+ without the administrator password$"
    on_match:
      finding:
        title: "SQL-Ledger Administration Interface Accessible Without Password (CVE-2009-4402)"
        description: "The SQL-Ledger administration script admin.pl ran an administrative action for a request carrying a random password: the administrator (\"root login\") password is not set. Anyone who can reach the site can add or edit users and datasets, create or delete databases, lock the system and set the administrator password."
        remediation: "Log in to admin.pl and set an administrator password with \"Change Admin Password\" (\"Change Password\" in SQL-Ledger 3.x) right after installation, and restrict access to admin.pl (for example by IP address or HTTP authentication in the web server)."
        confidence_delta: 0.65
        qod: 97
        evidence: "GET {{dir}}/admin.pl with a random password returned HTTP 200 with {{hit.what}} and no password prompt; a request for the random action {{rnd.act}} did not return that page."
      stop: true

SQL-Ledger <= 2.8.24 Multiple Vulnerabilities (Version Check)

CVECVE-2009-3580, CVE-2009-3581, CVE-2009-3582, CVE-2009-3583, CVE-2009-3584
Severitymedium · CVSS 6.8
Categorysqli — SQL injection
Serviceshttp, https
Detectionset_var, http_request, script, match · highest QoD 70
Feedtests/vulnerabilities/sql-ledger/sql-ledger-2-8-24-multiple-vulnerabilities.yaml

Reports SQL-Ledger installations at version 2.8.24 or earlier, which are affected by cross-site request forgery on the password change, stored cross-site scripting, SQL injection in the vendor delete action, local file inclusion through the countrycode preference and a session cookie sent without the secure flag. In the /sql-ledger, /SQL-Ledger and /ledger directories and in the web root, the feed requests login.pl and reads the version from the SQL-Ledger login screen (page title "SQL-Ledger" and the "Version X.Y.Z" heading). The finding is reported when that version is 2.8.24 or lower. These flaws can only be triggered by a logged-in user, so the result rests on the version shown and is not confirmed by an exploit. The probe only reads the login page.

How noctis detects it

  1. HTTP(S) request GET {{dir}}/login.pl
  2. Parses / computes the next value with a Rhai script
  3. Checks proof for ^SQL-Ledger version \d+\.\d+\.\d+$ → finding QoD 70: SQL-Ledger <= 2.8.24 Multiple Vulnerabilities (Version Check)

References:

Feed source — tests/vulnerabilities/sql-ledger/sql-ledger-2-8-24-multiple-vulnerabilities.yaml
# SQL-Ledger <= 2.8.24 multiple vulnerabilities — CVE-2009-3580, CVE-2009-3581,
# CVE-2009-3582, CVE-2009-3583, CVE-2009-3584
#
#   CVE-2009-3580  CSRF in am.pl (password change via a preferences action)
#   CVE-2009-3581  stored XSS (AR/AP descriptions, customer/vendor names)
#   CVE-2009-3582  SQL injection in the vendor delete subroutine (id, db)
#   CVE-2009-3583  local file inclusion through the Preferences countrycode
#   CVE-2009-3584  session cookie without the secure flag over https
#
# Every one of these needs a logged-in SQL-Ledger user and a write (a
# preference save, a DELETE, a stored record) or a victim's browser: there is
# no unauthenticated, non-intrusive way to trigger them. The feed therefore
# reports the vulnerable version (QoD 70, version check only), read from the
# login screen every SQL-Ledger release shows:
#   <title>SQL-Ledger Version</title> ... <h1 class=login ...>Version 2.8.24
# (bin/mozilla/login.pl, login_screen), in /sql-ledger, /SQL-Ledger, /ledger
# and the web root, with a browser User-Agent (without one, login.pl answers
# "Unknown terminal" and prints no page head). The admin interface left without a password
# (CVE-2009-4402, same NVT) is proven by CVE-2009-4402.yaml.
#
# Fixed version: NVD lists 2.8.24 as the vulnerable release; 2.8.25
# (Oct 2009) is the next one. Versions are compared numerically.
#
# CVSS: NVD v2, highest of the five (CVE-2009-3580, 6.8); no v3 scores published.
#
# Ported from OpenVAS/Greenbone NVT 2009/gb_sql_ledger_mult_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.902010, GPL-2.0-only).
uid: d3a57528-aa84-482f-8982-b980bc021f47
name: "SQL-Ledger <= 2.8.24 Multiple Vulnerabilities (Version Check)"
description: |
  Reports SQL-Ledger installations at version 2.8.24 or earlier, which are
  affected by cross-site request forgery on the password change, stored
  cross-site scripting, SQL injection in the vendor delete action, local file
  inclusion through the countrycode preference and a session cookie sent
  without the secure flag. In the /sql-ledger, /SQL-Ledger and /ledger
  directories and in the web root, the feed requests login.pl and reads the
  version from the SQL-Ledger login screen (page title "SQL-Ledger" and the
  "Version X.Y.Z" heading). The finding is reported when that version is
  2.8.24 or lower. These flaws can only be triggered by a logged-in user, so
  the result rests on the version shown and is not confirmed by an exploit.
  The probe only reads the login page.
cves: [CVE-2009-3580, CVE-2009-3581, CVE-2009-3582, CVE-2009-3583, CVE-2009-3584]
cvss: 6.8
severity: medium
category: sqli
confidence_base: 0.30
tags: [sql-ledger, perl, erp, version-check, sqli, xss, csrf, lfi]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2009-3580"
  - "https://nvd.nist.gov/vuln/detail/CVE-2009-3581"
  - "https://nvd.nist.gov/vuln/detail/CVE-2009-3582"
  - "https://nvd.nist.gov/vuln/detail/CVE-2009-3583"
  - "https://nvd.nist.gov/vuln/detail/CVE-2009-3584"
  - "https://github.com/Tekki/sql-ledger/blob/v2.8.24/bin/mozilla/login.pl"
  # OpenVAS/Greenbone NASL 2009/gb_sql_ledger_mult_vuln.nasl (GPL-2.0-only)

steps:
  # ── Loop group: every step below runs once per candidate install dir ─────
  - id: init-page
    action: set_var
    var_name: page
    var_value: {status: 0, body: ""}
    loop:
      over: ["/sql-ledger", "/SQL-Ledger", "/ledger", ""]
      var: dir

  - id: fetch-login
    action: http_request
    method: GET
    path: "{{dir}}/login.pl"
    port: "{{port}}"
    headers:
      User-Agent: "Mozilla/5.0 (compatible; noctis)"
    tls_insecure: true
    timeout_secs: 15
    store_as: page

  - id: version
    action: script
    store_as: proof
    code: |
      let out = "";
      if page.status == 200 && type_of(page.body) == "string"
          && egrep("(?i)<title>[^<]*SQL-Ledger", page.body) != "" {
        let m = eregmatch("(?i)<h1 class=login[^>]*>\\s*[^<0-9]{0,40}?(\\d+)\\.(\\d+)\\.(\\d+)", page.body);
        if type_of(m) == "array" && m.len() == 4 {
          let a = parse_int(m[1]);
          let b = parse_int(m[2]);
          let c = parse_int(m[3]);
          if a < 2 || (a == 2 && b < 8) || (a == 2 && b == 8 && c <= 24) {
            out = "SQL-Ledger version " + m[1] + "." + m[2] + "." + m[3];
          }
        }
      }
      out

  - id: report
    action: match
    source: proof
    pattern: "^SQL-Ledger version \\d+\\.\\d+\\.\\d+$"
    on_match:
      finding:
        title: "SQL-Ledger <= 2.8.24 Multiple Vulnerabilities (Version Check)"
        description: "The SQL-Ledger login screen reports version 2.8.24 or earlier. These releases are affected by cross-site request forgery on the password change (CVE-2009-3580), stored cross-site scripting (CVE-2009-3581), SQL injection in the vendor delete action (CVE-2009-3582), local file inclusion through the countrycode preference (CVE-2009-3583) and a session cookie without the secure flag (CVE-2009-3584). The result is based on the reported version only."
        remediation: "Upgrade SQL-Ledger to a release later than 2.8.24, serve it over HTTPS only and limit access to trusted users."
        confidence_delta: 0.45
        qod: 70
        evidence: "GET {{dir}}/login.pl returned the SQL-Ledger login screen showing {{proof}}"
      stop: true

View these feeds on GitHub