SetSeed — 1 vulnerability check

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

← All products · Feeds on GitHub

SetSeed CMS loggedInUser cookie SQL injection

CVECVE-2011-5116
Severityhigh · CVSS 7.5
Categorysqli — SQL injection
Serviceshttp, https
Detectionset_var, http_request, script, match · highest QoD 75
Feedtests/vulnerabilities/setseed/CVE-2011-5116.yaml

SetSeed CMS 5.8.20 uses the loggedInUser cookie sent to its hub (/setseed-hub/) in an SQL query without sufficient escaping, so an unauthenticated visitor can inject SQL into the CMS database.

Under the web root and the usual CMS paths, this check requests the hub with a plain numeric loggedInUser cookie as a control, then with a single quote appended, then with two quotes. The vulnerability is reported when only the single-quote request prints a MySQL syntax error, while the control and the balanced two-quote request print none. Nothing is written and no data is read from the database.

How noctis detects it

  1. HTTP(S) request GET {{adir}}/
  2. Parses / computes the next value with a Rhai script
  3. HTTP(S) request GET {{adir}}/setseed-hub/
  4. HTTP(S) request GET {{adir}}/setseed-hub/
  5. HTTP(S) request GET {{adir}}/setseed-hub/
  6. Parses / computes the next value with a Rhai script
  7. Checks res.ok for ^true$ → finding QoD 75: SetSeed CMS loggedInUser cookie SQL injection (CVE-2011-5116)

References:

Feed source — tests/vulnerabilities/setseed/CVE-2011-5116.yaml
# SetSeed CMS 5.8.20 — setseed-hub loggedInUser cookie SQL injection (CVE-2011-5116)
#
# The SetSeed hub (/setseed-hub/) builds an SQL query from the loggedInUser cookie without
# escaping it, so a lone quote in the cookie value makes the page print MySQL's syntax error.
#
# Detection (QoD 75), per candidate install dir (web root, /setseed, /cms):
#   1. GET <dir>/ to pick up the anonymous session cookie the CMS sets (sent back if present).
#   2. GET <dir>/setseed-hub/ with loggedInUser=1 (control) shows no SQL error.
#   3. loggedInUser=1' (one quote) answers with a MySQL syntax error.
#   4. loggedInUser=1'' (balanced quotes) answers with no SQL error again, so a page that
#      prints an error for any quote character is not reported.
# Read-only: the payloads are quote characters in a cookie; nothing is written or read.
#
# Better than the source NASL: it fires on the quote probe alone; here a clean control and a
# balanced-quote probe rule out pages that print an error whenever a quote shows up. The
# session cookie is only the last Set-Cookie header of the landing page (engine limitation).
# CVSS: NVD carries only a CVSS v2 score (7.5) for this CVE.
#
# Source: OpenVAS/Greenbone NVT 2011/gb_setseed_50498.nasl
# (OID 1.3.6.1.4.1.25623.1.0.103327, GPL-2.0-only).
uid: e2dceb36-acb9-41e1-a939-cdd86efadd7e
name: "SetSeed CMS loggedInUser cookie SQL injection (CVE-2011-5116)"
description: |
  SetSeed CMS 5.8.20 uses the loggedInUser cookie sent to its hub (/setseed-hub/) in an SQL
  query without sufficient escaping, so an unauthenticated visitor can inject SQL into the
  CMS database.

  Under the web root and the usual CMS paths, this check requests the hub with a plain
  numeric loggedInUser cookie as a control, then with a single quote appended, then with two
  quotes. The vulnerability is reported when only the single-quote request prints a MySQL
  syntax error, while the control and the balanced two-quote request print none. Nothing is
  written and no data is read from the database.
cves: [CVE-2011-5116]
cvss: 7.5  # NVD publishes only a CVSS v2 base score (7.5) for this CVE
severity: high
category: sqli
confidence_base: 0.30
tags: [setseed, php, sqli, error-based, cookie]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2011-5116"

steps:
  # A loop: step runs together with every following non-loop step once per directory, so
  # the init steps below reset all stored results at the start of each iteration.
  - id: init-land
    action: set_var
    var_name: land
    var_value: {status: 0, headers: {}}
    loop:
      over: ["", "/setseed", "/cms"]
      var: adir

  - id: init-ctl
    action: set_var
    var_name: ctl_resp
    var_value: {status: 0, body: null}

  - id: init-one
    action: set_var
    var_name: one_resp
    var_value: {status: 0, body: null}

  - id: init-two
    action: set_var
    var_name: two_resp
    var_value: {status: 0, body: null}

  - id: landing
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{adir}}/"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    store_as: land

  - id: gen
    action: script
    code: |
      let sess = "";
      if type_of(land.headers) == "map" && "set-cookie" in land.headers {
        let c = land.headers["set-cookie"];
        if type_of(c) == "string" && c.contains("=") { sess = "; " + c.split(";")[0]; }
      }
      let base = "loggedInKey=PYNS9QVWLEBG1E7C9UFCT674DYNW9YJ; loggedInUser=1";
      #{ ctl: base + sess, one: base + "%27" + sess, two: base + "%27%27" + sess }
    store_as: ck

  - id: control
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{adir}}/setseed-hub/"
    headers:
      Cookie: "{{ck.ctl}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    store_as: ctl_resp

  - id: inject-one
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{adir}}/setseed-hub/"
    headers:
      Cookie: "{{ck.one}}"
    condition: 'ctl_resp.status >= 200 && ctl_resp.status < 500 && type_of(ctl_resp.body) == "string" && !ereg("(?i)(error in your SQL syntax|mysql_fetch|MySQL server version)", ctl_resp.body)'
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    store_as: one_resp

  - id: inject-two
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{adir}}/setseed-hub/"
    headers:
      Cookie: "{{ck.two}}"
    condition: 'one_resp.status >= 200 && one_resp.status < 600 && type_of(one_resp.body) == "string" && ereg("error in your SQL syntax", one_resp.body)'
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    store_as: two_resp

  - id: check
    action: script
    code: |
      let o = if type_of(one_resp.body) == "string" { one_resp.body } else { "" };
      let t = if type_of(two_resp.body) == "string" { two_resp.body } else { "" };
      let ok = two_resp.status >= 200 && two_resp.status < 500
        && ereg("error in your SQL syntax", o)
        && !ereg("(?i)(error in your SQL syntax|mysql_fetch|MySQL server version)", t);
      #{ ok: ok }
    store_as: res

  - id: report
    action: match
    source: res.ok
    pattern: "^true$"
    condition: "res.ok"
    on_match:
      finding:
        title: "SetSeed CMS loggedInUser cookie SQL injection (CVE-2011-5116)"
        description: "A single quote appended to the loggedInUser cookie sent to the SetSeed hub made the page print a MySQL syntax error, while the same request without the quote and with a balanced pair of quotes printed none: the cookie value reaches an SQL statement unescaped, so an unauthenticated attacker can run arbitrary SQL against the CMS database."
        remediation: "Upgrade SetSeed CMS to a release later than 5.8.20 that escapes the loggedInUser cookie, or migrate to a supported CMS."
        confidence_delta: 0.45
        qod: 75
        evidence: "{{adir}}/setseed-hub/: loggedInUser=1 answers without a database error, loggedInUser=1' answers with an SQL syntax error, loggedInUser=1'' answers without one"
      stop: true

View these feeds on GitHub