FreeNAC — 1 vulnerability check

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

← All products · Feeds on GitHub

FreeNAC <= 3.02 stats.php reflected cross-site scripting

CVECVE-2012-6559
Severitymedium · CVSS 4.3
Categoryxss — XSS
Serviceshttp, https
Detectionset_var, http_request, script, match · highest QoD 75
Feedtests/vulnerabilities/freenac/CVE-2012-6559.yaml

FreeNAC 3.02 and earlier print the type and graphtype parameters of stats.php back into the page without HTML-encoding them, so an attacker can run script in the browser of any user who opens a crafted link (cross-site scripting).

Under the web root, /freenac and /nac, this check identifies FreeNAC from the titles of login.php, then requests stats.php with a harmless script tag carrying a random marker in the type parameter. The finding is reported when the tag comes back verbatim, unencoded, on a page that still shows the statistics. Nothing is written to the target.

How noctis detects it

  1. HTTP(S) request GET {{adir}}/login.php
  2. Parses / computes the next value with a Rhai script
  3. HTTP(S) request GET {{adir}}/stats.php?graphtype=bar&type=vlan13%3Cscript%3E{{g.mk}}%3C/script%3E
  4. Parses / computes the next value with a Rhai script
  5. Checks res.hit for ^true$ → finding QoD 75: FreeNAC stats.php reflected cross-site scripting (CVE-2012-6559)

References:

Feed source — tests/vulnerabilities/freenac/CVE-2012-6559.yaml
# FreeNAC <= 3.02 — stats.php reflected cross-site scripting (CVE-2012-6559)
#
# stats.php prints its graphtype / type parameters back into the page without
# HTML-encoding them. CVE-2012-6559 also names comment, mac and name on
# stats.php and comment on deviceadd.php; the type parameter is probed here.
# The SQL injection of the same advisory (CVE-2012-6560, deviceadd.php status)
# writes to the device table and is not probed.
#
# Detection (per candidate install dir: web root, /freenac, /nac):
#   0. login.php must carry the FreeNAC page titles (">FreeNAC website<" and
#      ">FreeNAC ::").
#   1. QoD 75 — stats.php?graphtype=bar&type=vlan13<script>MARK</script> (MARK
#      random per run) comes back with the tag unencoded, on a page that still
#      renders the statistics ("Server status" / "Device Class").
#   2. No finding when the tag is encoded (&lt;script&gt;) or dropped.
#
# Read-only: one GET with a random marker, nothing is written.
#
# Ported from OpenVAS/Greenbone NVT `2013/gb_freenac_mult_xss_n_sql_inj_vuln.nasl`
# (OID 1.3.6.1.4.1.25623.1.0.803707, GPL-2.0-only). Differences: the NASL
# reflects a fixed alert(document.cookie) payload; here a random inert marker
# is used, and the reply must carry the whole tag verbatim.
# CVSS: NVD carries only a CVSS v2 score (4.3) for CVE-2012-6559.
uid: 5b0f7a35-93d2-4c5e-8e1f-6a2d4c9b7e13
name: "FreeNAC <= 3.02 stats.php reflected cross-site scripting (CVE-2012-6559)"
description: |
  FreeNAC 3.02 and earlier print the type and graphtype parameters of
  stats.php back into the page without HTML-encoding them, so an attacker can
  run script in the browser of any user who opens a crafted link
  (cross-site scripting).

  Under the web root, /freenac and /nac, this check identifies FreeNAC from the
  titles of login.php, then requests stats.php with a harmless script tag
  carrying a random marker in the type parameter. The finding is reported when
  the tag comes back verbatim, unencoded, on a page that still shows the
  statistics. Nothing is written to the target.
cves: [CVE-2012-6559]
cvss: 4.3
severity: medium
category: xss
confidence_base: 0.30
tags: [freenac, nac, php, xss, reflected]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2012-6559"
  - "https://nvd.nist.gov/vuln/detail/CVE-2012-6560"

steps:
  - id: init-login
    action: set_var
    var_name: login
    var_value: {status: 0, body: ""}
    loop:
      over: ["", "/freenac", "/nac"]
      var: adir

  - id: init-stats
    action: set_var
    var_name: stats
    var_value: {status: 0, body: ""}

  - id: login-page
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{adir}}/login.php"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    store_as: login

  - id: gate
    action: script
    code: |
      let b = if type_of(login.body) == "string" { login.body } else { "" };
      #{ ok: login.status == 200 && b.contains(">FreeNAC website<") && b.contains(">FreeNAC ::"), mk: "NCT" + rand_hex(6) }
    store_as: g

  - id: reflect
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{adir}}/stats.php?graphtype=bar&type=vlan13%3Cscript%3E{{g.mk}}%3C/script%3E"
    condition: "g.ok"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    store_as: stats

  - id: check
    action: script
    code: |
      let b = if type_of(stats.body) == "string" { stats.body } else { "" };
      let tag = "<script>" + g.mk + "</script>";
      #{ hit: g.ok && stats.status == 200 && b.contains(tag) && (b.contains(">Server status<") || b.contains(">Device Class")) }
    store_as: res

  - id: report
    action: match
    source: res.hit
    pattern: "^true$"
    condition: "res.hit"
    on_match:
      finding:
        title: "FreeNAC stats.php reflected cross-site scripting (CVE-2012-6559)"
        description: "The type parameter of stats.php was returned inside the page with its <script> tag unencoded, so an attacker can run script in the browser of a user who follows a crafted link and act with that user's session."
        remediation: "Upgrade FreeNAC past 3.02, or HTML-encode every request parameter printed by stats.php and deviceadd.php."
        confidence_delta: 0.45
        qod: 75
        evidence: "{{adir}}/stats.php?type=vlan13<script>{{g.mk}}</script> came back with the script tag unencoded"
      stop: true

View these feeds on GitHub