Vulnerability Details
Apache Tomcat's CGI Servlet on Windows, when configured to pass command-line arguments to batch files, allows an attacker to inject shell commands via URL parameters. This could lead to remote code execution.
wwws.nightwatchcybersecurity.com
Published on wwws.nightwatchcybersecurity.com
Apache Tomcat has a vulnerability in the CGI Servlet which can be exploited to achieve remote code execution (RCE). This is only exploitable when running on Windows in a non-default configuration in conjunction with batch files.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the CGI Servlet passes URL parameters as command-line arguments to batch files without sanitising Windows shell metacharacters, and cmd.exe interprets them as additional commands.
Impact
An attacker could execute arbitrary commands on the server, but only if the non-default CGI configuration is enabled on Windows with batch files and command-line arguments allowed.
What the attacker needed
Windows OS; CGI support enabled; privileged context set to true; enableCmdLineArguments true (Tomcat 9)
The fix
The vendor fixed it by disabling command-line arguments by default and adding input validation via a new configuration parameter.
How it was found
- Install a Java Runtime Environment on Windows.
- Download a vulnerable version of Tomcat and extract it.
- Enable privileged context in conf\context.xml.
- Enable the CGI Servlet in conf\web.xml and set enableCmdLineArguments to true.
- Create a batch file in the CGI directory.
- Start Tomcat and request a URL with a parameter that injects a command.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
When a web server runs a program, it sometimes passes user input as arguments. On Windows, special characters in those arguments can be interpreted by the command shell, allowing an attacker to run their own commands. This only happens in a non-default setup where Tomcat runs batch files and passes arguments.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.