Closed Bug 1205616 Opened 9 years ago Closed 8 years ago

Creating a 4GB ArrayBuffer does not throw.

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: jujjyl, Assigned: jorendorff)

References

(Blocks 1 open bug)

Details

(Keywords: sec-audit)

Attachments

(1 file)

Attached file 4gb_arraybuffer.html (deleted) —
STR: Run the attached .html file. Observed: The page prints "0". Expected: Creating the ArrayBuffer should fail, and the page should throw an error "RangeError: invalid array length". (Works in Chrome)
Buffers larger than 4GB are definitely allowed by ES-2015. (Obviously there's a bug here though.)
Oh right - I was expecting it to throw since creating an ArrayBuffer of size 2^32-1 did throw, but of course getting a 4GB ArrayBuffer would be an ok result as well. (I think we currently have a limit of 2^31-1 bytes on ArrayBuffer size)
Looking at the creation code, it's a bit messy and arguably incorrect but almost certainly safe. It performs a ToInt32 operation, so sizes between 2GB and 4GB are illegal but then 4GB to 6GB is legal again. It should use ToLength and then do a proper check on the length. The create() method takes a uint32 but does not check that it is a uint32 in the proper range, notably it rounds the uint32 up to the page size so the strictly largest byte length for an ArrayBuffer is probably 4GB - pagesize. Elsewhere we have guards on the length being < 2GB.
Group: core-security
Marking s-s because correctness is not obvious. No smoking gun yet.
Group: core-security → javascript-core-security
Lars: did you decide this was a security bug that needs to remain hidden, and if so what is it's severity? Or is everything OK here.
Flags: needinfo?(lhansen)
Daniel: I don't think I ever finished the investigation, I was sidetracked (still am).
Flags: needinfo?(lhansen)
Blocks: es6
I'm just going to mark this sec-audit for now. Please adjust or clear the rating if you determine there to be an issue here. Thanks.
Keywords: sec-audit
Talked with Lars about this. I'm just going to fix the argument handling in the open bug (bug 1255128).
Assignee: nobody → winter2718
Depends on: 1255128
(In reply to Jason Orendorff [:jorendorff] from comment #9) > Talked with Lars about this. I'm just going to fix the argument handling in > the open bug (bug 1255128). Taking ownership for bookkeeping and to ensure that this doesn't slip through the cracks once we fix bug 1255128.
Any updates on this?
Flags: needinfo?(jorendorff)
Assignee: winter2718 → jorendorff
Flags: needinfo?(jorendorff)
Is there a timeline we want/need to get this fixed?
Flags: needinfo?(jorendorff)
Didn't Tom fix this with his ToIndex work, recently?
Yeah, this looks fixed in current code by bug 1255128, and stepping through in a debugger, it properly throws.
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Group: javascript-core-security → core-security-release
Flags: needinfo?(jorendorff)
Group: core-security-release
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: