Multiple Vendor chmlib CHM File Handling Buffer Overflow Vulnerability
=20
iDefense Security Advisory 10.28.05
http://www.idefense.com/application/...ulnerabilities
October 28, 2005
=20
I. BACKGROUND
=20
chmlib is a library for dealing with Microsoft ITSS/CHM format files.
=20
II. DESCRIPTION
=20
Remote exploitation of a stack overflow vulnerability in chmlib as=20
included in various Linux distributions allows attackers to execute=20
arbitrary code.
=20
The vulnerability specifically exists due to an unchecked memory copy=20
while processing a CHM file. The vulnerability exists in the following=20
code, which is found in chm_lib.c:=20
=20
static UChar *_chm_find_in_PMGL(UChar *page_buf,
UInt32=20
block_len,
const=20
char *objPath)
{
[...]
char buffer[CHM_MAX_PATHLEN+1]; =20
/* figure out where to start and end */
cur =3D page_buf;
hremain =3D _CHM_PMGL_LEN;
if (! _unmarshal_pmgl_header(&cur, &hremain, &header))
return NULL;
end =3D page_buf + block_len - (header.free_space);
=20
/* now, scan progressively */
while (cur < end)
{
/* grab the name */
temp =3D cur;
strLen =3D _chm_parse_cword(&cur);
if (! _chm_parse_UTF8(&cur, strLen, buffer))
return NULL;
[..]=20
=20
_chm_parse_cword can be forced to return a value larger than=20
CHM_MAX_PATHLEN. This value is then used while copying user controlled=20
data into a CHM_MAX_PATHLEN sized stack buffer. This allows the attacker

full control over execution flow by overwriting the saved return address

on the stack.
=20
III. ANALYSIS
=20
Exploitation could allow attackers to execute arbitrary code with the=20
privileges of the user processing the CHM file. Remote exploitation can=20
be achieved by sending a malicious file in an e-mail message to the=20
target user.
=20
IV. DETECTION
=20
iDefense has confirmed the existence of this vulnerability in chmlib=20
0.35. It is suspected that all versions of chmlib are vulnerable.=20
=20
The following vendors distribute susceptible chmlib packages within=20
their respective operating system distributions:
=20
FreeBSD Project:
FreeBSD 5.4 and prior
Gentoo Foundation Inc.:
Gentoo Linux 1.1a, 1.2, 1.4, 2004.0, 2004.1 and 2004.2=20
=20
V. WORKAROUND
=20
Do not open CHM files sent from an untrusted source.
=20
VI. VENDOR RESPONSE
=20
chmlib-0.36 addresses this vulnerability and is available for download
at:
=20
http://freshmeat.net/projects/chmlib/
=20
VII. CVE INFORMATION
=20
The Common Vulnerabilities and Exposures (CVE) project has assigned the
name CAN-2005-2930 to this issue. This is a candidate for inclusion in
the CVE list (http://cve.mitre.org), which standardizes names for
security problems.
=20
VIII. DISCLOSURE TIMELINE
=20
09/08/2005 Initial vendor notification
09/09/2005 Initial vendor response
10/28/2005 Public disclosure
=20
IX. CREDIT
=20
The discoverer of this vulnerability wishes to remain anonymous.
=20
Get paid for vulnerability research
http://www.iDefense.com/poi/teams/vcp.jsp
=20
Free tools, research and upcoming events
http://labs.iDefense.com
=20
X. LEGAL NOTICES
=20
Copyright (c) 2005 iDefense, Inc.
=20
Permission is granted for the redistribution of this alert
electronically. It may not be edited in any way without the express
written consent of iDefense. If you wish to reprint the whole or any
part of this alert in any other medium other than electronically, please
email customerservice@iDefense.com for permission.
=20
Disclaimer: The information in the advisory is believed to be accurate
at the time of publishing based on currently available information. Use
of the information constitutes acceptance for use in an AS IS condition.
There are no warranties with regard to this information. Neither the
author nor the publisher accepts any liability for any direct, indirect,
or consequential loss or damage arising from use of, or reliance on,
this information.