New issue
Advanced search Search tips
Starred by 2 users
Status: Fixed
Owner:
Closed: Nov 2014
Cc:



Sign in to add a comment
FreeType 2.5.3 Mac FOND resource parsing out-of-bounds read from stack
Project Member Reported by mjurczyk@google.com, Nov 5 2014 Back to list
In the freetype/src/base/ftmac.c file used exclusively to process Mac font files, the following code operating on FOND resources is present (function "parse_fond"):

433:      unsigned short  string_count;
434:      char            ps_name[256];
435:      unsigned char*  names[64];
...
439:      string_count = EndianS16_BtoN( *(short*)(p) );
...
464:          unsigned char*  suffixes = names[style->indexes[face_index] - 1];
465:
466:
467:          for ( i = 1; i <= suffixes[0]; i++ )
468:          {
469:            unsigned char*  s;
470:            size_t          j = suffixes[i] - 1;
471:
472:
473:            if ( j < string_count && ( s = names[j] ) != NULL )
474:            {
475:              size_t  s_len = (size_t)s[0];
476:
477:
478:              if ( s_len != 0 && ps_name_len + s_len < sizeof ( ps_name ) )
479:              {
480:                ft_memcpy( ps_name + ps_name_len, s + 1, s_len );
481:                ps_name_len += s_len;
482:                ps_name[ps_name_len] = 0;
483:              }
484:            }
485:          }

Note that the "names" array is 64 entry long, while the "string_count" variable stores a 16-bit controlled value. In line 473, the value of "j" (which is a controlled 8-bit value) is only checked against string_count but not against 64 (ARRAYSIZE(names)) before being used as an index into names[]. Therefore, it is possible to cause an out-of-bounds read in the "s = names[j]" expression, with j ranging between 64 .. 254 and -1. Further on, the invalid pointer can be further used to obtain a part of the PostScript font name and copy it into "ps_name" in line 480. This can lead to Denial of Service through library crash, or potentially memory disclosure, if the font name can be propagated back to the attacker.

The bug was identified through manual source code review, thus a proof of concept sample is not available at the time of this writing.
 
Project Member Comment 1 by mjurczyk@google.com, Nov 5 2014
Reported in https://savannah.nongnu.org/bugs/?43540.
Comment 3 by cevans@google.com, Jan 26 2015
Labels: -Restrict-View-Commit
All fixed by upstream:

FreeType 2.5.5

2014-12-30
FreeType 2.5.5 has been released. This is a minor bug fix release: All users of PCF fonts should update, since version 2.5.4 introduced a bug that prevented reading of such font files if not compressed.

FreeType 2.5.4

2014-12-06
FreeType 2.5.4 has been released. All users should upgrade due to another fix for vulnerability CVE-2014-2240 in the CFF driver. The library also contains a new round of patches for better protection against malformed fonts.

The main new feature, which is also one of the targets mentioned in the pledgie roadmap below, is auto-hinting support for Devanagari and Telugu, two widely used Indic scripts. A more detailed description of the remaining changes and fixes can be found here.


Project Member Comment 4 by mjurczyk@google.com, Feb 25 2015
Labels: CVE-2014-9672
Project Member Comment 5 by mjurczyk@google.com, Apr 20 2015
Labels: Fixed-2014-Nov-26
Comment 6 Deleted
FreeType 2.5.4

2014-12-10
FreeType 2.5.4 has been released. All users should upgrade due to another fix for vulnerability CVE-2014-2240 in the CFF driver. The library also contains a new round of patches for better protection against malformed fonts.

http://www.wdfshare.com
Sign in to add a comment