Skip to content
Info disclosure Disclosed report Intermediate CVE-2020-1934

Use of uninitialized value in ftp_getrc_msg method of mod_proxy_ftp.c

The FTP response parsing routine in Apache's mod_proxy_ftp copies from a buffer offset that can point past the end of a short server reply, so uninitialised memory is read. An attacker controlling an FTP server could potentially leak data from the proxy's memory.

chamal Follow

Originally disclosed on HackerOne

  • Triaged in 6 days
  • Fixed in 6 months
  • Paid in 6 months
  • Disclosed after 6 months

This is a Security Bug Report for mod_proxy_ftp. This bug is present in ftp_getrc_msg method of modules/proxy/mod_proxy_ftp.c file. This is the line which causes this bug.

C
...
  mb = apr_cpystrn(mb, response + 4, me - mb);
...

If ftp server returns a response like "\r\n", which has 3 characters with terminating NULL byte, apr_cpystrn method will copy uninitialized values. Because that line uses "response + 4" as the source of data for apr_cpystrn method.

Apache Http Server version: 2.4.41 CVE-ID: CVE-2020-1934 Apache Http server fixed security bugs: (https://httpd.apache.org/security/vulnerabilities_24.html)

Steps to reproduce

Python 3 and Ubuntu OS 18.04 are required.

  • Download attached ftpserver.py file.
  • Enable proxy_module and proxy_ftp_module on Apache Http server.
  • Add these lines to httpd.conf file of Apache http server.
APACHE
   ProxyRequests On

   <Proxy *>
     Order deny,allow
     Deny from all
     Allow from 127.0.0.1
   </Proxy>
  • Enter proxy settings
    • Open Setting on your Ubuntu OS.
    • Select Network
    • Click settings icon next to "Network Proxy" option.
    • Tick "Manual" option.
    • Enter Apache servers IP and port next to "FTP Proxy"
  • Run Apache http server with Valgrind. sudo valgrind --leak-check=yes bin/httpd -X
  • Run attached ftpserver.py sudo python3 ftpserver.py
    • This python program will start a server on port 21.
  • Open a new terminal window and run this command. curl ftp://127.0.0.1

Valgrind Output

Memcheck, a memory error detector Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info Command: bin/httpd -X

Thread 4: Conditional jump or move depends on uninitialised value(s) at 0x52E6FFE: apr_cpystrn (in /usr/lib/x86_64-linux-gnu/libapr-1.so.0.6.3) by 0x8A0A46A: ftp_getrc_msg (mod_proxy_ftp.c:403) by 0x8A0C6CF: proxy_ftp_command (mod_proxy_ftp.c:828) by 0x8A0EAF1: proxy_ftp_handler (mod_proxy_ftp.c:1212) by 0x87F0259: proxy_run_scheme_handler (mod_proxy.c:3082) by 0x87E9F08: proxy_handler (mod_proxy.c:1251) by 0x17462C: ap_run_handler (config.c:170) by 0x17516E: ap_invoke_handler (config.c:444) by 0x195E74: ap_process_async_request (http_request.c:453) by 0x1915BD: ap_process_http_async_connection (http_core.c:158) by 0x1917EB: ap_process_http_connection (http_core.c:252) by 0x183D4A: ap_run_process_connection (connection.c:42)

Conditional jump or move depends on uninitialised value(s) at 0x52E700F: apr_cpystrn (in /usr/lib/x86_64-linux-gnu/libapr-1.so.0.6.3) by 0x8A0A46A: ftp_getrc_msg (mod_proxy_ftp.c:403) by 0x8A0C6CF: proxy_ftp_command (mod_proxy_ftp.c:828) by 0x8A0EAF1: proxy_ftp_handler (mod_proxy_ftp.c:1212) by 0x87F0259: proxy_run_scheme_handler (mod_proxy.c:3082) by 0x87E9F08: proxy_handler (mod_proxy.c:1251) by 0x17462C: ap_run_handler (config.c:170) by 0x17516E: ap_invoke_handler (config.c:444) by 0x195E74: ap_process_async_request (http_request.c:453) by 0x1915BD: ap_process_http_async_connection (http_core.c:158) by 0x1917EB: ap_process_http_connection (http_core.c:252) by 0x183D4A: ap_run_process_connection (connection.c:42)

Conditional jump or move depends on uninitialised value(s) at 0x8A0A475: ftp_getrc_msg (mod_proxy_ftp.c:405) by 0x8A0C6CF: proxy_ftp_command (mod_proxy_ftp.c:828) by 0x8A0EAF1: proxy_ftp_handler (mod_proxy_ftp.c:1212) by 0x87F0259: proxy_run_scheme_handler (mod_proxy.c:3082) by 0x87E9F08: proxy_handler (mod_proxy.c:1251) by 0x17462C: ap_run_handler (config.c:170) by 0x17516E: ap_invoke_handler (config.c:444) by 0x195E74: ap_process_async_request (http_request.c:453) by 0x1915BD: ap_process_http_async_connection (http_core.c:158) by 0x1917EB: ap_process_http_connection (http_core.c:252) by 0x183D4A: ap_run_process_connection (connection.c:42) by 0x1A189C: process_socket (event.c:1050) ...

  • Complete valgrind output is attached.

Impact

Uninitialized data may leak data from memory.

The original report as published on HackerOne, by chamal. 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

The code copies from a fixed offset of four bytes into the response buffer without checking that the reply is long enough, so a short reply causes a read of uninitialised memory.

Impact

Uninitialised data may leak data from memory, though the report only demonstrates the read under Valgrind rather than a full exfiltration.

What the attacker needed

Apache proxy_ftp_module enabled; attacker controls an FTP server; victim requests an FTP URL via proxy

How it was found

  1. Download the attached Python FTP server script.
  2. Enable proxy_module and proxy_ftp_module on the Apache HTTP server.
  3. Add the proxy configuration lines to httpd.conf.
  4. Configure the system to use the Apache server as an FTP proxy.
  5. Run Apache under Valgrind and start the Python FTP server on port 21.
  6. Request an FTP URL through the proxy with curl and observe the Valgrind warnings.

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.

Apache can act as a proxy that fetches files over FTP for a user. When it reads a reply from the FTP server, it assumes the reply is at least a certain length; a very short reply makes it read leftover memory instead of real data. That leftover memory could contain information the attacker should not see.

What is Info disclosure?

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.

More by chamal

View all

8 more disclosed reports, best first.

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.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.