Greenbone — 1 vulnerability check

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

← All products · Feeds on GitHub

Greenbone Security Assistant < 7.0.3 / Greenbone OS < 5.0.0 Host Header Injection

CVECVE-2018-25016
Severitycritical · CVSS 9.8
Categoryexposure — Exposure
Serviceshttp, https
Detectionscript, tcp_connect, match · highest QoD 75
Feedtests/vulnerabilities/greenbone/CVE-2018-25016.yaml

Tests the Greenbone Security Assistant web server (gsad) for the Host header injection fixed in GSA 7.0.3 and Greenbone OS 5.0.0 (CVE-2018-25016). The feed sends GET / with a Host header naming a random third-party host (noctis<random hex>.example.com). Vulnerable versions build their "303 See Other" redirect to the login page from that header, so the reply's body ("Code 303 - Redirecting to <a href=...>") sends the browser to the random host. A 303 reply redirecting to that host confirms the finding: the server can be made to redirect users, or poison cached links and e-mailed URLs, to an attacker-controlled domain. Fixed versions answer an unknown Host header with 400 Bad Request. The request only reads the redirect; nothing is changed on the server.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. Raw TCP (TLS on HTTPS), sent verbatim: GET / HTTP/1.1
  3. Parses / computes the next value with a Rhai script
  4. Checks gsa_redirect for Code 303 - Redirecting to <a href= → finding QoD 75: GET / with Host: … was answered with a 303 redirect to that host — …

References:

Feed source — tests/vulnerabilities/greenbone/CVE-2018-25016.yaml
# Greenbone Security Assistant (gsad) < 7.0.3 / Greenbone OS < 5.0.0 —
# Host header injection — CVE-2018-25016
#
# gsad, the web server of the Greenbone Security Assistant, answers a request
# for "/" (and for "/login/", and every URL on its HTTP-to-HTTPS redirect
# port) with a "303 See Other" whose Location header AND body are built from
# the client's Host header, unchecked:
#
#   gsad 7.0.2 src/gsad.c, send_redirect_to_urn():
#     snprintf (uri, sizeof (uri), "%s://%s%s", protocol, host, urn);
#   send_redirect_to_uri():
#     "<html><body>Code 303 - Redirecting to <a href=\"%s\">%s<a/></body></html>"
#
# GSA 7.0.3 (gsa PR #318) added validate_host_header(): only the addresses gsad
# listens on, localhost and the --allow-header-host names are accepted, any
# other Host gets "400 Bad Request" with "The request contained an unknown or
# invalid Host header". Greenbone OS 5.0.0 ships the fixed gsad.
#
# Detection (benign, read-only): GET / with a random third-party Host header
# (noctis<random hex>.example.com). A 303 reply whose gsad redirect body sends
# the client to that random host proves the injection (QoD 75). The random
# name cannot come from anything but our header, so a plain redirect to the
# server's own name, a fixed gsad (400) or any other web server does not match.
#
# Improvements over the source check: a random per-run host instead of a fixed
# third-party domain (a page or honeypot that happens to contain the fixed name
# cannot match), and the regex is anchored on the href of the gsad redirect body.
#
# Ported from OpenVAS/Greenbone NVT 2019/greenbone/gb_gos_host_header_vuln_active.nasl
# (OID 1.3.6.1.4.1.25623.1.0.108662, GPL-2.0-only). Vulnerable / fixed code read
# from greenbone/gsa tags v7.0.2 and v7.0.3 (src/gsad.c).
uid: 75363b38-72ee-4c15-abc1-87dae56a3ae5
name: "Greenbone Security Assistant < 7.0.3 / Greenbone OS < 5.0.0 Host Header Injection (CVE-2018-25016)"
description: |
  Tests the Greenbone Security Assistant web server (gsad) for the Host header
  injection fixed in GSA 7.0.3 and Greenbone OS 5.0.0 (CVE-2018-25016). The
  feed sends GET / with a Host header naming a random third-party host
  (noctis<random hex>.example.com). Vulnerable versions build their "303 See
  Other" redirect to the login page from that header, so the reply's body
  ("Code 303 - Redirecting to <a href=...>") sends the browser to the random
  host. A 303 reply redirecting to that host confirms the finding: the server
  can be made to redirect users, or poison cached links and e-mailed URLs, to
  an attacker-controlled domain. Fixed versions answer an unknown Host header
  with 400 Bad Request. The request only reads the redirect; nothing is changed
  on the server.
cves: [CVE-2018-25016]
cvss: 9.8
severity: critical
category: exposure
confidence_base: 0.30
tags: [greenbone, gsa, gsad, greenbone-os, gos, host-header-injection, open-redirect, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2018-25016"
  - "https://github.com/greenbone/gsa/pull/318"
  - "https://github.com/greenbone/gsa/releases/tag/v7.0.3"
  # OpenVAS/Greenbone NASL 2019/greenbone/gb_gos_host_header_vuln_active.nasl (GPL-2.0-only)

steps:
  # ── 1. Per-run random third-party host name ─────────────────────────────
  - id: mint-host
    action: script
    code: '"noctis" + rand_hex(6) + ".example.com"'
    store_as: gsa_inj_host

  # ── 2. GET / with the injected Host header ──────────────────────────────
  #       Raw request: the Host header must go out exactly as written.
  - id: host-probe
    action: tcp_connect
    port: "{{port}}"
    send: "GET / HTTP/1.1\r\nHost: {{gsa_inj_host}}\r\nUser-Agent: Mozilla/5.0\r\nAccept: */*\r\nConnection: close\r\n\r\n"
    timeout_secs: 10
    store_as: gsa_resp
    # A failed connect leaves store_as unset: define it so the script runs.
    on_failure:
      set_vars:
        gsa_resp: false

  # ── 3. Keep the gsad redirect line, only on a 303 reply, only when it ───
  #       points at the random host we sent.
  - id: extract-redirect
    action: script
    code: |
      let line = "";
      if type_of(gsa_resp) == "map" && type_of(gsa_resp.banner) == "string"
          && ereg("^HTTP/1\\.[01] 303", gsa_resp.banner) {
        let host_re = str_replace(gsa_inj_host, ".", "\\.");
        line = egrep("Code 303 - Redirecting to <a href=\"https?://" + host_re + "[:/\"]", gsa_resp.banner);
      }
      chomp(line)
    store_as: gsa_redirect

  # ── 4. Confirm the injection ────────────────────────────────────────────
  - id: host-header-injected
    action: match
    source: gsa_redirect
    pattern: "Code 303 - Redirecting to <a href="
    on_match:
      finding:
        confidence_delta: 0.55
        qod: 75
        evidence: "GET / with Host: {{gsa_inj_host}} was answered with a 303 redirect to that host — {{gsa_redirect}}"
      stop: true

View these feeds on GitHub