Rapid7 Vulnerability & Exploit Database

WordPress PHPMailer Host Header Command Injection

Back to Search

WordPress PHPMailer Host Header Command Injection



This module exploits a command injection vulnerability in WordPress version 4.6 with Exim as an MTA via a spoofed Host header to PHPMailer, a mail-sending library that is bundled with WordPress. A valid WordPress username is required to exploit the vulnerability. Additionally, due to the altered Host header, exploitation is limited to the default virtual host, assuming the header isn't mangled in transit. If the target is running Apache 2.2.32 or 2.4.24 and later, the server may have HttpProtocolOptions set to Strict, preventing a Host header containing parens from passing through, making exploitation unlikely.


  • Dawid Golunski
  • wvu <wvu@metasploit.com>




x86, x64


Module Options

To display the available options, load the module within the Metasploit console and run the commands 'show options' or 'show advanced':

msf > use exploit/unix/webapp/wp_phpmailer_host_header
msf exploit(wp_phpmailer_host_header) > show targets
msf exploit(wp_phpmailer_host_header) > set TARGET < target-id >
msf exploit(wp_phpmailer_host_header) > show options
    ...show and set options...
msf exploit(wp_phpmailer_host_header) > exploit

Time is precious, so I don’t want to do something manually that I can automate. Leveraging the Metasploit Framework when automating any task keeps us from having to re-create the wheel as we can use the existing libraries and focus our efforts where it matters.

– Jim O’Gorman | President, Offensive Security