CVE-2025–4919 [for Dummies]
A bug in Firefox's JIT compiler's bounds-check elimination mishandled 32-bit signed integer wraparound, allowing a crafted JavaScript array index to become negative and bypass bounds checks. An attacker could then achieve out-of-bounds read/write and potentially arbitrary code execution.
medium.com
Published on medium.com
This write-up breaks down CVE-2025–4919: Corruption via Math Space in Mozilla Firefox, in a way that even a regular computer science student with only basic knowledge of syntax can understand.
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 bounds-check elimination logic in TryEliminateBoundsCheck mishandled 32-bit signed integer wraparound when comparing linear expressions, allowing a negative index to pass as in-bounds.
Impact
An attacker could achieve out-of-bounds read/write and potentially arbitrary code execution within the Firefox rendering process.
What the attacker needed
Victim visits a malicious webpage; JavaScript enabled in Firefox
How it was found
- Warm up the JIT compiler with safe array indices that stay within 32-bit bounds.
- Supply crafted values where the index expression overflows a 32-bit signed integer and wraps to a negative number.
- Observe that the JIT compiler only checks the upper bound and permits the negative index as an out-of-bounds access.
- Use the resulting out-of-bounds read/write primitive to scan memory for a Map object and leak an address.
- Overwrite a tagged pointer to create a fake object at an arbitrary memory location.
- Forge memory to point to shellcode and achieve arbitrary code execution.
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.
Firefox's JavaScript engine sometimes optimises code by removing safety checks it thinks are redundant. A mistake in that optimisation let a specially crafted number wrap around to a negative value, so the engine skipped a check it should have kept. That gave the attacker a way to read and write memory outside the intended array, which can lead to running 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.