Skip to content
DoS Disclosed report Intermediate CVE-2022-1919

SEGV on libwebp WebPSafeFree -> malloc_decls.h free

Repeatedly encoding a canvas to WebP and data URL in a loop caused Firefox to crash with a segmentation fault in the WebP encoder's free routine. An attacker could potentially crash the browser by luring a user to a page that performs these operations.

Irvan Kurniawan Follow

Originally disclosed on Mozilla

  • Fixed in 48 days
  • Paid in 2 months
  • Disclosed after 48 days

Created attachment 9269236 testcase.html

After run canvas.toBlob(callback, "image/webp") and canvas.toDataURL() in loop, then when Firefox trigger free to avoid OOM, surprisingly Firefox crashed with SIGSEGV WebPSafeFree to malloc_decls.h free crash signature.

Tested on:

  • Firefox 98.0.2 (32-bit) on Arch Linux
  • Firefox Nightly 100.0a1 (2022-03-24) (32-bit) on Arch Linux

Steps to reproduce:

  1. Open Firefox (32-bit)
  2. Visit attached testcase.html
  3. After few seconds Firefox crashed with "free" crash signature

(If Firefox crashed with mozalloc_abort signature, try again until it crashed with free crash signature)

Crash report minidump:

eip = 0x5661a62f   esp = 0xe4457f80   ebp = 0xe4458008   ebx = 0x56675000
esi = 0x00001010   edi = 0x10100000   eax = 0x00000001   ecx = 0x565b9500
edx = 0x00000000   efl = 0x00010206
OS|Linux|0.0.0 Linux 5.16.13-arch1-1 #1 SMP PREEMPT Tue, 08 Mar 2022 20:07:36 +0000 x86_64
CPU|x86|AuthenticAMD family 23 model 96 stepping 1|12
GPU|||
Crash|SIGSEGV / SEGV_MAPERR|0x10100000|6
6|0|firefox-bin|free|hg:hg.mozilla.org/mozilla-central:memory/build/malloc_decls.h:a8d37f94a6364103b7f373b9938ce7a62d9db9e6|54|0x6f
6|1|libxul.so|WebPSafeFree|hg:hg.mozilla.org/mozilla-central:media/libwebp/src/utils/utils.c:a8d37f94a6364103b7f373b9938ce7a62d9db9e6|219|0x8
6|2|libxul.so|VP8LBitWriterWipeOut|hg:hg.mozilla.org/mozilla-central:media/libwebp/src/utils/bit_writer_utils.c:a8d37f94a6364103b7f373b9938ce7a62d9db9e6|257|0xb
6|3|libxul.so|VP8LEncodeStream|hg:hg.mozilla.org/mozilla-central:media/libwebp/src/enc/vp8l_enc.c:a8d37f94a6364103b7f373b9938ce7a62d9db9e6|2033|0xf
6|4|libxul.so|EncodeAlphaInternal|hg:hg.mozilla.org/mozilla-central:media/libwebp/src/enc/alpha_enc.c:a8d37f94a6364103b7f373b9938ce7a62d9db9e6|139|0x1f
6|5|libxul.so|CompressAlphaJob|hg:hg.mozilla.org/mozilla-central:media/libwebp/src/enc/alpha_enc.c:a8d37f94a6364103b7f373b9938ce7a62d9db9e6|374|0x33
6|6|libxul.so|VP8EncStartAlpha|hg:hg.mozilla.org/mozilla-central:media/libwebp/src/enc/alpha_enc.c:a8d37f94a6364103b7f373b9938ce7a62d9db9e6|413|0x10
6|7|libxul.so|WebPEncode|hg:hg.mozilla.org/mozilla-central:media/libwebp/src/enc/webp_enc.c:a8d37f94a6364103b7f373b9938ce7a62d9db9e6|382|0x8
6|8|libxul.so|Encode|hg:hg.mozilla.org/mozilla-central:media/libwebp/src/enc/picture_enc.c:a8d37f94a6364103b7f373b9938ce7a62d9db9e6|255|0x2a
6|9|libxul.so|WebPEncodeRGBA|hg:hg.mozilla.org/mozilla-central:media/libwebp/src/enc/picture_enc.c:a8d37f94a6364103b7f373b9938ce7a62d9db9e6|273|0x38
6|10|libxul.so|nsWebPEncoder::InitFromData(unsigned char const*, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, nsTSubstring<char16_t> const&)|hg:hg.mozilla.org/mozilla-central:image/encoders/webp/nsWebPEncoder.cpp:a8d37f94a6364103b7f373b9938ce7a62d9db9e6|138|0x2d
6|11|libxul.so|mozilla::dom::ImageEncoder::ExtractDataInternal(nsTSubstring<char16_t> const&, nsTSubstring<char16_t> const&, unsigned char*, int, mozilla::gfx::IntSizeTyped<mozilla::gfx::UnknownUnits>, bool, mozilla::layers::Image*, nsICanvasRenderingContextInternal*, mozilla::layers::CanvasRenderer*, nsIInputStream**, imgIEncoder*)|hg:hg.mozilla.org/mozilla-central:dom/base/ImageEncoder.cpp:a8d37f94a6364103b7f373b9938ce7a62d9db9e6|414|0x19
6|12|libxul.so|mozilla::dom::EncodingRunnable::ProcessImageData(unsigned long long*, void**)|hg:hg.mozilla.org/mozilla-central:dom/base/ImageEncoder.cpp:a8d37f94a6364103b7f373b9938ce7a62d9db9e6|163|0x44
6|13|libxul.so|mozilla::dom::EncodingRunnable::Run()|hg:hg.mozilla.org/mozilla-central:dom/base/ImageEncoder.cpp:a8d37f94a6364103b7f373b9938ce7a62d9db9e6|186|0x8
6|14|libxul.so|nsThreadPool::Run()|hg:hg.mozilla.org/mozilla-central:xpcom/threads/nsThreadPool.cpp:a8d37f94a6364103b7f373b9938ce7a62d9db9e6|310|0x8
6|15|libxul.so|nsThread::ProcessNextEvent(bool, bool*)|hg:hg.mozilla.org/mozilla-central:xpcom/threads/nsThread.cpp:a8d37f94a6364103b7f373b9938ce7a62d9db9e6|1167|0x8
6|16|libxul.so|mozilla::ipc::MessagePumpForNonMainThreads::Run(base::MessagePump::Delegate*)|hg:hg.mozilla.org/mozilla-central:ipc/glue/MessagePump.cpp:a8d37f94a6364103b7f373b9938ce7a62d9db9e6|300|0x30
6|17|libxul.so|MessageLoop::Run()|hg:hg.mozilla.org/mozilla-central:ipc/chromium/src/base/message_loop.cc:a8d37f94a6364103b7f373b9938ce7a62d9db9e6|306|0xc
6|18|libxul.so|nsThread::ThreadFunc(void*)|hg:hg.mozilla.org/mozilla-central:xpcom/threads/nsThread.cpp:a8d37f94a6364103b7f373b9938ce7a62d9db9e6|389|0x8
6|19|libnspr4.so|_pt_root|hg:hg.mozilla.org/mozilla-central:nsprpub/pr/src/pthreads/ptthread.c:a8d37f94a6364103b7f373b9938ce7a62d9db9e6|201|0x9
6|20|firefox-bin|set_alt_signal_stack_and_start(PthreadCreateParams*)|hg:hg.mozilla.org/mozilla-central:toolkit/crashreporter/pthread_create_interposer/pthread_create_interposer.cpp:a8d37f94a6364103b7f373b9938ce7a62d9db9e6|80|0x9
6|21|libc.so.6||||0x8a3de
6|22|libc.so.6||||0x122d1a

The original report as published on Mozilla's Bugzilla, by Irvan Kurniawan. 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 a memory management bug in the WebP encoder's alpha compression path, where a buffer is freed incorrectly during repeated encoding under memory pressure.

Impact

A malicious web page could crash the browser (denial of service) by repeatedly encoding canvas data to WebP, though the crash may not always occur on the first attempt.

What the attacker needed

Victim visits a malicious page; 32-bit Firefox on Linux

How it was found

  1. Open Firefox (32-bit)
  2. Visit the attached testcase.html
  3. Wait a few seconds until Firefox crashes with the 'free' crash signature

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 web page can ask the browser to turn a drawing (canvas) into a WebP image. If it does this over and over very quickly, the browser's image encoder sometimes frees memory incorrectly and crashes. This means a malicious site could make your browser close unexpectedly.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by Irvan Kurniawan

View all

72 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.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.