CVE-2011-2895: Buffer Overflow

Published Aug 2, 2011
·
Updated

BSD compress implemented an LZW compressor and decompressor. This decompressor implementation did not correctly handle compressed streams that contain code words that were not yet added to the decompression table. LZW decompression has a special case (a KwKwK string) when code word may match the first free entry in the decompression table. The implementation used in BSD compress allow code words not only matching, but also exceeding the first free entry.

It seems this compress implementation first appeared in BSD around 1985, and was later used in various other code base, such as ncompress and gzip. Other components that contain affected code will be listed below. Following page list the version of the code as was used in 4.3BSD:

http://minnie.tuhs.org/cgi-bin/utree.pl?file=4.3BSD-Reno/src/usr.bin/compress/compress.c

Relevant code appears in the decompress() routine:

/ Special case for KwKwK string. / if ( code >= freeent ) { stackp++ = finchar; code = oldcode; }

This allows creating a loop in the decompression table, which leads to an "infinite" loop:

/ Generate output characters in reverse order / #ifdef SIGNEDCOMPARESLOW while ( ((unsigned long)code) >= ((unsigned long)256) ) { #else while ( code >= 256 ) { #endif stackp++ = tabsuffixof(code); code = tabprefixof(code); }

where tabprefixof is:

unsigned short codetab [HSIZE]; #define codetabof(i) codetab[i] #define tabprefixof(i) codetabof(i)

This overflows destack "buffer" (part of the htab[]):

countint htab [HSIZE]; # define tabsuffixof(i) ((chartype )(htab))[i] # define destack ((chartype )&tabsuffixof(1<<BITS))

Depending on the relative htab[] and codetab[] positions, destack overflow may overwrite codetab[] entries, which may break infinite loop and let program continue its execution with possibly corrupted memory.

Other sources

The LZW decompressor in (1) the BufCompressedFill function in fontfile/decompress.c in X.Org libXfont before 1.4.4 and (2) compress/compress.c in 4.3BSD, as used in zopen.c in OpenBSD before 3.8, FreeBSD, NetBSD 4.0.x and 5.0.x before 5.0.3 and 5.1.x before 5.1.1, FreeType 2.1.9, and other products, does not properly handle code words that are absent from the decompression table when encountered, which allows context-dependent attackers to trigger an infinite loop or a heap-based buffer overflow, and possibly execute arbitrary code, via a crafted compressed stream, a related issue to CVE-2006-1168 and CVE-2011-2896.

MITRE

Affected Software

40 affected components
FreeType FreeType=2.1.9
X libXfont<=1.4.3
X libXfont=1.2.0
X libXfont=1.2.1
X libXfont=1.2.2
X libXfont=1.2.3
X libXfont=1.2.4
X libXfont=1.2.5
X libXfont=1.2.6
X libXfont=1.2.7
X libXfont=1.2.8
X libXfont=1.2.9
X libXfont=1.3.0
X libXfont=1.3.1
X libXfont=1.3.2
X libXfont=1.3.3
X libXfont=1.3.4
X libXfont=1.4.0
X libXfont=1.4.1
X libXfont=1.4.2
FreeBSD FreeBSD
NetBSD NetBSD
OpenBSD OpenBSD<=3.7
OpenBSD OpenBSD=2.0
OpenBSD OpenBSD=2.1
OpenBSD OpenBSD=2.2
OpenBSD OpenBSD=2.3
OpenBSD OpenBSD=2.4
OpenBSD OpenBSD=2.5
OpenBSD OpenBSD=2.6
OpenBSD OpenBSD=2.7
OpenBSD OpenBSD=2.8
OpenBSD OpenBSD=2.9
OpenBSD OpenBSD=3.0
OpenBSD OpenBSD=3.1
OpenBSD OpenBSD=3.2
OpenBSD OpenBSD=3.3
OpenBSD OpenBSD=3.4
OpenBSD OpenBSD=3.5
OpenBSD OpenBSD=3.6

Event History

Aug 2, 2011
Data Sourced
via Red Hat·04:00 PM
DescriptionSeverityAffected Software
Aug 19, 2011
CVE Published
via MITRE·05:00 PM
Data Sourced
via MITRE·05:00 PM
Description
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2011-2895?

CVE-2011-2895 is classified as a high severity vulnerability due to its potential impact on security.

2

How do I fix CVE-2011-2895?

To fix CVE-2011-2895, upgrade the affected software to versions that have addressed the vulnerability.

3

Which software is affected by CVE-2011-2895?

CVE-2011-2895 affects FreeType 2.1.9 and multiple versions of the X.Org LibXfont library.

4

What type of vulnerability is CVE-2011-2895?

CVE-2011-2895 is a decompression vulnerability in the LZW compressor and decompressor implementation.

5

Can CVE-2011-2895 be exploited remotely?

Yes, CVE-2011-2895 can be exploited remotely if an attacker sends specially crafted compressed streams.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203