Multiple Vendor test-cgi Arbitrary File Access - Nessus

Medium   Plugin ID: 10282

This page contains detailed information about the Multiple Vendor test-cgi Arbitrary File Access Nessus plugin including available exploits and PoCs found on GitHub, in Metasploit or Exploit-DB for verifying of this vulnerability.

Plugin Overview


ID: 10282
Name: Multiple Vendor test-cgi Arbitrary File Access
Filename: test-cgi.nasl
Vulnerability Published: 1996-04-01
This Plugin Published: 1999-06-22
Last Modification Time: 2022-04-11
Plugin Version: 1.39
Plugin Type: remote
Plugin Family: CGI abuses
Dependencies: http_version.nasl
Excluded KB Items [?]: Settings/disable_cgi_scanning

Vulnerability Information


Severity: Medium
Vulnerability Published: 1996-04-01
Patch Published: N/A
CVE [?]: CVE-1999-0070
CPE [?]: N/A

Synopsis

The remote web server contains a CGI script that is affected by information disclosure vulnerabilities.

Description

The remote web server contains the 'test-cgi' test script, which is included by default with some web servers.

The version of this script on the remote host fails to quote input to several environment variables, such as 'QUERY_STRING', before echoing it back as part of a shell script. An unauthenticated attacker can leverage this issue to list the contents of directories on the remote host, subject to the permissions of the web server user id.

Solution

Disable or delete the CGI script.

Public Exploits


Target Network Port(s): 80
Target Asset(s): Services/www
Exploit Available: True (GitHub)
Exploit Ease: No exploit is required

Here's the list of publicly known exploits and PoCs for verifying the Multiple Vendor test-cgi Arbitrary File Access vulnerability:

  1. GitHub: https://github.com/starnightcyber/vul-info-collect
    [CVE-1999-0070]

Before running any exploit against any system, make sure you are authorized by the owner of the target system(s) to perform such activity. In any other case, this would be considered as an illegal activity.

WARNING: Beware of using unverified exploits from sources such as GitHub or Exploit-DB. These exploits and PoCs could contain malware. For more information, see how to use exploits safely.

Risk Information


CVSS V2 Vector [?]: AV:N/AC:L/Au:N/C:P/I:N/A:N/E:POC/RL:OF/RC:C
CVSS Base Score:5.0 (Medium)
Impact Subscore:2.9
Exploitability Subscore:10.0
CVSS Temporal Score:3.9 (Low)
CVSS Environmental Score:NA (None)
Modified Impact Subscore:NA
Overall CVSS Score:3.9 (Low)

Go back to menu.

Plugin Source


This is the test-cgi.nasl nessus plugin source code. This script is Copyright (C) 1999-2022 Tenable Network Security, Inc.

#%NASL_MIN_LEVEL 70300
#
# (C) Tenable Network Security, Inc.
#

include('deprecated_nasl_level.inc');
include('compat.inc');

if (description)
{
  script_id(10282);
  script_version("1.39");
  script_set_attribute(attribute:"plugin_modification_date", value:"2022/04/11");

  script_cve_id("CVE-1999-0070");
  script_bugtraq_id(2003);

  script_name(english:"Multiple Vendor test-cgi Arbitrary File Access");

  script_set_attribute(attribute:"synopsis", value:
"The remote web server contains a CGI script that is affected by
information disclosure vulnerabilities.");
  script_set_attribute(attribute:"description", value:
"The remote web server contains the 'test-cgi' test script, which is
included by default with some web servers. 

The version of this script on the remote host fails to quote input to
several environment variables, such as 'QUERY_STRING', before echoing
it back as part of a shell script.  An unauthenticated attacker can
leverage this issue to list the contents of directories on the remote
host, subject to the permissions of the web server user id.");
  script_set_attribute(attribute:"see_also", value:"http://www.securityfocus.com/advisories/582");
  script_set_attribute(attribute:"solution", value:
"Disable or delete the CGI script.");
  script_set_cvss_base_vector("CVSS2#AV:N/AC:L/Au:N/C:P/I:N/A:N");
  script_set_cvss_temporal_vector("CVSS2#E:POC/RL:OF/RC:C");

  script_set_attribute(attribute:"exploitability_ease", value:"No exploit is required");
  script_set_attribute(attribute:"exploit_available", value:"false");

  script_set_attribute(attribute:"vuln_publication_date", value:"1996/04/01");
  script_set_attribute(attribute:"plugin_publication_date", value:"1999/06/22");

  script_set_attribute(attribute:"plugin_type", value:"remote");
  script_set_attribute(attribute:"thorough_tests", value:"true");
  script_end_attributes();

  script_category(ACT_GATHER_INFO);
  script_family(english:"CGI abuses");

  script_copyright(english:"This script is Copyright (C) 1999-2022 Tenable Network Security, Inc.");

  script_dependencies("http_version.nasl");
  script_exclude_keys("Settings/disable_cgi_scanning");
  script_require_ports("Services/www", 80);

  exit(0);
}

#
# The script code starts here
#
include("global_settings.inc");
include("misc_func.inc");
include("http.inc");


port = get_http_port(default:80);

cgi = "test-cgi";
pat = string("[= ]", cgi, "($| )");


foreach dir (cgi_dirs())
{
  url = string(dir, "/", cgi);

  # Try an exploit using QUERY_STRING.
  info = "";

exploit = strcat('GET ', url, '?* HTTP/1.0\r\n\r\n');
w = http_send_recv_buf(port: port, data: exploit);
if (isnull(w)) exit(1, "the web server did not answer");
res = strcat(w[0], w[1], '\r\n', w[2]);

  lines = egrep(pattern:"^QUERY_STRING *= *", string:res);
  if (lines)
  {
    foreach line (split(lines, keep:FALSE))
    {
      # There's a problem if we see the script name in the line; eg,
      #   QUERY_STRING = nph-test-cgi printenv test-cgi
      if (ereg(string:line, pattern:pat))
      {
        info = line;
        break;
      }
    }
  }

  # If the exploit didn't work but the script appears to exist...
  if (lines && !info && thorough_tests)
  {
    # Try an exploit using SERVER_PROTOCOL.
    exploit = strcat('GET ', url, '?x HTTP/1.0 *\r\n\r\n');
    w = http_send_recv_buf(port: port, data: exploit);
    if (isnull(w)) exit(1, "the web server did not answer");
    res = strcat(w[0], w[1], '\r\n', w[2]);

    lines = egrep(pattern:"^SERVER_PROTOCOL *= *", string:res);
    if (lines)
    {
      foreach line (split(lines, keep:FALSE))
      {
        # There's a problem if we see the script name in the line; eg,
        #   SERVER_PROTOCOL = HTTP/1.0 nph-test-cgi printenv test-cgi
        if (ereg(string:line, pattern:pat))
        {
          info = line;
          break;
        }
      }
    }
  }

  if (info)
  {
    if (report_verbosity)
    {
      info = strstr(info, "=") - "=";
      while (info[0] == " ") info = substr(info, 1);
      if ("HTTP/" >< info) info = ereg_replace(pattern:"^HTTP/[0-9]\.[0-9] +", replace:"", string:info);
      info = str_replace(find:" ", replace:'\n  ', string:info);

      report = string(
        "\n",
        "Here are the contents of the CGI directory '", dir, "' on the\n",
        "remote host :\n",
        "\n",
        "  ", info, "\n",
        "\n",
        "which Nessus collected by sending the following request :\n",
        "\n",
        "  ", exploit, "\n"
      );
      security_warning(port:port, extra:report);
    }
    else security_warning(port);
    exit(0);
  }
}

The latest version of this script can be found in these locations depending on your platform:

  • Linux / Unix:
    /opt/nessus/lib/nessus/plugins/test-cgi.nasl
  • Windows:
    C:\ProgramData\Tenable\Nessus\nessus\plugins\test-cgi.nasl
  • Mac OS X:
    /Library/Nessus/run/lib/nessus/plugins/test-cgi.nasl

Go back to menu.

How to Run


Here is how to run the Multiple Vendor test-cgi Arbitrary File Access as a standalone plugin via the Nessus web user interface (https://localhost:8834/):

  1. Click to start a New Scan.
  2. Select Advanced Scan.
  3. Navigate to the Plugins tab.
  4. On the top right corner click to Disable All plugins.
  5. On the left side table select CGI abuses plugin family.
  6. On the right side table select Multiple Vendor test-cgi Arbitrary File Access plugin ID 10282.
  7. Specify the target on the Settings tab and click to Save the scan.
  8. Run the scan.

Here are a few examples of how to run the plugin in the command line. Note that the examples below demonstrate the usage on the Linux / Unix platform.

Basic usage:

/opt/nessus/bin/nasl test-cgi.nasl -t <IP/HOST>

Run the plugin with audit trail message on the console:

/opt/nessus/bin/nasl -a test-cgi.nasl -t <IP/HOST>

Run the plugin with trace script execution written to the console (useful for debugging):

/opt/nessus/bin/nasl -T - test-cgi.nasl -t <IP/HOST>

Run the plugin with using a state file for the target and updating it (useful for running multiple plugins on the target):

/opt/nessus/bin/nasl -K /tmp/state test-cgi.nasl -t <IP/HOST>

Go back to menu.

References


BID | SecurityFocus Bugtraq ID: See also: Similar and related Nessus plugins:
  • 44937 - Multiple Adobe Products XML External Entity (XXE) Injection (APSB10-05)
  • 11748 - Multiple Dangerous CGI Script Detection
  • 10176 - Multiple Vendor phf CGI Arbitrary Command Execution
  • 80475 - Multiple Slider Plugins for WordPress 'img' Parameter Local File Inclusion Vulnerability
  • 49217 - Multiple Switch Vendors '__super' Account Backdoor
  • 49003 - Multiple Vulnerabilities in the IOS FTP Server
  • 49017 - Multiple Cisco Products Vulnerable to DNS Cache Poisoning Attacks
  • 139545 - Multiple Vulnerabilities in Treck IP Stack Affecting Cisco Products: June 2020 (cisco-sa-treck-ip-stack-JyBQ5GyC)
  • 33447 - Multiple Vendor DNS Query ID Field Prediction Cache Poisoning
  • 11197 - Multiple Ethernet Driver Frame Padding Information Disclosure (Etherleak)
  • 10821 - Multiple FTPD glob Command Arbitrary Command Execution
  • 10084 - Multiple FTP Server Command Handling Overflow
  • 123520 - Multiple Command Injection Vulnerabilities in Grandstream Products
  • 124173 - Multiple Command Injection Vulnerabilities in Grandstream Products
  • 10930 - Multiple Web Server on Windows MS/DOS Device Request Remote DOS
  • 11337 - Multiple Linux rpc.mountd Remote Overflow
  • 10249 - Multiple Mail Server EXPN/VRFY Information Disclosure
  • 40449 - Multiple Vendor HMAC Authentication SNMPv3 Authentication Bypass
  • 11136 - Multiple OS /bin/login Remote Overflow
  • 31683 - Multiple Vendor NIS rpc.ypupdated YP Map Update Arbitrary Remote Command Execution

Version


This page has been produced using Nessus Professional 10.1.2 (#68) LINUX, Plugin set 202205072148.
Plugin file test-cgi.nasl version 1.39. For more plugins, visit the Nessus Plugin Library.

Go back to menu.