First published: Wed Aug 03 2011(Updated: )
GIF image file format readers in various open source projects are based on the GIF decoder implementation written by David Koblas. This implementation contains a bug in the LZW decompressor, causing it to in 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 this GIF reading code allows code words not only matching, but also exceeding the first free entry. This problem is identical to a bug found in BSD compress (<a href="https://access.redhat.com/security/cve/CVE-2011-2895">CVE-2011-2895</a>, <a class="bz_bug_link bz_status_CLOSED bz_closed bz_public " title="CLOSED ERRATA - CVE-2011-2895 BSD compress LZW decoder buffer overflow" href="show_bug.cgi?id=727624">bug #727624</a>), but given the unclear relationship between BSD compress and GIF decoder code bases, separate CVE is used here. Several projects refer to pbmplus as the source form where GIF reading code was taken: <a href="http://www.acme.com/software/pbmplus/">http://www.acme.com/software/pbmplus/</a> In pbmplus version of the code, the flaw can be found in LWZReadByte(): if (code >= max_code) { *sp++ = firstcode; code = oldcode; } This allows creating a loop in the decompression table, which leads to an "infinite" loop: while (code >= clear_code) { *sp++ = table[1][code]; if (code == table[0][code]) pm_error("circular table entry BIG ERROR"); code = table[0][code]; } where: #define MAX_LWZ_BITS 12 static int table[2][(1<< MAX_LWZ_BITS)]; static int stack[(1<<(MAX_LWZ_BITS))*2], *sp; sp = stack; This results in stack[] buffer overflow. If table[][] is located above stack[], stack[] overflow may further modify decoding table and break infinite loop.
Credit: secalert@redhat.com
Affected Software | Affected Version | How to fix |
---|---|---|
Swi-prolog Swi-prolog | <=5.10.4 | |
Apple Cups | <=1.4.6 | |
GIMP GIMP | <=2.6.11 |
Sign up to SecAlerts for real-time vulnerability data matched to your software, aggregated from hundreds of sources.