Skip to content
Memory corruption Disclosed report Intermediate CVE-2018-12379

Invalid memcpy in mar_read.c

A MAR update file with an extremely long item filename causes an integer overflow in the filename length, leading to a negative-size memcpy. An attacker could trigger an out-of-bounds read or write by supplying a crafted update file.

Holger Fuhrmannek Follow

Originally disclosed on Mozilla

  • Fixed in 33 days
  • Paid in 49 days
  • Disclosed after 33 days
Text
Created attachment 8989519
update.mar.zip

By opening a mar file which contains a very long item file name (length = max int) it's possible to trigger an invalid memcpy call. This can lead to an out-of-bounds read/write.
To reproduce extract the update.mar and try an update with an 64bit updater or use the mar tool like 'mar -t ./update.mar'

ASAN-Log:

==11754==ERROR: AddressSanitizer: negative-size-param: (size=-2147483648)
    #0 0x4bdeb4 in __asan_memcpy moz-toolchain/src/llvm/projects/compiler-rt/lib/asan/asan_interceptors_memintrinsics.cc:23:3
    #1 0x500c2a in mar_insert_item  src/modules/libmar/src/mar_read.c:44:3
    #2 0x500c2a in mar_consume_index  src/modules/libmar/src/mar_read.c:109
    #3 0x500c2a in mar_read_index  src/modules/libmar/src/mar_read.c:142
    #4 0x500c2a in mar_fpopen  src/modules/libmar/src/mar_read.c:164
    #5 0x500c2a in mar_open  src/modules/libmar/src/mar_read.c:182
    #6 0x4efa94 in ArchiveReader::Open(char const*)  src/toolkit/mozapps/update/updater/archivereader.cpp:209:14
    #7 0x4f908d in UpdateThreadFunc(void*)  src/toolkit/mozapps/update/updater/updater.cpp:2480:27
...

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 an integer overflow when adding the filename length to a header size, producing a negative size passed to memcpy.

Impact

This could lead to an out-of-bounds read or write, potentially allowing memory corruption or a crash.

What the attacker needed

Ability to supply a crafted MAR file

How it was found

  1. Extract the provided update.mar file.
  2. Run a 64-bit updater or the mar tool with the test option on the file.

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 MAR file is a package used to deliver software updates. The program that reads it trusts a length value in the file; if that value is huge, a calculation wraps around to a negative number, and a memory copy goes wrong. This can crash the updater or potentially let an attacker read or write memory outside the intended buffer.

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.