AddressSanitizer: heap-buffer-overflow [@ sse2_composite_over_x888_8_8888] when print or save to PDF
A crafted HTML page caused a heap-buffer-overflow read in the pixman SSE2 compositing routine when the page was printed or saved to PDF. An attacker could crash the browser (a denial of service) by getting a victim to open the page and print it.
Originally disclosed on Mozilla
- Fixed in 10 days
- Paid in 16 days
- Disclosed after 10 days
Created attachment 9207351 testcase.html
The testcase crashes Firefox ASAN on Linux with SUMMARY: "AddressSanitizer: heap-buffer-overflow /builds/worker/checkouts/gecko/gfx/cairo/libpixman/src/pixman-sse2.c:4919:13 in sse2_composite_over_x888_8_8888 with READ of size 4 at 0x61000074d2f4"
When I change testcase JS code from String.fromCodePoint(10040); into String.fromCodePoint(10100); the ASAN shadow bytes point will change from [04] into [fa].
The code in pixman-sse2.c:4919 (that ASAN show) is from commit Bug 1689998 - Update pixman sources to release 0.40.0 as below:
memcpy(&m, mask++, sizeof(uint32_t));
Reproduced on:
- Firefox ASAN build on last commit ca22dc040c3a6f9257efdaedec848bb48334f8bd (HEAD -> master, origin/master, origin/HEAD) (Sat Mar 6 05:40:39 2021 +0000) on Arch Linux
- Firefox ASAN from fuzzfetch with Build ID 20210305214118 on Arch Linux
Steps to reproduce:
- Open Firefox ASAN with recent build
- Visit attached testcase.html
- When print dialog show, select Destination "Save to PDF" (default on my desktop) or "Print to File" (on Firefox ESR Linux)
- Click "Save" or "Print"
- Browser crashed
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 SSE2 compositing routine reads a mask pixel past the end of the mask buffer when handling this particular glyph during PDF/print rendering.
Impact
An attacker could crash the browser (denial of service) when a victim prints or saves the crafted page to PDF; the report shows only a crash, not code execution.
What the attacker needed
Victim opens a crafted HTML page; victim prints or saves to PDF; Firefox build with pixman 0.40.0
How it was found
- Open a Firefox ASAN build.
- Visit the attached testcase page.
- In the print dialog choose Save to PDF or Print to File.
- Click Save or Print; the browser crashes.
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 heap-buffer-overflow is when a program reads or writes past the end of a block of memory it allocated. Here the graphics library used for printing read four bytes beyond a buffer, which the memory checker AddressSanitizer detected and which crashed the browser. The trigger is a page containing a particular character that is drawn during printing.
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.