bugThe FreeType Project - Bugs: bug #43590, FreeType 2.5.3 SFNT parsing...

 
 

bug #43590: FreeType 2.5.3 SFNT parsing integer overflows

Submitted by:  Mateusz Jurczyk <j00ru>
Submitted on:  Wed 12 Nov 2014 05:43:02 PM UTC  
 
Severity: 3 - NormalItem Group: Incorrect behaviour
Status: FixedPrivacy: Public
Assigned to: Werner LEMBERG <wl>Open/Closed: Closed
Planned Release: 2.5.4

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Thu 13 Nov 2014 08:15:14 AM UTC, comment #2:

The fix LGTM, thanks!

Mateusz Jurczyk <j00ru>
Project Member
Wed 12 Nov 2014 08:29:00 PM UTC, comment #1:

Thanks for the report. Fixed in git, please test.

Werner LEMBERG <wl>
Project AdministratorIn charge of this item.
Wed 12 Nov 2014 05:43:02 PM UTC, original submission:

In the freetype/src/sfnt/ttload.c file responsible for handling SFNT tables, there are potential integer overflow conditions in the following code snippets:

209: /* we ignore invalid tables */
210: if ( table.Offset + table.Length > stream->size )
211: {
212: FT_TRACE2(( "check_table_dir: table entry %d invalid\n", nn ));
213: continue;
214: }
215: else
216: valid_entries++;

and

397: /* ignore invalid tables */
398: if ( entry->Offset + entry->Length > stream->size )
399: continue;
400: else
401: {
402: FT_TRACE2(( " %c%c%c%c %08lx %08lx %08lx\n",
403: (FT_Char)( entry->Tag >> 24 ),
404: (FT_Char)( entry->Tag >> 16 ),
405: (FT_Char)( entry->Tag >> 8 ),
406: (FT_Char)( entry->Tag ),
407: entry->Offset,
408: entry->Length,
409: entry->CheckSum ));
410: entry++;
411: }

Since both "Offset" and "Length" fields are fully controlled 32-bit unsigned integers, their sum can overflow the integer ranges on 32-bit builds of FreeType, effectively bypassing the sanity above checks.

The full consequence of not correctly filtering out such malformed tables is not fully understood; we assume, however, that the worst that could happen as a result of this issue is an out-of-bounds read from the table of an allegedly enormous size (while in reality much smaller). We believe installing proper bounds checking should be a good defense-in-depth measure to prevent further bugs related to such bogus table headers.

Mateusz Jurczyk <j00ru>
Project Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by wl (Posted a comment)
  • -unavailable- added by j00ru (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 12 Nov 2014 08:29:00 PM UTCwlStatusNone=>Fixed
      PrivacyPrivate=>Public
      Assigned toNone=>wl
      Open/ClosedOpen=>Closed
      Planned ReleaseNone=>2.5.4

    Back to the top


    Powered by Savane 3.1-cleanup1