Red Hat Bugzilla – Bug 800591
CVE-2012-1133 freetype: heap buffer underflow in BDF parser _bdf_parse_glyphs() (#35607)
Last modified: 2016-11-08 11:04:25 EST
An out-of heap-based buffer write flaw was found in the way FreeType font rendering engine performed parsing of glyph information and bitmaps for certain glyph bitmap distribution format (BDF) fonts. A remote attacker could provide a specially-crafted BDF font file, which once opened in an application linked against FreeType would lead to that application crash, or, potentially, arbitrary code execution with the privileges of the user running the application.
Upstream bug report:
Red Hat would like to thank Mateusz Jurczyk of the Google Security Team for reporting this issue.
Added CVE as per http://www.openwall.com/lists/oss-security/2012/03/06/16
This issue did NOT affect the versions of the freetype package, as shipped with Red Hat Enterprise Linux 5 and 6.
This issue affects the versions of the freetype package, as shipped with Fedora release of 15 and 16.
This problem is triggered by a negative value of the glyph's ENCODING parameter and can cause freetype to index glyphs array (an array of bdf_glyph_t) using index -1. The glyph structure is both read and written to.
It seems this issue existed in old freetype versions. It was later resolved via the following commit:
That commit addresses a security issue CVE-2006-1861 (bug 484437, bug 190593) related to the large ENCODING values causing buffer overflow. The fix ensures that ENCODING value is not negative and not too large.
The fix was backported to freetype packages in Red Hat Enterprise Linux 2.1, 3, and 4:
The freetype packages in Red Hat Enterprise Linux 5 and 6 are based on upstream versions that include the fix.
However, the fix introduced a regression and caused valid ENCODING value of -1 to be rejected as invalid. This was reported upstream and resolved via:
That regression fix re-introduced the security problem. The regression fix is no included in freetype packages in Red Hat Enterprise Linux 4, 5 and 6.
Not vulnerable. This issue did not affect freetype packages as shipped with Red Hat Enterprise Linux 3, 4, 5, and 6.
(In reply to comment #8)
> It seems this issue existed in old freetype versions. It was later resolved
> via the following commit:
Note there is additional follow up patch:
That patch add explicit conversion of p->glyph_enc to size_t for comparison (which causes negative values to be converted to large positive unsigned value). However, as glyph_enc is (signed) long and the right side of the comparison is of the size_t type, gcc does implicit conversion of the p->glyph_enc to unsigned long and hence error is reported.
> The freetype packages in Red Hat Enterprise Linux 5 and 6 are based on
> upstream versions that include the fix.
freetype packages in Red Hat Enterprise Linux 5 and 6 include explicit conversion to size_t, patch that was added to earlier Red Hat Enterprise Linux versions does not include explicit type conversion.