Out of bounds read in V8 API (CVE-2024-4059)
Calling getContextAttributes() on a WebGL2 context causes a large typed array to be retained after a page reload, leading to a memory leak. An attacker could use this to cause memory exhaustion in the browser.
- Fix shipped in 16 days
Steps to reproduce the problem
- Open this file in a new tab:
<!DOCTYPE html>
<html lang="en">
<body>
<canvas id="canvas"></canvas>
<script>
const resource = new Uint8Array(100000000).fill(42);
const attributes = canvas.getContext('webgl2').getContextAttributes();
</script>
</body>
</html>
- Use Dev Tools to capture a heap snapshot. This will be about 100MB in size
- Reload the page
- Capture another heap snapshot. This will be about 200MB. Triggering GC with the "Collect garbage"-button does not affect this. Subsequent reloads will not cause a larger heap than this.
Problem Description
I've been investigating a resource leak in a large WebGL application that seems to happen when you reload the page, I've found a minimal way to reproduce the issue. For some reason, if I call getContextAttributes() the resources won't be cleaned up on a page reload.
The resources are cleaned up correctly on 122.0.6261.128, so this seems to be a regression.
I'm running Ubuntu 22.04 (6.5.0-26-generic). Since this seems to be WebGL related I've tried both OpenGL and Vulkan angle backends, and both are affected.
Summary
WebGLContext.getContextAttributes() triggers resource leak on page reload
Additional Data
Category: JavaScript
Chrome Channel: Stable
Regression: Yes
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 regression in V8's handling of WebGL context attributes that prevents garbage collection of associated resources on page reload.
Impact
An attacker could cause a memory leak that persists across page reloads, potentially leading to memory exhaustion and denial of service.
What the attacker needed
Victim visits a malicious page; browser supports WebGL2
How it was found
- Open a page that creates a large Uint8Array and calls getContextAttributes() on a WebGL2 canvas.
- Capture a heap snapshot using Dev Tools.
- Reload the page.
- Capture another heap snapshot and observe the increased size.
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.
A web page can create a large block of memory and then ask the browser for details about a WebGL drawing surface. Normally, reloading the page frees that memory, but here it stays allocated. Repeating this could fill up the browser's memory and slow down or crash the tab.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.