Two Exploitable Overflows in PINE (message/external-body type, e-mail headers)
11 Sep. 2003
Summary
PINE (The Program for Internet News & Email) is "a popular e-mail client shipped with many Linux and UNIX distributions. It was developed at the University of Washington".
PINE contains two exploitable vulnerabilities that can be triggered when a victim opens a specially crafted email sent by an attacker.
Vulnerable Systems:
* PINE version 4.56 and earlier is vulnerable.
Immune Systems:
* PINE version 4.58
Buffer Overflow:
A remotely exploitable buffer overflow exists within the parsing of the message/external-body type attribute name/value pairs. Failure to check that the length of the longest attribute is less than the space available allows a maliciously formed e-mail message to overwrite control structures. Careful modification of these values allows arbitrary code execution. However, exploitation requires knowledge of the targeted version of PINE.
A 20kb character array is declared as:
headers.h: #define SIZEOF_20KBUF (20480)
pine.c: char tmp_20k_buf[SIZEOF_20KBUF];
The tmp_20k_buf[] array is stored within the .bss section and referenced with a character pointer 'd'. The overflow occurs within the following snippet of code from the display_parameters() routine in mailview.c: d = tmp_20k_buf;
if(parmlist = rfc2231_newparmlist(params)){
while(rfc2231_list_params(parmlist) && d < tmp_20k_buf + 10000){
sprintf(d, "%-*s: %s\n", longest, parmlist->attrib,
parmlist->value ? strsquish(tmp_20k_buf + 11000,
parmlist->value, 100)
: "");
d += strlen(d);
}
Starting at 'd', the code adds spaces to the left of the string as padding to make the total length of the parameter attribute string equal to that of the 'longest'. Later displaying the Attribute name/value pairs. Example: Access-Type: ftp
URL: ftp://localhost/pub/interesting.ps
Supplying any attribute name that is over 20kb in length will overflow the buffer, eventually allowing for arbitrary code execution.
Integer Overflow:
A remotely exploitable integer overflow exists in the parsing of e-mail headers, allowing for arbitrary code execution upon the opening of a malicious e-mail. The vulnerability exists within the rfc2231_get_param() routine found in the strings.c file. A character array of size 64 is declared:
The variable 'n' is attacker-controlled and can be set to contain a negative value that satisfies the if statement yet references an out-of-bounds index within the pieces[] array. Arbitrary code execution is possible by storing assembly code within the parms->value structure and writing beyond the 64-byte character array, thereby overwriting the stored instruction pointer on the stack.
Disclosure Timeline:
15 AUG 2003 Issues acquired by iDEFENSE
25 AUG 2003 Issues disclosed to pine@cac.washington.edu
25 AUG 2003 Response from Mark Crispin, University of Washington
26 AUG 2003 Issues disclosed to iDEFENSE clients
04 SEP 2003 Issues disclosed to Linux vendors: vendor-sec@lst.de
10 SEP 2003 Coordinated Public Disclosure
CVE Information:
CAN-2003-0720: PINE buffer overflow in its handling of the 'message/external-body' type.
CAN-2003-0721: PINE integer overflow in MIME header parsing.