TeamPass — 1 vulnerability check

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

← All products · Feeds on GitHub

TeamPass < 2.1.20 upload.files.php access-control bypass

CVECVE-2014-3772
Severityhigh · CVSS 7.5
Categoryauth-bypass — Auth bypass
Serviceshttp, https
Detectionscript, set_var, tcp_connect, http_request, match · highest QoD 97
Feedtests/vulnerabilities/teampass/CVE-2014-3772.yaml

Tests TeamPass before 2.1.20 for the access-control bypass in sources/upload/upload.files.php (CVE-2014-3772): the upload handler only checks a session flag that index.php sets for every anonymous visitor. The test loads index.php to obtain an anonymous session (the session cookies it sets), requests upload.files.php once without cookies as a control, then again with the anonymous session and a file name too long to be created, so no file is created. A JSON-RPC reply from the upload handler to the anonymous session, while the control was refused with "Hacking attempt...", confirms the bypass. The web root, /teampass and /TeamPass are tried.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. Raw TCP (TLS on HTTPS), sent verbatim: GET {{base}}/index.php HTTP/1.0
  3. Parses / computes the next value with a Rhai script
  4. HTTP(S) request GET {{base}}/sources/upload/upload.files.php?PHPSESSID=&name={{m.name}}
  5. HTTP(S) request GET {{base}}/sources/upload/upload.files.php?PHPSESSID=&name={{m.name}}
  6. Parses / computes the next value with a Rhai script
  7. Checks v.reply for JSON-RPC → finding QoD 97: TeamPass upload.files.php access-control bypass (CVE-2014-3772)
  8. Checks v.reply for JSON-RPC → finding QoD 75: TeamPass upload.files.php reachable without login (CVE-2014-3772)

References:

Feed source — tests/vulnerabilities/teampass/CVE-2014-3772.yaml
# TeamPass < 2.1.20 — upload.files.php session access-control bypass (CVE-2014-3772)
#
# index.php sets $_SESSION['CPM'] = 1 for every visitor, logged in or not. Up to 2.1.19,
# sources/upload/upload.files.php only checked that CPM flag after session_start(), so an
# anonymous visitor who first loads index.php (which hands out the PHPSESSID cookie) can
# run the plupload handler. 2.1.20 also requires user_id and key in the session and calls
# checkUser(), so an anonymous session gets "Hacking attempt...". 2.1.20 (and its betas)
# also moved to an encrypted session handler (sources/sessions.php) that needs a second
# cookie, KEY_PHPSESSID, to read the session back: the feed sends back every cookie
# index.php set, so both the plain 2.1.19 sessions and the encrypted ones work.
#
# Detection, per candidate base ("", /teampass, /TeamPass):
#   1. GET index.php over raw TCP: every Set-Cookie header is needed (http_request keeps
#      only the last one). No cookie → not a TeamPass session page, stop.
#   2. Control: upload.files.php without cookies → "Hacking attempt..." (the CPM gate).
#   3. Probe: the same request with the index.php cookies. A vulnerable server runs the
#      handler and answers with a plupload JSON-RPC reply. The source check (which this
#      request follows: GET ?PHPSESSID=) sends no file name, so the handler creates an
#      empty ".part" file in the upload folder; this feed sends a 300-character file name
#      instead, so fopen() fails ("File name too long") and the handler answers JSON-RPC
#      error 102 without creating a file. Before that fopen() the handler runs its normal
#      housekeeping (mkdir of a missing upload folder, removal of *.part leftovers older
#      than 5 hours). Error 100 (upload folder unusable) and the "result" reply are
#      accepted as well: all of them come from code after the gate.
#   QoD 97 when the cookie-less control was refused by the gate and the anonymous-session
#   request got through; QoD 75 when the probe got through but the control did not show
#   the gate (request failed, or the handler answers even without a session).
#
# Better than the source check: no file is created on the target, and the control request
# shows the access check exists and is bypassed (the source check reported any page
# containing "jsonrpc" and "result").
#
# Versions: checked against the upstream git history — 2.1.19 index.php / upload.files.php
# (plain session_start(), CPM-only gate) and 2.1.20 (encrypted sessions, user_id/key +
# checkUser()).
#
# CVSS: NVD v2 7.5 for CVE-2014-3772 (no v3 score in NVD). The issue also lists
# CVE-2014-3771 (language-file restriction bypass), CVE-2014-3773 (SQL injection) and
# CVE-2014-3774 (XSS), fixed in the same release but not exercised by this request.
#
# Backlog source: OpenVAS/Greenbone NVT 2014/gb_teampass_mult_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.805001, GPL-2.0-only).
uid: a6b6d26a-6a52-42b7-a869-02d4c42ec615
name: "TeamPass < 2.1.20 upload.files.php access-control bypass (CVE-2014-3772)"
description: |
  Tests TeamPass before 2.1.20 for the access-control bypass in
  sources/upload/upload.files.php (CVE-2014-3772): the upload handler only checks a session
  flag that index.php sets for every anonymous visitor. The test loads index.php to obtain
  an anonymous session (the session cookies it sets), requests upload.files.php once
  without cookies as a control, then again with the anonymous session and a file name too
  long to be created, so no file is created. A JSON-RPC reply from the upload handler to
  the anonymous session, while the control was refused with "Hacking attempt...", confirms
  the bypass. The web root, /teampass and /TeamPass are tried.
cves: [CVE-2014-3772]
cvss: 7.5
severity: high
confidence_base: 0.30
category: auth-bypass
tags: [teampass, php, auth-bypass, file-upload, web-abuse]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2014-3772"
  - "https://nvd.nist.gov/vuln/detail/CVE-2014-3771"
  - "https://nvd.nist.gov/vuln/detail/CVE-2014-3773"
  - "https://nvd.nist.gov/vuln/detail/CVE-2014-3774"
  - "https://github.com/nilsteampassnet/TeamPass/blob/2.1.20/sources/upload/upload.files.php"
  - "https://github.com/nilsteampassnet/TeamPass/blob/2.1.20/sources/sessions.php"

steps:
  # A file name longer than any file-system name limit (255 bytes): fopen() of
  # "<upload folder>/<name>.part" fails, so the handler stops before writing anything.
  - id: mint
    action: script
    code: '#{ name: "noctis" + rand_hex(8) + crap(300, "a") }'
    store_as: m

  # ── Loop group: every step below runs once per candidate install base ──
  # Pre-initialise every stored result a script reads (an undefined variable aborts
  # the whole test).
  - id: init-idx
    action: set_var
    var_name: idx
    var_value: {connected: false, banner: null}
    loop:
      over: ["", "/teampass", "/TeamPass"]
      var: base

  - id: init-ctrl
    action: set_var
    var_name: ctrl
    var_value: {status: 0, body: null}

  - id: init-probe
    action: set_var
    var_name: probe
    var_value: {status: 0, body: null}

  # 1. index.php — raw request so every Set-Cookie header is kept.
  - id: index
    action: tcp_connect
    port: "{{port}}"
    send: "GET {{base}}/index.php HTTP/1.0\r\nHost: {{target_host}}\r\nUser-Agent: Mozilla/5.0\r\nAccept: */*\r\n\r\n"
    store_as: idx

  - id: cookies
    action: script
    code: |
      let out = #{ ok: false, cookie: "", names: "" };
      if type_of(idx.banner) == "string" {
        let head = idx.banner;
        let cut = stridx(head, "\r\n\r\n");
        if cut < 0 { cut = stridx(head, "\n\n"); }
        if cut >= 0 { head = substr(head, 0, cut); }
        let jar = #{};
        for raw in split(head, "\n") {
          let c = eregmatch("^set-cookie:[ \\t]*([A-Za-z0-9_.-]+)=([^;\\r]*)", raw, true);
          if c.len() < 3 || c[2] == "" || c[2] == "deleted" { continue; }
          jar[c[1]] = c[2];
        }
        for k in jar.keys() {
          if out.ok {
            out.cookie += "; ";
            out.names += ", ";
          }
          out.cookie += k + "=" + jar[k];
          out.names += k;
          out.ok = true;
        }
      }
      out
    store_as: c

  # 2. Control — no session cookie: the CPM check must refuse it.
  - id: control
    action: http_request
    method: GET
    path: "{{base}}/sources/upload/upload.files.php?PHPSESSID=&name={{m.name}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    condition: "c.ok == true"
    store_as: ctrl

  # 3. Probe — the anonymous session from index.php.
  - id: bypass
    action: http_request
    method: GET
    path: "{{base}}/sources/upload/upload.files.php?PHPSESSID=&name={{m.name}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    condition: "c.ok == true"
    headers:
      Cookie: "{{c.cookie}}"
    store_as: probe

  - id: verdict
    action: script
    code: |
      let rpc = "\"jsonrpc\"[ \\t]*:[ \\t]*\"2\\.0\"";
      let tail = "\"result\"[ \\t]*:|\"error\"[ \\t]*:[ \\t]*\\{[ \\t]*\"code\"[ \\t]*:[ \\t]*10[0-3]";
      let pb = probe.body;
      let cb = ctrl.body;
      let hit = c.ok == true && type_of(pb) == "string" && probe.status == 200
        && ereg(rpc, pb) && ereg(tail, pb) && stridx(pb, "Hacking attempt") < 0;
      let gated = type_of(cb) == "string" && ctrl.status == 200
        && stridx(cb, "Hacking attempt...") >= 0 && !ereg(rpc, cb);
      let code = eregmatch("\"code\"[ \\t]*:[ \\t]*(10[0-3])", if type_of(pb) == "string" { pb } else { "" });
      let reply = if code.len() > 1 { "JSON-RPC error " + code[1] } else { "JSON-RPC result" };
      #{ hit: hit, gated: gated, reply: reply }
    store_as: v

  - id: bypass-confirmed
    action: match
    source: v.reply
    pattern: "JSON-RPC"
    condition: "v.hit == true && v.gated == true"
    on_match:
      stop: true
      finding:
        title: "TeamPass upload.files.php access-control bypass (CVE-2014-3772)"
        confidence_delta: 0.65
        qod: 97
        evidence: "Access check bypassed: GET {{base}}/sources/upload/upload.files.php without cookies was refused (\"Hacking attempt...\"), while the same request with the anonymous session handed out by {{base}}/index.php (cookies {{c.names}}, no login) ran the upload handler ({{v.reply}}; an over-long file name kept it from creating a file)"
        remediation: "Upgrade TeamPass to 2.1.20 or later."

  - id: bypass-reachable
    action: match
    source: v.reply
    pattern: "JSON-RPC"
    condition: "v.hit == true && v.gated != true"
    on_match:
      stop: true
      finding:
        title: "TeamPass upload.files.php reachable without login (CVE-2014-3772)"
        confidence_delta: 0.45
        qod: 75
        evidence: "GET {{base}}/sources/upload/upload.files.php with the anonymous session handed out by {{base}}/index.php (cookies {{c.names}}, no login) ran the upload handler ({{v.reply}}); the cookie-less control did not show the access check (status {{ctrl.status}})"
        remediation: "Upgrade TeamPass to 2.1.20 or later."

View these feeds on GitHub