`CVE-2019-0232` is a critical security issue that could result in remote code execution. This vulnerability affects Windows systems that have the `enableCmdLineArguments` feature enabled. An attacker can exploit this vulnerability by exploiting a command injection flaw resulting from a Tomcat CGI Servlet input validation error, thus allowing them to execute arbitrary commands on the affected system. Versions `9.0.0.M1` to `9.0.17`, `8.5.0` to `8.5.39`, and `7.0.0` to `7.0.93` of Tomcat are affected.
CGI Servlet is vital component of apache tomcat that enables webservers to communicate with external applications beyond tomcat JVM Ext. apps are typically CGI scripts written in langs like perl,python,bash. CGI Servlet function is to receive requests from browser and forward them to CGI scripts for processing
CGI Servlet is a program that runs on a webserver - to support execution of external app that confirm to CGI specification. Middleware.
Utilized for several reasons but there's some big disadvantages
| Advantages | Disadvantages |
|---|---|
| It is simple and effective for generating dynamic web content. | Incurs overhead by having to load programs into memory for each request. |
| Use any programming language that can read from standard input and write to standard output. | Cannot easily cache data in memory between page requests. |
| Can reuse existing code and avoid writing new code. | It reduces the server's performance and consumes a lot of processing time. |
enableCmdLineArguments
- apache tomcat cgi servlet
- controls cmdline args from query string
- true = parse string + pass to cgi script as args
- make cgi scripts more flexible / easier to write by allowing params to be passed w/o env vars or stdin
- i.e. cgi script cmdline args switch between actions based on user input
http://example.com/cgi-bin/booksearch.cgi?action=title&query=the+great+gatsby
action param set to title - indicating script search books by title. query param specifies search term.
http://example.com/cgi-bin/booksearch.cgi?action=author&query=fitzgerald
action set to author, etc.
allows easily switching different search actions based on user input.
Problem arises when enableCmdLineArguments is enabled on win systems because cgi servlet fails to properly validate input from web browser before passing it to cgi script. Leads to OS cmd injection attacks, exec arbitrary commands on tgt sys
i.e. attack can append dir to valid command using & separator
- if attacker controls input to CGI script that uses this command they can inject after
&to execute any cmd on the server.
http://example.com/cgi-bin/hello.bat?&dir
&dir passed as arg to hello.bat and executes dir
example nmap 
tomcat 8080
Finding CGI
dirbusting ffuf w/ dirb common.txt wordlist. knowing default dir for cgi scripts is /cgi ,
attempt url: http://10.129.204.227:8080/cgi/FUZZ.cmd or http://10.129.204.227:8080/cgi/FUZZ.bat
since OS is windows we aim to fuzz for batch scripts
ffuf -w /usr/share/dirb/wordlists/common.txt -u http://10.129.204.227:8080/cgi/FUZZ.bat
ffuf -w /usr/share/dirb/wordlists/common.txt -u http://10.129.204.227:8080/cgi/FUZZ.cmd
exploit CVE-2019-0232 appending commands with &

keep note it may be necessary to both:
- url encode your command
- hardcode path (if $PATH isnt set)