heap buffer overflow in VertexBuffer9 (ANGLE)
A heap buffer overflow exists in ANGLE's D3D9 VertexBuffer9::storeVertexAttributes when handling WebGL drawElements calls. An attacker could trigger memory corruption by loading a crafted WebGL page, potentially leading to code execution in the browser process.
- Fixed in 45 days
- Paid in 52 days
- Disclosed after 45 days
Created attachment 8911233
D3D9.html
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36
Steps to reproduce:
I have attached the same PoC (Bug 1398381) which can be used to trigger a heap overflow in ANGLE.
(You can disable hardware acceleration and test.)
I have tested this on: 58 nightly build (should be applicable to the current stable build as well)
libglesv2.dll!memcpy + ? (the exact offset is not known) (id: 72d)
libglesv2.dll!rx::VertexBuffer9::storeVertexAttributes + 0x1D4 (id: 791) [[z:\build\build\src\gfx\angle\src\libangle\renderer\d3d\d3d9\vertexbuffer9.cpp @ 109]]
libglesv2.dll!rx::StreamingVertexBufferInterface::storeDynamicAttribute + 0x204 [[z:\build\build\src\gfx\angle\src\libangle\renderer\d3d\vertexbuffer.cpp @ 173]]
libglesv2.dll!rx::VertexDataManager::storeDynamicAttrib + 0x240 [[z:\build\build\src\gfx\angle\src\libangle\renderer\d3d\vertexdatamanager.cpp @ 480]]
libglesv2.dll!rx::VertexDataManager::storeDynamicAttribs + 0x25A [[z:\build\build\src\gfx\angle\src\libangle\renderer\d3d\vertexdatamanager.cpp @ 400]]
libglesv2.dll!rx::VertexDataManager::prepareVertexData + 0x2DA [[z:\build\build\src\gfx\angle\src\libangle\renderer\d3d\vertexdatamanager.cpp @ 275]]
libglesv2.dll!rx::Renderer9::applyVertexBuffer + 0x5E [[z:\build\build\src\gfx\angle\src\libangle\renderer\d3d\d3d9\renderer9.cpp @ 1285]]
libglesv2.dll!rx::Renderer9::genericDrawElements + 0x1A8 [[z:\build\build\src\gfx\angle\src\libangle\renderer\d3d\d3d9\renderer9.cpp @ 2984]]
libglesv2.dll!rx::Context9::drawElements + 0x47 [[z:\build\build\src\gfx\angle\src\libangle\renderer\d3d\d3d9\context9.cpp @ 157]]
libglesv2.dll!gl::Context::drawElements + 0x33 (inlined function) [[z:\build\build\src\gfx\angle\src\libangle\context.cpp @ 1654]]
libglesv2.dll!gl::DrawElements + 0xB2 [[z:\build\build\src\gfx\angle\src\libglesv2\entry_points_gles_2_0.cpp @ 791]]
xul.dll!mozilla::gl::GLContext::raw_fDrawElements + 0x1A (inlined function) [[z:\build\build\src\gfx\gl\glcontext.h @ 1101]]
xul.dll!mozilla::gl::GLContext::fDrawElements + 0x26 [[z:\build\build\src\gfx\gl\glcontext.h @ 1115]]
xul.dll!mozilla::WebGLContext::DrawElements + 0x13F [[z:\build\build\src\dom\canvas\webglcontextdraw.cpp @ 811]]
xul.dll!mozilla::dom::WebGLRenderingContextBinding::drawElements + 0xB6 [[z:\build\build\src\obj-firefox\dom\bindings\webglrenderingcontextbinding.cpp @ 16256]]
xul.dll!mozilla::dom::GenericBindingMethod + 0x12A [[z:\build\build\src\dom\bindings\bindingutils.cpp @ 3061]]
xul.dll!js::CallJSNative + 0xA3 (inlined function) [[z:\build\build\src\js\src\jscntxtinlines.h @ 293]]
xul.dll!InternalCall + ? (the exact offset is not known) [[z:\build\build\src\js\src\vm\interpreter.cpp @ 495]]
xul.dll!js::CallFromStack + 0xD (inlined function) [[z:\build\build\src\js\src\vm\interpreter.cpp @ 546]]
xul.dll!js::jit::DoCallFallback + 0x24A [[z:\build\build\src\js\src\jit\baselineic.cpp @ 2589]]
0x2E8E572D08E (no function symbol available)
0x18453FC480 (no function symbol available)
0x18453FC1B0 (no function symbol available)
0xFFFE01216EA6D940 (no function symbol available)
0xEEE4421FD838 (no function symbol available)
0x18453FC430 (no function symbol available)
0x18453FC3E8 (no function symbol available)
0x4 (no function symbol available)
0x18453FC3E8 (no function symbol available)
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
Likely a size or bounds miscalculation in VertexBuffer9::storeVertexAttributes when copying dynamic vertex attribute data, allowing a memcpy to write past the allocated heap buffer.
Impact
A crafted WebGL page could corrupt heap memory in the browser, which may lead to code execution; the report only demonstrates a crash.
What the attacker needed
Victim loads a crafted WebGL page; hardware acceleration disabled
How it was found
- Load the attached proof-of-concept page in a browser with hardware acceleration disabled.
- The page issues WebGL drawElements calls that reach ANGLE's D3D9 vertex buffer code.
- The vertex attribute copy overflows the heap buffer, as shown in the crash stack.
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.
WebGL lets web pages draw 3D graphics, and the browser translates those calls into lower-level graphics library calls. Here a translation layer called ANGLE copied vertex data into a buffer that was too small, so memory past the end of the buffer got overwritten. A malicious page could exploit this to corrupt the browser's memory.
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.