Skip to content
Memory corruption Write-up Advanced

Browser Exploitation: Firefox OOB to RCE

A custom-patched Firefox build added a setter for ArrayBuffer byteLength and removed a length sanity check, letting JavaScript set an oversized length and read or write past the buffer. The author used this out-of-bounds access to build read/write and address-of primitives, then placed shellcode in JIT-compiled double constants and located it to redirect execution.

vuln.dev

Published on vuln.dev

In this post, we will exploit Midenios, a good introductory browser exploitation challenge that was originally used for the HackTheBox Business-CTF. I had some experience exploiting IE/Edge/Chrome before, but exploiting Firefox was mostly new to me.

The author, on vuln.dev

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the patch exposed a byteLength setter to JavaScript and removed the check that the new length stays within the maximum buffer size, so the stored length no longer matched the allocated data.

Impact

A script running in the vulnerable browser could read and write arbitrary memory and, in the release build, locate JIT-compiled shellcode; the debug build hit an assertion, and the text does not show a completed jump to the shellcode.

What the attacker needed

Victim bot visits attacker HTML; vulnerable patched Firefox build; attacker-hosted JavaScript

How it was found

  1. Submit HTML containing a script tag pointing at the attacker's JavaScript so the bot loads it.
  2. Create an ArrayBuffer, set its byteLength to a large value, and view it through a typed array.
  3. Create a second ArrayBuffer next to the first and read past the first buffer's end to see the second one's metadata.
  4. Overwrite the second buffer's data pointer through the out-of-bounds write to build read and write helpers.
  5. Define shellcode as double constants in a function and call it many times so the JIT compiles it into executable memory.
  6. Use the address-of helper and read primitive to scan the JIT region for a marker and find the shellcode.

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 write-up has not been written yet. The Original tab links to the source.

A browser stores the contents of a typed array in a block of memory and keeps a number saying how long that block is. The patched browser let a script change that number to something much larger than the real block, so the script could read and write memory belonging to other objects nearby. From there the author could read and write anywhere and eventually run their own code.

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.

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.