Skip to content
Memory corruption Disclosed report Advanced CVE-2017-5436

Graphite2 FeatureRef::applyValToFeature heap overflow

A specially crafted Graphite font feature table causes a heap overflow in the FeatureRef::applyValToFeature function because the code reserves one element too few in a bitmap vector. An attacker could use this to achieve remote code execution, as demonstrated by proof-of-concept files that calculate a library base address and crash with a controlled jump.

Holger Fuhrmannek Follow

Originally disclosed on Mozilla

Critical View original
  • Fixed in 8 days
  • Paid in 2 months
  • Disclosed after 8 days
Text
Created attachment 8844899
poc1.html

A graphite font with a specially crafted feature table can cause a heap overflow which is exploitable to archive remote code execution.

The vulnerability exists in FeatureRef::applyValToFeature in the graphite 2 library. Before accessing data FeatureRef::applyValToFeature tries to ensure that the capacity of the pDest Vector is sufficient through a call to Vector ::reserve but it reserves one too few because the variable m_index is used for the call to Vector::reserve and for accessing the Vector data. This leads to the possibility of a 1-32 bit overflow because the vector is used as a bit map.

The attached pocs work with https://ftp.mozilla.org/pub/firefox/releases/52.0/linux-x86_64/en-US/firefox-52.0.tar.bz2 and show the possibility to exploit the vulnerability to archive remote code execution:

- poc1 calculates the base address for the xul library
- poc2 crashes with a jump to 0x4141414141414141

The original report as published on Mozilla's Bugzilla, by Holger Fuhrmannek. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The code calls Vector::reserve using m_index but then accesses the vector at that same index, so it reserves one slot too few and writes past the end of the bitmap.

Impact

The heap overflow could be exploited to achieve remote code execution, and the proof of concept shows a controlled jump to an attacker-chosen address.

What the attacker needed

Victim loads a crafted font; affected Firefox 52.0 build

How it was found

  1. Open the crafted font in the affected Firefox build.
  2. The font's feature table triggers the undersized reserve in applyValToFeature.
  3. The out-of-bounds write corrupts heap memory.
  4. The proof of concept calculates the base address of the xul library.
  5. A second proof of concept crashes with a jump to a controlled address.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A font file can contain extra data that a program reads to draw text. In this case the program miscounts how much space it needs to store some of that data, so it writes past the end of its buffer. That lets an attacker control memory and potentially run their own code.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More by Holger Fuhrmannek

View all

32 more disclosed reports, best first.

More from Mozilla

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.