Home Library CVE-2021-42013
CVE-2021-42013 Critical

Apache httpd 2.4.50 incomplete traversal fix

Build a lab target running Apache httpd 2.4.50, the version CVE-2021-42013 affects.

CVSS
9.8 / 10
Vector
Web app
Difficulty
Easy
Added
2026-10-20
01

About this target

Apache httpd 2.4.50 was the first attempt to fix CVE-2021-41773, and it left a gap: a path that is URL-encoded twice still gets past the check. There are two playbooks for this CVE. One builds 2.4.50 with the root directory opened up as a file-access target. The other builds it with the prefork MPM, mod_cgi loaded and CGI execution allowed on the root directory. Both start the service and stop there.

Remote code execution bugs are the ones defenders care about most. This target is useful for testing detection rules and logging.

Product
Apache httpd
Version
2.4.50
Type
RCE
Severity
Critical
Port
80/tcp
apache cgi web
02

Before you start

This playbook needs the setup from the earlier steps. Check these first.

  • The base VM from Step 01 is built and reachable over SSH.
  • You cloned the playbooks repo and set inventory/hosts.ini in Step 02.
  • A snapshot named clean-base exists, and the machine is booted from it.

One CVE at a time. Don't run this on top of another playbook. Reset first.

03

Run the playbook

Boot the machine from clean-base, then run the playbook for CVE-2021-42013. It installs Apache httpd 2.4.50, sets up its config and starts the service.

Terminal · host
ansible-playbook cve/cve-2021-42013.yml 

A clean run ends with a recap that shows failed=0. If it fails partway, run it again.

04

Verify the target

The verify tag checks that the service is listening and running the version this CVE affects. Run it from the host.

Terminal · host
ansible-playbook cve/cve-2021-42013.yml  --tags verify

You should see target OK.

05

What defenders can look for

- Requests with doubly encoded dot sequences in the URL path - Access log entries under /cgi-bin/ that resolve to paths outside the web root - Unexpected child processes started by httpd - A Server header or banner showing Apache/2.4.50

06

How it was fixed

Fixed in Apache httpd 2.4.51, which reworked how encoded path segments are decoded and checked. Upgrade to 2.4.51 or later, and keep the root directory set to Require all denied.

07

Reset when you're done

Restore clean-base. Nothing from this playbook carries over.

Terminal · host
VBoxManage controlvm thehackingmachine acpipowerbutton
VBoxManage snapshot thehackingmachine restore clean-base
VBoxManage startvm thehackingmachine
08

References

09

Credit

Playbook and write-up by TheHackingMachine Team.

Want to add your own? See how to contribute.