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

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #43590: FreeType 2.5.3 SFNT parsing integer overflows

Submitter:  Mateusz Jurczyk <j00ru>
Submitted:  Wed 12 Nov 2014 05:43:02 PM UTC
 
Severity:  3 - Normal Item Group:  Incorrect behaviour
Status:  Fixed Privacy:  Public
Assigned to:  wl Open/Closed:  Closed
Planned Release:  2.5.4
* Mandatory Fields

Add a New Comment (Rich Markup)
   

Comment Type & Canned Response:
       No canned response available

 

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 Administrator
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 Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

     

     

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-11-12 wl StatusNone Fixed
        PrivacyPrivate Public
        Assigned toNone wl
        Open/ClosedOpen Closed
        Planned ReleaseNone 2.5.4

    Back to the top


    Powered by Savane 3.9