Skip to content
Memory corruption Disclosed report Advanced CVE-2026-74946

WebGLBuffer cache invalidation misses bufferSubData updates, bypassing vertex bounds checks

A WebGL index-range cache in Firefox was invalidated using a byte offset that was wrongly multiplied by the index element size, so a bufferSubData write to the selected index bytes did not evict the cached range. An attacker could then draw with an out-of-range index that Firefox should have rejected, and read back nonzero values from logical vertex fetches beyond the WebGL-visible buffer.

locust1b Follow

Originally disclosed on Mozilla

  • Fixed in 43 hours
  • Paid in 46 days
  • Disclosed after 43 hours
Text
Created attachment 9620835
WebGL cache-bypass and readback PoCs, compact Firefox 153 results, root-cause report, one-line correction, and SHA-256 manifest.

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36

Steps to reproduce:

I reproduced this with an official Firefox 153 release on a MacBook Air with an Apple M3. Each run used the temporary fresh profile created by GeckoDriver. The pages use standard WebGL APIs and require no preference changes.

Environment:

- macOS 26.3, build 25D125
- Firefox 153.0
- Build ID: `20260715202819`
- Release source stamp: `3810496e857367d04cf4fa0c705df6995a48b860`
- User agent: `Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:153.0) Gecko/20100101 Firefox/153.0`
- WebGL renderer: `Apple M1, or similar`
- GeckoDriver 0.37.1

The attached bundle contains two PoCs. `poc-primary.html` is the shortest deterministic reproduction:

1. Create a one-vertex attribute buffer.
2. Upload `Uint16Array([0, 0, 0, 65534])` as the element array.
3. Draw one `UNSIGNED_SHORT` index at byte offset 2. This valid draw caches an exact maximum of zero for `{type: UNSIGNED_SHORT, byteOffset: 2, indexCount: 1}`.
4. Call `bufferSubData` at byte offset 2 and replace that selected index with `65534`.
5. Repeat the same draw.
6. As a control, write the unchanged value zero at byte offset 4 and repeat the draw once more.

Run it with:

'''bash
node run-webdriver.mjs \
  --html poc-primary.html \
  --result primary.json \
  --screenshot primary.png \
  --driver /path/to/geckodriver \
  --firefox /Applications/Firefox.app/Contents/MacOS/firefox
'''

`poc-readback.html` sends values from the selected vertex fetch through a shader into four integer framebuffer attachments and reads them with `readPixels`:

'''bash
node run-webdriver.mjs \
  --html poc-readback.html \
  --query '?sizes=4096&targetMode=shrink&preallocationSize=131072&recordLimit=512' \
  --result readback.json \
  --screenshot readback.png \
  --driver /path/to/geckodriver \
  --firefox /Applications/Firefox.app/Contents/MacOS/firefox \
  --timeout-ms 180000
'''

The two attached readback summaries came from separate fresh profiles on August 2, 2026. They retain the counts, hashes, bounded samples, in-bounds oracle, controlled-marker result, GL errors, context-loss events, and correct-invalidation control. The full WebDriver logs and earlier exploratory runs are omitted.


Actual results:

The update at byte offset 2 did not invalidate the exact cached range used by the draw. Firefox accepted the second draw even though the selected index was now `65534` and the active vertex buffer supplied one vertex.

The primary result recorded:

- initial valid draw: no GL error, center pixel `[0, 255, 0, 255]`
- draw after changing the selected index to `65534`: no GL error, center pixel `[0, 255, 0, 255]`
- draw after the byte-4 control write: `INVALID_OPERATION` (`0x502`), center pixel remained the blue clear value `[0, 0, 255, 255]`

The byte-4 control identifies the unit error. The selected index occupies the real byte range `[2,4)`. `WebGLBuffer::InvalidateCacheRange` incorrectly models that cached range as `[4,6)`, so the real update at byte 2 misses it while the unrelated write at byte 4 evicts it.

The attached readback runs each scanned 65,535 candidate indices:

- run A returned 59,272 nonzero 16-byte records, with readback hash `4bdb7f8a5531cf93d1900cb662035b157bb8d4a65a3681e4fd4b0e91c4f1bb1e`
- run B returned 813 nonzero 16-byte records, with readback hash `9c6b62b08194a7f562cf8597740272bdea24fe495227cba98cb7231e70e74e6e`

Both runs completed without a GL error or context-loss event. Their in-bounds oracle returned its exact expected value. In each run, the byte-4 invalidation control made Firefox reject the draw with `0x502` and returned a zero output record.

No returned record matched a controlled canary. The results show that page JavaScript can receive nonzero values produced by logical vertex fetches beyond the WebGL-visible buffer. They do not identify the values as another WebGL object, context, origin, or process, and they do not establish native memory corruption or code execution.

The root cause is in `dom/canvas/WebGLBuffer.cpp`. `IndexRange::byteOffset` is already measured in bytes, but `InvalidateCacheRange` multiplies it by the index element size:

'''cpp
const auto rangeBegin = range.byteOffset * indexByteSize;
'''

For a nonzero `UNSIGNED_SHORT` or `UNSIGNED_INT` offset, this moves the modeled cached interval to a higher byte address. `bufferSubData` and WebGL2 `copyBufferSubData` both call this invalidator after page-controlled updates.

The expression remains present in current source at revision `56ad29049a11ced909e25d7e1fabcc6155e1a516`. The attached `fix.patch` changes only the unit conversion:

'''cpp
const auto rangeBegin = range.byteOffset;
'''


Expected results:

Updating the selected index bytes `[2,4)` should invalidate every cached index range that reads those bytes. Firefox should then rescan the exact range, observe index `65534`, and reject the draw because the active vertex buffer supplies only one vertex.

`InvalidateCacheRange` should compare byte offsets directly. An unrelated write beginning at byte 4 should not be required to evict a cache entry for the selected bytes `[2,4)`.

The original report as published on Mozilla's Bugzilla, by locust1b. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

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 the cache invalidation multiplies an already byte-based offset by the index element size, so the modelled cached interval is shifted and real updates to the selected bytes miss it.

Impact

Page JavaScript could receive nonzero values from logical vertex fetches beyond the WebGL-visible buffer, though the report does not establish native memory corruption, code execution, or cross-origin data.

What the attacker needed

Victim visits a malicious page; WebGL enabled, no preference changes

The fix

The invalidation should compare byte offsets directly without multiplying by the index element size, as the attached patch does.

How it was found

  1. Create a one-vertex attribute buffer.
  2. Upload a small Uint16Array as the element array.
  3. Draw one UNSIGNED_SHORT index at byte offset 2 to cache a maximum of zero.
  4. Call bufferSubData at byte offset 2 to replace the selected index with 65534.
  5. Repeat the same draw and observe it is accepted.
  6. Write the unchanged value zero at byte offset 4 as a control and repeat the draw.

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 a web page draw shapes using a list of vertex numbers (indices) stored in a buffer. Firefox remembers the largest index it has seen so it can quickly reject draws that point past the end of the vertex data. Here that memory was not cleared when the page changed the index, so a draw that should have been refused went ahead and the page could read back values it should not have seen.

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.

More from Mozilla

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.