Simple Bugs With Complex Exploits - elttam
Two Torque reimplementations of V8's fixed-array allocation builtins omitted the maximum length check, so arrays could be created slightly longer than the allowed limit. The report explains how a crafted concat and splice sequence produces an array whose length exceeds its backing store, which the original researcher then turned into an out-of-bounds heap access primitive.
elttam.com
Published on elttam.com
Issue 2046 was recently disclosed on the Project Zero bugtracker by Sergey Glazunov. This issue describes a bug that was introduced into V8 when the developers decided to reimplement two CodeStubAssembler (CSA) functions using the new Torque language.
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 Torque rewrites of the fixed-array allocation macros dropped the kMaxLength bounds check that the original CodeStubAssembler version performed.
Impact
An attacker gains an out-of-bounds read and write primitive on the V8 heap, which the report says can very easily lead to code execution; the fast concat path's length check blocks the simple route, so the slow path is used to bypass it.
What the attacker needed
Running V8 8.5.51 or similar; ability to execute JavaScript in the engine
The fix
The allocation macros should restore the maximum length checks against FixedArray::kMaxLength and FixedDoubleArray::kMaxLength; the text does not state that a fix was applied.
How it was found
- Create a moderately sized array filled with values and give it an extra property so later concatenation takes the slow path.
- Build an arguments array holding many references to that array, then push one more large array so the total element count sits just under the limit.
- Concatenate everything with Array.prototype.concat.apply to obtain a giant array just below the maximum length.
- Call splice at the end of the giant array to append a few more elements, pushing its length past the maximum.
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.
V8 stores a JavaScript array's elements in a separate block of memory, and the array object keeps a length number that says how many elements it has. Normally the engine refuses to build a block bigger than a fixed maximum, but the rewritten code forgot that check, so a carefully built array can claim to be longer than the memory actually reserved for it. Reading or writing past the end of that memory is the first step towards running attacker-chosen 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.