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

Graphite2 lz4::decompress out of bounds write

On 32-bit systems, the LZ4 decompression routine in the Graphite2 font library can read and write past the end of a heap buffer when processing a crafted compressed font table. An attacker could trigger out-of-bounds memory access, potentially leading to memory corruption or a crash.

Holger Fuhrmannek Follow

Originally disclosed on Mozilla

  • Fixed in 49 days
  • Paid in 59 days
  • Disclosed after 49 days
Text
Created attachment 8849662
grlz432bit.poc.zip

On 32 bit systems an out of bounds write read/write can occur during the decompressing of a lz4 compressed graphite font table.

valgrind log (with gr2fonttest tool):

Invalid read of size 16
   at 0x4048550: lz4::decompress(void const*, unsigned int, void*, unsigned int) (in /src/libgraphite2.so.3.0.1)
 Address 0x685218d is 16,843,109 bytes inside a block of size 16,843,117 alloc'd
   at 0x402D17C: malloc 
   by 0x4049567: graphite2::Face::Table::decompress() (in /src/libgraphite2.so.3.0.1)

Invalid read of size 16
   at 0x4048555: lz4::decompress(void const*, unsigned int, void*, unsigned int) (in /src/libgraphite2.so.3.0.1)
 Address 0x685219d is 8 bytes after a block of size 16,843,117 alloc'd
   at 0x402D17C: malloc 
   by 0x4049567: graphite2::Face::Table::decompress() (in /src/libgraphite2.so.3.0.1)

Invalid write of size 8
   at 0x404855A: lz4::decompress(void const*, unsigned int, void*, unsigned int) (in /src/libgraphite2.so.3.0.1)
 Address 0x6852195 is 0 bytes after a block of size 16,843,117 alloc'd
   at 0x402D17C: malloc 
   by 0x4049567: graphite2::Face::Table::decompress() (in /src/libgraphite2.so.3.0.1)

Invalid write of size 8
   at 0x404855E: lz4::decompress(void const*, unsigned int, void*, unsigned int) (in /src/libgraphite2.so.3.0.1)
 Address 0x685219d is 8 bytes after a block of size 16,843,117 alloc'd
   at 0x402D17C: malloc 
   by 0x4049567: graphite2::Face::Table::decompress() (in /src/libgraphite2.so.3.0.1)

Invalid read of size 16
   at 0x4048567: lz4::decompress(void const*, unsigned int, void*, unsigned int) (in /src/libgraphite2.so.3.0.1)
 Address 0x68521ad is 16,843,141 bytes inside a block of size 16,846,784 in arena "client"

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

Likely the LZ4 decompressor did not properly validate the output length against the allocated buffer size on 32-bit systems, allowing reads and writes past the buffer end.

Impact

An attacker could cause out-of-bounds reads and writes in the decompressor, which may lead to memory corruption or a crash; the report only demonstrates this on 32-bit systems.

What the attacker needed

32-bit system; crafted compressed font table

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.

Fonts can contain compressed data, and the library that unpacks it must check sizes carefully. Here, on 32-bit systems, the unpacking code trusted a size and wrote past the end of a memory buffer, which can corrupt memory or crash the program.

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.