Out-of-bounds array access in WebGLTexture::ImageInfoAtFace
An out-of-bounds array access occurs in WebGLTexture::ImageInfoAtFace when a large level value is passed to gl.texParameterf, allowing a bogus ImageInfo object to be returned. This could potentially lead to an exploitable state.
Originally disclosed on Mozilla
- Fixed in 35 days
- Paid in 49 days
- Disclosed after 35 days
Created attachment 8858813
testcase.html
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36
Steps to reproduce:
Tested on:
- Mozilla Firefox 52.0.2 (32-bit) on Windows 10
- Nightly 55.0a1 (2017-04-10) (64-bit) on Ubuntu 16.04 LTS
Details:
dom/canvas/WebGLTexture.h:
..
313 ImageInfo& ImageInfoAtFace(uint8_t face, uint32_t level) {
314 MOZ_ASSERT(face < mFaceCount);
315 MOZ_ASSERT(level < kMaxLevelCount);
316 size_t pos = (level * mFaceCount) + face;
317 return mImageInfoArr[pos];
318 }
..
By supplying a sufficiently large value to 'level' (see the third parameter of gl.texParameterf() in the provided testcase file), it is possible to cause an out-of-bounds array access in line 317. This may result in a bogus ImageInfo object being returned to the calling function, possibly leading to an exploitable state.
Provided files:
- testcase.html -- Testcase to trigger the issue.
- ASAN_output.txt -- Detailed ASAN output (Linux).
- WinDbg_output.txt -- Further debugging information (Windows).
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The level parameter is not validated against the maximum allowed level before being used to index the mImageInfoArr array.
Impact
This may result in a bogus ImageInfo object being returned to the calling function, possibly leading to an exploitable state.
What the attacker needed
Victim visits a malicious webpage
How it was found
- Open the provided testcase.html in Firefox.
- The testcase calls gl.texParameterf with a large level value.
- This triggers an out-of-bounds array access in WebGLTexture::ImageInfoAtFace.
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 report has not been written yet. The Original tab links to the source.
This bug is in a web browser's graphics code. When a webpage asks the browser to set a texture parameter with a very large 'level' number, the code uses that number to calculate a position in an array without checking if it's too big. That can make the browser read or write memory outside the array, which might let an attacker run harmful 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.