-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypedArray constructor reads bufferByteLength too early #842
Comments
I see how this behavior is not what you'd expect--we should probably be doing all conversions before the detached check so that this check can catch as many cases as possible. But I don't see the security issue. A later indexed property access would simply find the underlying ArrayBuffer detached and throw (modulo #678), wouldn't it? |
Previously, in one of the TypedArray constructor paths, an ArrayBuffer was checked for being detached, and then a ToIndex calculation is done. Because ToIndex may detach the ArrayBuffer itself, this patch moves the detached check to afterwards, so that it can include that possible time when the ArrayBuffer may be detached. Closes tc39#842
Yes that's true, as long as the property accesses check for detached ArrayBuffer, this won't cause a security problem |
Previously, in one of the TypedArray constructor paths, an ArrayBuffer was checked for being detached, and then a ToIndex calculation is done. Because ToIndex may detach the ArrayBuffer itself, this patch moves the detached check to afterwards, so that it can include that possible time when the ArrayBuffer may be detached. Closes #842
In 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ):
In step 9, we store the value of the byte length of the buffer.
9. Let bufferByteLength be buffer.[[ArrayBufferByteLength]].
In step 11.a, we can end up in user-code via ToIndex.
11.a. Let newLength be ? ToIndex(length).
In step 11.c, we use the value of bufferByteLength from step 9 -- which could be totally incorrect now, as 11.a could have neutered the buffer.
11.c. If offset + newByteLength > bufferByteLength, throw a RangeError exception.
If an implementation followed this, it could result in (quite bad) security issues.
The text was updated successfully, but these errors were encountered: