Skip to content
Memory corruption Advisory Advanced CVE-2024-7973

Heap buffer overflow in PDFium (CVE-2024-7973)

soiax Follow

Originally disclosed on Chrome VRP

Bounty$7,000 Medium View original
  • Fix shipped in 3 months

The attached testcase crashes asan builds of pdfium/chrome on linux/windows:

Output of chromium-127.0.6521.0-win64-asan\pdfium_test.exe:

==34504==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x12be0a234a04 at pc 0x7ff6bae2dbdc bp 0x0074deb1deb0 sp 0x0074deb1def8
READ of size 3 at 0x12be0a234a04 thread T0
==34504==WARNING: Failed to use and restart external symbolizer!
    #0 0x7ff6bae2dbdb in __asan_memcpy C:\b\s\w\ir\cache\builder\src\third_party\llvm\compiler-rt\lib\asan\asan_interceptors_memintrinsics.cpp:63
    #1 0x7ff6b7449f90 in CPDF_DIB::LoadJpxBitmap C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\page\cpdf_dib.cpp:778
    #2 0x7ff6b74427f2 in CPDF_DIB::CreateDecoder C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\page\cpdf_dib.cpp:529
    #3 0x7ff6b7444f56 in CPDF_DIB::StartLoadDIBBase C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\page\cpdf_dib.cpp:311
    #4 0x7ff6b7479878 in CPDF_PageImageCache::Entry::StartGetCachedBitmap C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\page\cpdf_pageimagecache.cpp:272
    #5 0x7ff6b7478f6c in CPDF_PageImageCache::StartGetCachedBitmap C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\page\cpdf_pageimagecache.cpp:185
    #6 0x7ff6b746a941 in CPDF_ImageLoader::Start C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\page\cpdf_imageloader.cpp:35
    #7 0x7ff6b74c27e2 in CPDF_ImageRenderer::StartLoadDIBBase C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\render\cpdf_imagerenderer.cpp:68
    #8 0x7ff6b74c8804 in CPDF_ImageRenderer::Start C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\render\cpdf_imagerenderer.cpp:186
    #9 0x7ff6b74de7c3 in CPDF_RenderStatus::ContinueSingleObject C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\render\cpdf_renderstatus.cpp:271
    #10 0x7ff6b74cc1e5 in CPDF_ProgressiveRenderer::Continue C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\render\cpdf_progressiverenderer.cpp:92
    #11 0x7ff6b679dd3b in `anonymous namespace'::RenderPageImpl C:\b\s\w\ir\cache\builder\src\third_party\pdfium\fpdfsdk\cpdfsdk_renderpage.cpp:84
    #12 0x7ff6b679e0ff in CPDFSDK_RenderPageWithContext C:\b\s\w\ir\cache\builder\src\third_party\pdfium\fpdfsdk\cpdfsdk_renderpage.cpp:113
    #13 0x7ff6b67b56e5 in FPDF_RenderPageBitmapWithColorScheme_Start C:\b\s\w\ir\cache\builder\src\third_party\pdfium\fpdfsdk\fpdf_progressive.cpp:69
    #14 0x7ff6b674bfec in `anonymous namespace'::ProgressiveBitmapPageRenderer::Start C:\b\s\w\ir\cache\builder\src\third_party\pdfium\testing\pdfium_test.cc:1076
    #15 0x7ff6b6743f79 in main C:\b\s\w\ir\cache\builder\src\third_party\pdfium\testing\pdfium_test.cc:2006
    #16 0x7ff6bb8422e7 in __scrt_common_main_seh D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
    #17 0x7ffc5bc27343 in BaseThreadInitThunk+0x13 (C:\Windows\System32\KERNEL32.DLL+0x180017343)
    #18 0x7ffc5c8a26b0 in RtlUserThreadStart+0x20 (C:\Windows\SYSTEM32\ntdll.dll+0x1800526b0)

0x12be0a234a04 is located 0 bytes after 82436-byte region [0x12be0a220800,0x12be0a234a04)
allocated by thread T0 here:
    #0 0x7ff6bae2c484 in calloc C:\b\s\w\ir\cache\builder\src\third_party\llvm\compiler-rt\lib\asan\asan_malloc_win.cpp:114
    #1 0x7ff6b6c53222 in CFX_DIBitmap::Create C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fxge\dib\cfx_dibitmap.cpp:66
    #2 0x7ff6b6c52db9 in CFX_DIBitmap::Create C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fxge\dib\cfx_dibitmap.cpp:38
    #3 0x7ff6b7449790 in CPDF_DIB::LoadJpxBitmap C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\page\cpdf_dib.cpp:731
    #4 0x7ff6b74427f2 in CPDF_DIB::CreateDecoder C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\page\cpdf_dib.cpp:529
    #5 0x7ff6b7444f56 in CPDF_DIB::StartLoadDIBBase C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\page\cpdf_dib.cpp:311
    #6 0x7ff6b7479878 in CPDF_PageImageCache::Entry::StartGetCachedBitmap C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\page\cpdf_pageimagecache.cpp:272
    #7 0x7ff6b7478f6c in CPDF_PageImageCache::StartGetCachedBitmap C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\page\cpdf_pageimagecache.cpp:185
    #8 0x7ff6b746a941 in CPDF_ImageLoader::Start C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\page\cpdf_imageloader.cpp:35
    #9 0x7ff6b74c27e2 in CPDF_ImageRenderer::StartLoadDIBBase C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\render\cpdf_imagerenderer.cpp:68
    #10 0x7ff6b74c8804 in CPDF_ImageRenderer::Start C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\render\cpdf_imagerenderer.cpp:186
    #11 0x7ff6b74de7c3 in CPDF_RenderStatus::ContinueSingleObject C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\render\cpdf_renderstatus.cpp:271
    #12 0x7ff6b74cc1e5 in CPDF_ProgressiveRenderer::Continue C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\render\cpdf_progressiverenderer.cpp:92
    #13 0x7ff6b679dd3b in `anonymous namespace'::RenderPageImpl C:\b\s\w\ir\cache\builder\src\third_party\pdfium\fpdfsdk\cpdfsdk_renderpage.cpp:84
    #14 0x7ff6b679e0ff in CPDFSDK_RenderPageWithContext C:\b\s\w\ir\cache\builder\src\third_party\pdfium\fpdfsdk\cpdfsdk_renderpage.cpp:113
    #15 0x7ff6b67b56e5 in FPDF_RenderPageBitmapWithColorScheme_Start C:\b\s\w\ir\cache\builder\src\third_party\pdfium\fpdfsdk\fpdf_progressive.cpp:69
    #16 0x7ff6b674bfec in `anonymous namespace'::ProgressiveBitmapPageRenderer::Start C:\b\s\w\ir\cache\builder\src\third_party\pdfium\testing\pdfium_test.cc:1076
    #17 0x7ff6b6743f79 in main C:\b\s\w\ir\cache\builder\src\third_party\pdfium\testing\pdfium_test.cc:2006
    #18 0x7ff6bb8422e7 in __scrt_common_main_seh D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
    #19 0x7ffc5bc27343 in BaseThreadInitThunk+0x13 (C:\Windows\System32\KERNEL32.DLL+0x180017343)
    #20 0x7ffc5c8a26b0 in RtlUserThreadStart+0x20 (C:\Windows\SYSTEM32\ntdll.dll+0x1800526b0)

SUMMARY: AddressSanitizer: heap-buffer-overflow C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\page\cpdf_dib.cpp:778 in CPDF_DIB::LoadJpxBitmap
Shadow bytes around the buggy address:
  0x12be0a234780: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x12be0a234800: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x12be0a234880: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x12be0a234900: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x12be0a234980: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x12be0a234a00:[04]fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x12be0a234a80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x12be0a234b00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x12be0a234b80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x12be0a234c00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x12be0a234c80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==34504==ABORTING

Chrome Version: tested asan builds of 125, 127

Operating System: windows, linux

Attached minimized testcase

Type of crash: tab

Reporter credit: soiax

The original report as published on the Chromium issue tracker, by soiax. Images and videos are our own copies; raw HTML is shown as text. View it on Chromium issue tracker.

The original is short, so this covers everything it reports, then explains this kind of bug in general: how it works, how to test for it and how it is fixed. The general sections are about the bug class, not this target. Written with AI and checked against the original; the original is the record. 8 min read.

What the report shows

This is a Chrome VRP advisory for a heap buffer overflow in PDFium, the PDF rendering library used by Chrome. The researcher, credited as soiax, reported it as a tab crash and it was rated medium severity with a bounty of 7,000 USD. The weakness class is heap buffer overflow, the affected component is PDFium, and the report was disclosed on 21 August 2024.

The researcher attached a minimised testcase and ran it against AddressSanitizer builds of PDFium and Chrome. The crash reproduced on both Linux and Windows, and the report states that Chrome versions 125 and 127 were tested as ASan builds. The output below is from the Windows ASan build of pdfium_test.exe:

Text
==34504==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x12be0a234a04 at pc 0x7ff6bae2dbdc bp 0x0074deb1deb0 sp 0x0074deb1def8
READ of size 3 at 0x12be0a234a04 thread T0
==34504==WARNING: Failed to use and restart external symbolizer!
    #0 0x7ff6bae2dbdb in __asan_memcpy C:\b\s\w\ir\cache\builder\src\third_party\llvm\compiler-rt\lib\asan\asan_interceptors_memintrinsics.cpp:63
    #1 0x7ff6b7449f90 in CPDF_DIB::LoadJpxBitmap C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\page\cpdf_dib.cpp:778
    #2 0x7ff6b74427f2 in CPDF_DIB::CreateDecoder C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\page\cpdf_dib.cpp:529
    #3 0x7ff6b7444f56 in CPDF_DIB::StartLoadDIBBase C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\page\cpdf_dib.cpp:311
    #4 0x7ff6b7479878 in CPDF_PageImageCache::Entry::StartGetCachedBitmap C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\page\cpdf_pageimagecache.cpp:272
    #5 0x7ff6b7478f6c in CPDF_PageImageCache::StartGetCachedBitmap C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\page\cpdf_pageimagecache.cpp:185
    #6 0x7ff6b746a941 in CPDF_ImageLoader::Start C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\page\cpdf_imageloader.cpp:35
    #7 0x7ff6b74c27e2 in CPDF_ImageRenderer::StartLoadDIBBase C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\render\cpdf_imagerenderer.cpp:68
    #8 0x7ff6b74c8804 in CPDF_ImageRenderer::Start C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\render\cpdf_imagerenderer.cpp:186
    #9 0x7ff6b74de7c3 in CPDF_RenderStatus::ContinueSingleObject C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\render\cpdf_renderstatus.cpp:271
    #10 0x7ff6b74cc1e5 in CPDF_ProgressiveRenderer::Continue C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\render\cpdf_progressiverenderer.cpp:92
    #11 0x7ff6b679dd3b in `anonymous namespace'::RenderPageImpl C:\b\s\w\ir\cache\builder\src\third_party\pdfium\fpdfsdk\cpdfsdk_renderpage.cpp:84
    #12 0x7ff6b679e0ff in CPDFSDK_RenderPageWithContext C:\b\s\w\ir\cache\builder\src\third_party\pdfium\fpdfsdk\cpdfsdk_renderpage.cpp:113
    #13 0x7ff6b67b56e5 in FPDF_RenderPageBitmapWithColorScheme_Start C:\b\s\w\ir\cache\builder\src\third_party\pdfium\fpdfsdk\fpdf_progressive.cpp:69
    #14 0x7ff6b674bfec in `anonymous namespace'::ProgressiveBitmapPageRenderer::Start C:\b\s\w\ir\cache\builder\src\third_party\pdfium\testing\pdfium_test.cc:1076
    #15 0x7ff6b6743f79 in main C:\b\s\w\ir\cache\builder\src\third_party\pdfium\testing\pdfium_test.cc:2006
    #16 0x7ff6bb8422e7 in __scrt_common_main_seh D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
    #17 0x7ffc5bc27343 in BaseThreadInitThunk+0x13 (C:\Windows\System32\KERNEL32.DLL+0x180017343)
    #18 0x7ffc5c8a26b0 in RtlUserThreadStart+0x20 (C:\Windows\SYSTEM32\ntdll.dll+0x1800526b0)

0x12be0a234a04 is located 0 bytes after 82436-byte region [0x12be0a220800,0x12be0a234a04)
allocated by thread T0 here:
    #0 0x7ff6bae2c484 in calloc C:\b\s\w\ir\cache\builder\src\third_party\llvm\compiler-rt\lib\asan\asan_malloc_win.cpp:114
    #1 0x7ff6b6c53222 in CFX_DIBitmap::Create C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fxge\dib\cfx_dibitmap.cpp:66
    #2 0x7ff6b6c52db9 in CFX_DIBitmap::Create C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fxge\dib\cfx_dibitmap.cpp:38
    #3 0x7ff6b7449790 in CPDF_DIB::LoadJpxBitmap C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\page\cpdf_dib.cpp:731
    #4 0x7ff6b74427f2 in CPDF_DIB::CreateDecoder C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\page\cpdf_dib.cpp:529
    #5 0x7ff6b7444f56 in CPDF_DIB::StartLoadDIBBase C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\page\cpdf_dib.cpp:311
    #6 0x7ff6b7479878 in CPDF_PageImageCache::Entry::StartGetCachedBitmap C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\page\cpdf_pageimagecache.cpp:272
    #7 0x7ff6b7478f6c in CPDF_PageImageCache::StartGetCachedBitmap C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\page\cpdf_pageimagecache.cpp:185
    #8 0x7ff6b746a941 in CPDF_ImageLoader::Start C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\page\cpdf_imageloader.cpp:35
    #9 0x7ff6b74c27e2 in CPDF_ImageRenderer::StartLoadDIBBase C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\render\cpdf_imagerenderer.cpp:68
    #10 0x7ff6b74c8804 in CPDF_ImageRenderer::Start C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\render\cpdf_imagerenderer.cpp:186
    #11 0x7ff6b74de7c3 in CPDF_RenderStatus::ContinueSingleObject C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\render\cpdf_renderstatus.cpp:271
    #12 0x7ff6b74cc1e5 in CPDF_ProgressiveRenderer::Continue C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\render\cpdf_progressiverenderer.cpp:92
    #13 0x7ff6b679dd3b in `anonymous namespace'::RenderPageImpl C:\b\s\w\ir\cache\builder\src\third_party\pdfium\fpdfsdk\cpdfsdk_renderpage.cpp:84
    #14 0x7ff6b679e0ff in CPDFSDK_RenderPageWithContext C:\b\s\w\ir\cache\builder\src\third_party\pdfium\fpdfsdk\cpdfsdk_renderpage.cpp:113
    #15 0x7ff6b67b56e5 in FPDF_RenderPageBitmapWithColorScheme_Start C:\b\s\w\ir\cache\builder\src\third_party\pdfium\fpdfsdk\fpdf_progressive.cpp:69
    #16 0x7ff6b674bfec in `anonymous namespace'::ProgressiveBitmapPageRenderer::Start C:\b\s\w\ir\cache\builder\src\third_party\pdfium\testing\pdfium_test.cc:1076
    #17 0x7ff6b6743f79 in main C:\b\s\w\ir\cache\builder\src\third_party\pdfium\testing\pdfium_test.cc:2006
    #18 0x7ff6bb8422e7 in __scrt_common_main_seh D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
    #19 0x7ffc5bc27343 in BaseThreadInitThunk+0x13 (C:\Windows\System32\KERNEL32.DLL+0x180017343)
    #20 0x7ffc5c8a26b0 in RtlUserThreadStart+0x20 (C:\Windows\SYSTEM32\ntdll.dll+0x1800526b0)

SUMMARY: AddressSanitizer: heap-buffer-overflow C:\b\s\w\ir\cac

The report also includes the shadow byte map around the faulting address, which shows the access landing in the redzone immediately after the allocation:

Text
Shadow bytes around the buggy address:
  0x12be0a234780: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x12be0a234800: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x12be0a234880: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x12be0a234900: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x12be0a234980: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x12be0a234a00:[04]fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x12be0a234a80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x12be0a234b00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x12be0a234b80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x12be0a234c00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x12be0a234c80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa

The report stops at the crash evidence and the testcase. It does not include the patch, the fixing commit or a root cause analysis.

Root cause

The stack points to CPDF_DIB::LoadJpxBitmap in cpdf_dib.cpp. The faulting operation is a memcpy of 3 bytes reading from an address 0 bytes past the end of an 82436-byte heap region. That region was allocated earlier in the same function through CFX_DIBitmap::Create. In other words, the bitmap buffer is sized from one set of values, and the copy that fills it reads or writes past that size, likely because the dimensions or stride used for the copy do not match the allocation. The report does not state which field of the JPEG 2000 image data is inconsistent.

Impact

The report classifies the crash as a tab crash: rendering a crafted PDF terminates the renderer process. The report does not demonstrate code execution, information disclosure or a sandbox escape. A heap overflow in a renderer is still worth fixing because it is a memory safety defect reachable from untrusted input.

How this kind of bug works

A heap buffer overflow happens when code writes to, or reads from, memory outside the bounds of an allocation. In image decoders the usual pattern is a mismatch between the size computed for the destination buffer and the amount of data the decoder produces. Dimensions, channel count, row stride and bit depth all feed into the allocation size; if any of them is derived differently at allocation time and at copy time, the copy runs past the end. Reads just past the end are caught by ASan because it places redzones around every allocation and checks each access against a shadow map. In production builds without ASan the same access may silently read adjacent heap memory, which is why these bugs are treated as memory corruption rather than mere crashes.

How to test for it

  1. Identify the parsers that handle complex binary formats: image codecs, font engines, document renderers, media demuxers. These are the places where size arithmetic is most fragile.
  2. Obtain a build with sanitizers enabled. For open source components, build the library and its test harness with ASan and run candidate files through it. For browser targets, use the vendor's ASan builds where a program provides them.
  3. Generate or mutate inputs that stress dimension fields: very large and very small widths and heights, odd channel counts, truncated data, and headers whose declared size disagrees with the actual payload.
  4. Watch for sanitizer reports that name a copy or allocation routine and show the access landing in a redzone. A report that says the access is a few bytes past a region allocated in the same call chain is a strong signal.
  5. Minimise the input before reporting, and confirm the crash on more than one platform or build if you can.

Common false positives are out-of-memory conditions, timeouts and assertion failures, which are not memory corruption. A crash inside a third-party library that the target merely links may be out of scope, so check the program's rules first.

How it is fixed

The report does not include the patch, the fixing commit or a root cause analysis, so the fix is not described here.

Hunting notes

This class of bug tends to hide in code that parses attacker-controlled headers describing buffer geometry: image formats, PDF objects, fonts, video containers and archive formats. Recon signals include components with a history of sanitizer findings, recently refactored size calculations, and code paths where a value from the file is used both to allocate and to copy. To make a report accepted, include the sanitizer output, the exact build and version tested, the platforms confirmed, and a minimised testcase. State clearly what the crash is and avoid claiming impact you have not demonstrated.

The original is short, so this covers everything it reports, then explains this kind of bug in general: how it works, how to test for it and how it is fixed. The general sections are about the bug class, not this target. Written with AI and checked against the original; the original is the record. 11 min read.

What happened, in plain words

This is a public bug bounty advisory from the Chrome Vulnerability Reward Program (VRP), the scheme Google runs to pay people who find and report security flaws in Chrome. The flaw is in PDFium, the library Chrome uses to open PDF documents. A researcher credited as soiax found it, reported it as a browser tab crash, and received a bounty of 7,000 USD. The severity was rated medium, the weakness class is a heap buffer overflow, and the report was disclosed on 21 August 2024.

To understand the bug, start with two ideas. A buffer is a block of memory set aside to hold data, like a row of numbered boxes. A heap is the area of memory a program uses for blocks it creates while running, such as the pixels of an image it is about to draw. A heap buffer overflow means the program reads or writes just past the end of one of those blocks, into memory that belongs to something else. Think of writing a name into a form with ten boxes and carrying on into the eleventh: the eleventh box is not yours.

The researcher attached a minimised testcase, meaning a small PDF file trimmed down to the fewest bytes that still trigger the problem, and ran it against special builds of PDFium and Chrome that include AddressSanitizer (ASan). ASan is a debugging tool built into a test build of a program: it puts invisible fences, called redzones, around every memory block and checks each access, so an out-of-bounds read is caught immediately instead of quietly corrupting data. The crash reproduced on both Linux and Windows, and the report says Chrome versions 125 and 127 were tested as ASan builds.

The output below comes from the Windows ASan build of pdfium_test.exe, a small program that renders a PDF file so the library can be exercised on its own:

Text
==34504==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x12be0a234a04 at pc 0x7ff6bae2dbdc bp 0x0074deb1deb0 sp 0x0074deb1def8
READ of size 3 at 0x12be0a234a04 thread T0
==34504==WARNING: Failed to use and restart external symbolizer!
    #0 0x7ff6bae2dbdb in __asan_memcpy C:\b\s\w\ir\cache\builder\src\third_party\llvm\compiler-rt\lib\asan\asan_interceptors_memintrinsics.cpp:63
    #1 0x7ff6b7449f90 in CPDF_DIB::LoadJpxBitmap C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\page\cpdf_dib.cpp:778
    #2 0x7ff6b74427f2 in CPDF_DIB::CreateDecoder C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\page\cpdf_dib.cpp:529
    #3 0x7ff6b7444f56 in CPDF_DIB::StartLoadDIBBase C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\page\cpdf_dib.cpp:311
    #4 0x7ff6b7479878 in CPDF_PageImageCache::Entry::StartGetCachedBitmap C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\page\cpdf_pageimagecache.cpp:272
    #5 0x7ff6b7478f6c in CPDF_PageImageCache::StartGetCachedBitmap C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\page\cpdf_pageimagecache.cpp:185
    #6 0x7ff6b746a941 in CPDF_ImageLoader::Start C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\page\cpdf_imageloader.cpp:35
    #7 0x7ff6b74c27e2 in CPDF_ImageRenderer::StartLoadDIBBase C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\render\cpdf_imagerenderer.cpp:68
    #8 0x7ff6b74c8804 in CPDF_ImageRenderer::Start C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\render\cpdf_imagerenderer.cpp:186
    #9 0x7ff6b74de7c3 in CPDF_RenderStatus::ContinueSingleObject C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\render\cpdf_renderstatus.cpp:271
    #10 0x7ff6b74cc1e5 in CPDF_ProgressiveRenderer::Continue C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\render\cpdf_progressiverenderer.cpp:92
    #11 0x7ff6b679dd3b in `anonymous namespace'::RenderPageImpl C:\b\s\w\ir\cache\builder\src\third_party\pdfium\fpdfsdk\cpdfsdk_renderpage.cpp:84
    #12 0x7ff6b679e0ff in CPDFSDK_RenderPageWithContext C:\b\s\w\ir\cache\builder\src\third_party\pdfium\fpdfsdk\cpdfsdk_renderpage.cpp:113
    #13 0x7ff6b67b56e5 in FPDF_RenderPageBitmapWithColorScheme_Start C:\b\s\w\ir\cache\builder\src\third_party\pdfium\fpdfsdk\fpdf_progressive.cpp:69
    #14 0x7ff6b674bfec in `anonymous namespace'::ProgressiveBitmapPageRenderer::Start C:\b\s\w\ir\cache\builder\src\third_party\pdfium\testing\pdfium_test.cc:1076
    #15 0x7ff6b6743f79 in main C:\b\s\w\ir\cache\builder\src\third_party\pdfium\testing\pdfium_test.cc:2006
    #16 0x7ff6bb8422e7 in __scrt_common_main_seh D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
    #17 0x7ffc5bc27343 in BaseThreadInitThunk+0x13 (C:\Windows\System32\KERNEL32.DLL+0x180017343)
    #18 0x7ffc5c8a26b0 in RtlUserThreadStart+0x20 (C:\Windows\SYSTEM32\ntdll.dll+0x1800526b0)

0x12be0a234a04 is located 0 bytes after 82436-byte region [0x12be0a220800,0x12be0a234a04)
allocated by thread T0 here:
    #0 0x7ff6bae2c484 in calloc C:\b\s\w\ir\cache\builder\src\third_party\llvm\compiler-rt\lib\asan\asan_malloc_win.cpp:114
    #1 0x7ff6b6c53222 in CFX_DIBitmap::Create C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fxge\dib\cfx_dibitmap.cpp:66
    #2 0x7ff6b6c52db9 in CFX_DIBitmap::Create C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fxge\dib\cfx_dibitmap.cpp:38
    #3 0x7ff6b7449790 in CPDF_DIB::LoadJpxBitmap C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\page\cpdf_dib.cpp:731
    #4 0x7ff6b74427f2 in CPDF_DIB::CreateDecoder C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\page\cpdf_dib.cpp:529
    #5 0x7ff6b7444f56 in CPDF_DIB::StartLoadDIBBase C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\page\cpdf_dib.cpp:311
    #6 0x7ff6b7479878 in CPDF_PageImageCache::Entry::StartGetCachedBitmap C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\page\cpdf_pageimagecache.cpp:272
    #7 0x7ff6b7478f6c in CPDF_PageImageCache::StartGetCachedBitmap C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\page\cpdf_pageimagecache.cpp:185
    #8 0x7ff6b746a941 in CPDF_ImageLoader::Start C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\page\cpdf_imageloader.cpp:35
    #9 0x7ff6b74c27e2 in CPDF_ImageRenderer::StartLoadDIBBase C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\render\cpdf_imagerenderer.cpp:68
    #10 0x7ff6b74c8804 in CPDF_ImageRenderer::Start C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\render\cpdf_imagerenderer.cpp:186
    #11 0x7ff6b74de7c3 in CPDF_RenderStatus::ContinueSingleObject C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\render\cpdf_renderstatus.cpp:271
    #12 0x7ff6b74cc1e5 in CPDF_ProgressiveRenderer::Continue C:\b\s\w\ir\cache\builder\src\third_party\pdfium\core\fpdfapi\render\cpdf_progressiverenderer.cpp:92
    #13 0x7ff6b679dd3b in `anonymous namespace'::RenderPageImpl C:\b\s\w\ir\cache\builder\src\third_party\pdfium\fpdfsdk\cpdfsdk_renderpage.cpp:84
    #14 0x7ff6b679e0ff in CPDFSDK_RenderPageWithContext C:\b\s\w\ir\cache\builder\src\third_party\pdfium\fpdfsdk\cpdfsdk_renderpage.cpp:113
    #15 0x7ff6b67b56e5 in FPDF_RenderPageBitmapWithColorScheme_Start C:\b\s\w\ir\cache\builder\src\third_party\pdfium\fpdfsdk\fpdf_progressive.cpp:69
    #16 0x7ff6b674bfec in `anonymous namespace'::ProgressiveBitmapPageRenderer::Start C:\b\s\w\ir\cache\builder\src\third_party\pdfium\testing\pdfium_test.cc:1076
    #17 0x7ff6b6743f79 in main C:\b\s\w\ir\cache\builder\src\third_party\pdfium\testing\pdfium_test.cc:2006
    #18 0x7ff6bb8422e7 in __scrt_common_main_seh D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
    #19 0x7ffc5bc27343 in BaseThreadInitThunk+0x13 (C:\Windows\System32\KERNEL32.DLL+0x180017343)
    #20 0x7ffc5c8a26b0 in RtlUserThreadStart+0x20 (C:\Windows\SYSTEM32\ntdll.dll+0x1800526b0)

SUMMARY: AddressSanitizer: heap-buffer-overflow C:\b\s\w\ir\cac

Read it in three parts. The first line says ASan caught a heap buffer overflow at a particular memory address. The second says the program tried to read 3 bytes there. The numbered lines are the stack trace, a list of function calls from the innermost (__asan_memcpy, the memory copy routine) outwards to main, the program's entry point. The top of the list is where the fault happened: a copy inside CPDF_DIB::LoadJpxBitmap, the function that loads a JPEG 2000 image (the Jpx in the name) into a bitmap. The second block says the address is 0 bytes after an 82436-byte region, and shows where that region was allocated: also inside LoadJpxBitmap, through CFX_DIBitmap::Create. The final SUMMARY line repeats the location, cpdf_dib.cpp:778.

The report also includes the shadow byte map around the faulting address, which shows the access landing in the redzone immediately after the allocation:

Text
Shadow bytes around the buggy address:
  0x12be0a234780: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x12be0a234800: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x12be0a234880: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x12be0a234900: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x12be0a234980: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x12be0a234a00:[04]fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x12be0a234a80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x12be0a234b00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x12be0a234b80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x12be0a234c00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x12be0a234c80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa

Each shadow byte stands for 8 bytes of real memory. 00 means all 8 are inside a valid block; fa marks a redzone, memory that is fenced off. The [04] marks the spot where the read began, right at the edge of the valid region.

Root cause

The stack points to CPDF_DIB::LoadJpxBitmap in cpdf_dib.cpp. The faulting operation is a memcpy of 3 bytes reading from an address 0 bytes past the end of an 82436-byte heap region. That region was allocated earlier in the same function through CFX_DIBitmap::Create. In other words, the bitmap buffer is sized from one set of values, and the copy that fills it reads or writes past that size, likely because the dimensions or stride used for the copy do not match the allocation. The report does not state which field of the JPEG 2000 image data is inconsistent.

Impact

The report classifies the crash as a tab crash: rendering a crafted PDF terminates the renderer process. The report does not demonstrate code execution, information disclosure or a sandbox escape. A heap overflow in a renderer is still worth fixing because it is a memory safety defect reachable from untrusted input.

In general, how this kind of bug works

A heap buffer overflow happens when code writes to, or reads from, memory outside the bounds of an allocation. In image decoders the usual pattern is a mismatch between the size computed for the destination buffer and the amount of data the decoder produces. Dimensions, channel count, row stride and bit depth all feed into the allocation size; if any of them is derived differently at allocation time and at copy time, the copy runs past the end. Reads just past the end are caught by ASan because it places redzones around every allocation and checks each access against a shadow map. In production builds without ASan the same access may silently read adjacent heap memory, which is why these bugs are treated as memory corruption rather than mere crashes.

In general, how to test for it

  1. Identify the parsers that handle complex binary formats: image codecs, font engines, document renderers, media demuxers. These are the places where size arithmetic is most fragile.
  2. Obtain a build with sanitizers enabled. For open source components, build the library and its test harness with ASan and run candidate files through it. For browser targets, use the vendor's ASan builds where a program provides them.
  3. Generate or mutate inputs that stress dimension fields: very large and very small widths and heights, odd channel counts, truncated data, and headers whose declared size disagrees with the actual payload.
  4. Watch for sanitizer reports that name a copy or allocation routine and show the access landing in a redzone. A report that says the access is a few bytes past a region allocated in the same call chain is a strong signal.
  5. Minimise the input before reporting, and confirm the crash on more than one platform or build if you can.

Common false positives are out-of-memory conditions, timeouts and assertion failures, which are not memory corruption. A crash inside a third-party library that the target merely links may be out of scope, so check the program's rules first.

In general, how it is fixed

The report does not include the patch, the fixing commit or a root cause analysis, so the fix is not described here.

In general, hunting notes

This class of bug tends to hide in code that parses attacker-controlled headers describing buffer geometry: image formats, PDF objects, fonts, video containers and archive formats. Recon signals include components with a history of sanitizer findings, recently refactored size calculations, and code paths where a value from the file is used both to allocate and to copy. To make a report accepted, include the sanitizer output, the exact build and version tested, the platforms confirmed, and a minimised testcase. State clearly what the crash is and avoid claiming impact you have not demonstrated.

Glossary

  • Bug bounty: a programme that pays researchers for reporting security flaws.
  • Chrome VRP: Google's Vulnerability Reward Program for Chrome.
  • PDFium: the open source library Chrome uses to render PDF files.
  • Heap: the area of memory a program uses for blocks it creates while running.
  • Buffer: a block of memory set aside to hold data.
  • Heap buffer overflow: reading or writing past the end of a heap block.
  • AddressSanitizer (ASan): a debugging tool in test builds that fences memory blocks and checks every access.
  • Redzone: memory ASan fences off around a block to catch out-of-bounds access.
  • Shadow map: ASan's table recording which memory bytes are valid.
  • Stack trace: the list of function calls leading to a crash, innermost first.
  • memcpy: a routine that copies a number of bytes from one memory location to another.
  • Bitmap: an in-memory grid of pixels.
  • JPEG 2000: an image format, referred to as Jpx in the function name.
  • Stride: the number of bytes between the start of one image row and the next.
  • Bit depth: the number of bits used to store each colour value.
  • Testcase: an input file that triggers the bug, often minimised to the smallest version.
  • Minimised: trimmed down to the fewest bytes that still reproduce the problem.
  • Tab crash: the browser tab's renderer process terminating.
  • Renderer process: the sandboxed process a browser uses to display a page.
  • Sandbox escape: breaking out of that restricted process to reach the rest of the system.
  • Memory corruption: damage to memory that can change program behaviour, not just cause a crash.
  • False positive: a reported issue that is not actually the vulnerability it appears to be.
  • Regression test: a test added to ensure a fixed bug stays fixed.

More by soiax

View all

19 more disclosed reports, best first.

More from Google Chrome

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.