Uninitialized compositor-process memory disclosure to web content via DrawTargetWebgl accelerated canvas filter readback [@ SharedContextWebgl::ReadInto]
Categories
(Core :: Graphics: Canvas2D, defect, P1)
Tracking
()
People
(Reporter: bugmon, Assigned: lsalzman)
Details
(5 keywords, Whiteboard: [adv-main154+r][adv-esr153.1+r])
Attachments
(6 files, 3 external files)
The accelerated canvas 2D backend (DrawTargetWebgl, running inside CanvasTranslator in the compositor process — the GPU process where available, the parent process otherwise) can disclose uninitialized privileged-process heap memory to ordinary web content.
When a canvas filter (e.g. feGaussianBlur) is applied, SharedContextWebgl::ResolveFilterInputAccel allocates a render-target texture sized to the blur-inflated source rect via AllocateTextureHandle, which performs no validation against mMaxTextureSize on the standalone-texture path. For a wide canvas plus a large blur, the requested width exceeds GL MAX_TEXTURE_SIZE, so the TexStorage call in BindAndInitRenderTex fails with a GL error that is silently ignored, leaving a texture with no storage. ClearRenderTex nevertheless marks the backing texture INITIALIZED (relying on WebGL's implicit clear, which never happens without storage), and the broken handle is returned as a valid filter input surface.
If the final filter draw cannot be accelerated (e.g. globalCompositeOperation = 'color-dodge', unsupported by SupportsDrawOptions), Firefox falls back to the software filter path, which reads the accelerated input surface back via SharedContextWebgl::ReadSnapshot/ReadInto. ReadSnapshot allocates the destination with Factory::CreateDataSourceSurface(..., aZero=false) — uninitialized malloc memory — and ReadInto ignores the ReadPixels failure on the storage-less (framebuffer-incomplete) texture and returns true unconditionally. The never-written heap bytes are then blurred, composited into the canvas, and exfiltrated by content via getImageData. Verified on a pristine ASAN build: an all-transparent gradient draw yields 8192/8192 nonzero bytes derived from ASAN's 0xBE malloc fill, while a control canvas with a valid texture size yields all zeros. In release builds, mozjemalloc/GL-driver buffer recycling surfaces stale privileged-process heap content instead of a fill pattern.
Build Info
- Branch: main
- Revision: 446c6e609dbd7c355c2fb27209dfe4833211991f
- Timestamp: 2026-07-16T21:34:33+00:00
Affected Code
File: dom/canvas/DrawTargetWebgl.cpp, line 4140-4160
// Round size to account for potential mipping from blur filters.
int roundFactor = 2 << BLUR_ACCEL_DOWNSCALE_ITERS;
IntSize roundSize =
std::max(aSourceRect.width, aSourceRect.height) >=
BLUR_ACCEL_DOWNSCALE_SIZE
? IntSize(RoundToFactor(aSourceRect.width, roundFactor),
RoundToFactor(aSourceRect.height, roundFactor))
: aSourceRect.Size();
RefPtr<TextureHandle> handle =
AllocateTextureHandle(aFormat, roundSize, true, true); // <-- no mMaxTextureSize check anywhere
if (!handle) {
return nullptr;
}
BackingTexture* targetBacking = handle->GetBackingTexture();
InitRenderTex(targetBacking); // TexStorage fails for oversized texture, error ignored
if (!aDT->PrepareContext(false, handle)) {
return nullptr;
}
DisableScissor();
ClearRenderTex(targetBacking); // marks INITIALIZED without an actual clear
File: dom/canvas/DrawTargetWebgl.cpp, line 2713-2744
void SharedContextWebgl::BindAndInitRenderTex(const RefPtr<WebGLTexture>& aTex,
SurfaceFormat aFormat,
const IntSize& aSize) {
mWebgl->BindTexture(LOCAL_GL_TEXTURE_2D, aTex);
mWebgl->TexStorage( // fails with GL_INVALID_VALUE when aSize.width > MAX_TEXTURE_SIZE; not checked
LOCAL_GL_TEXTURE_2D, 1,
aFormat == SurfaceFormat::A8 ? LOCAL_GL_R8 : LOCAL_GL_RGBA8,
{uint32_t(aSize.width), uint32_t(aSize.height), 1});
InitTexParameters(aTex);
ClearLastTexture();
}
...
void SharedContextWebgl::ClearRenderTex(BackingTexture* aBacking) {
if (!aBacking->IsInitialized()) {
aBacking->MarkInitialized();
// WebGL implicitly clears the backing texture the first time it is used.
// ^ never happens for a storage-less texture
} else { ... }
}
File: dom/canvas/DrawTargetWebgl.cpp, line 1254-1272
webgl::ReadPixelsDesc desc;
desc.srcOffset = *ivec2::From(aBounds);
desc.size = *uvec2::FromSize(aBounds);
desc.packState.rowLength = aDstStride / BytesPerPixel(aFormat);
if (aBuffer) {
mWebgl->BindBuffer(LOCAL_GL_PIXEL_PACK_BUFFER, aBuffer);
mWebgl->ReadPixelsPbo(desc, 0);
mWebgl->BindBuffer(LOCAL_GL_PIXEL_PACK_BUFFER, nullptr);
} else {
Range<uint8_t> range = {aDstData, size_t(aDstStride) * aBounds.height};
mWebgl->ReadPixelsInto(desc, range); // fails on incomplete framebuffer; result ignored
}
// Restore the actual framebuffer after reading is done.
if (aHandle) {
RestoreCurrentTarget();
}
return true; // <-- unconditional success
File: dom/canvas/DrawTargetWebgl.cpp, line 1291-1303
RefPtr<DataSourceSurface> surface =
aData ? Factory::CreateWrappingDataSourceSurface(aData, aStride,
bounds.Size(), format)
: Factory::CreateDataSourceSurface(bounds.Size(), format);
// ^ aZero defaults to false: uninitialized malloc memory (2D.h:2277)
if (!surface) {
return nullptr;
}
DataSourceSurface::ScopedMap dstMap(surface, DataSourceSurface::WRITE);
if (!dstMap.IsMapped() || !ReadInto(dstMap.GetData(), dstMap.GetStride(),
format, bounds, aHandle)) {
return nullptr;
}
return surface.forget(); // uninitialized bytes returned as valid pixels
All affected code is in dom/canvas/DrawTargetWebgl.cpp. Four defects combine: (1) no max-texture-size validation, (2) ignored TexStorage failure plus a backing texture incorrectly marked initialized, (3) ReadPixels failure ignored, and (4) a non-zeroed readback destination buffer.
Exploit Chain
- Attacker page creates an accelerated 2D canvas (default-on: gfx.canvas.accelerated) whose width plus blur inflation exceeds the GL MAX_TEXTURE_SIZE of the compositor's WebGL context (e.g. 8192-wide canvas with blur(500) on hardware with MAX_TEXTURE_SIZE=8192; 14000-wide canvas with max-size pref 16384 on llvmpipe/16384 in this harness).
- Set ctx.filter = url(#f) referencing an SVG feGaussianBlur with stdDeviation=500 over a wide userSpaceOnUse region; the source-needed inflation (~1410px per side) makes the deferred filter-input rect (16820x128, rounded to 16824x128) exceed MAX_TEXTURE_SIZE.
- Set fillStyle to a fully transparent linear gradient (non-color pattern), so FilterNodeDeferInputWebgl::ResolveInputs installs the accel-resolved SourceSurfaceWebgl into both the accelerated and software filter graphs.
- ctx.fillRect() triggers ResolveFilterInputAccel in the compositor process: AllocateTextureHandle allocates a standalone texture with no size validation; TexStorage(16824x128) fails (GL error ignored), leaving a storage-less texture; ClearRenderTex marks it INITIALIZED anyway and the broken handle is returned as a valid filter input.
- Set globalCompositeOperation = 'color-dodge' (SupportsDrawOptions returns No), so the accelerated FilterNodeGaussianBlurWebgl draw fails and Firefox falls back to the software filter path.
- The software filter reads the input surface back: ReadSnapshot allocates a non-zeroed destination (CreateDataSourceSurface, aZero=false); ReadInto's ReadPixels fails on the framebuffer-incomplete texture but returns true; raw uninitialized compositor-process heap bytes are treated as pixel data.
- The uninitialized bytes are blurred and composited into the canvas; content calls getImageData() to exfiltrate them. Under release allocators (mozjemalloc chunk recycling, GL driver buffer recycling — plain process heap for software GL), the disclosed bytes are stale privileged-process heap content.
IPC Path
- PCanvas
- Protocol: PCanvas
- Parent process: GPU
- Child process: Content
- Message flow: Content -> GPU/Parent compositor: recorded canvas 2D drawing events replayed by CanvasTranslator into DrawTargetWebgl; leaked snapshot returned to content for getImageData (GPU process where available; parent process on this Linux configuration)
Steps to Reproduce
- Build Firefox with the Linux ASAN fuzzing mozconfig (mozconfig.linux.asan.fuzzing).
- Set prefs: gfx.canvas.accelerated=true, gfx.canvas.accelerated.force-enabled=true, webgl.force-enabled=true (only to bypass the llvmpipe software-GL blocklist in the test harness), gfx.canvas.accelerated.max-size=16384 (only because llvmpipe reports MAX_TEXTURE_SIZE=16384; on hardware with MAX_TEXTURE_SIZE=8192 the default pref value of 8192 suffices).
- Load testcase.html: it draws a fully transparent linear gradient through ctx.filter=url(#feGaussianBlur stdDeviation=500) with globalCompositeOperation='color-dodge' on a 14000x128 accelerated canvas, and a 1000x128 control canvas with identical drawing.
- Observe console output: CONTROL canvas reads back nonzero=0/3072 (correct: all transparent), while the LEAK canvas reads back nonzero=8192/8192 with repeating RGBA bytes 255,255,255,110 — the blurred/unpremultiplied form of ASAN's 0xBE malloc fill, proving the returned pixels come from memory never written by any rendering operation.
Security Impact
- Severity: High
- Attacker capability: Ordinary web content (no user interaction) reads uninitialized heap memory of the privileged process hosting CanvasTranslator (GPU process where available; parent process otherwise) and exfiltrates it via getImageData. In release builds, allocator and GL-driver buffer recycling surface stale privileged-process heap contents, enabling theft of secrets (pointers defeating ASLR, keys, cross-origin data) from beyond the content sandbox. Repeated allocations let the attacker sample many distinct heap regions. It is an information disclosure, not a corruption primitive.
- Preconditions: Accelerated canvas 2D enabled (default on Linux/macOS/Windows/Android with non-blocklisted GPU drivers). The blur-inflated filter-input width must exceed the compositor GL context's MAX_TEXTURE_SIZE: with the default gfx.canvas.accelerated.max-size of 8192, any hardware whose MAX_TEXTURE_SIZE is 8192 (older/integrated GPUs, some ANGLE configs) is reachable with fully default prefs (8192 + 2x1410 blur inflation > 8192). The extra prefs in this reproduction only compensate for the test harness's blocklisted llvmpipe software GL. No source patches or custom servers required.
ASAN Report
No sanitizer crash: this is an observable-effect uninitialized-memory disclosure (an uninitialized read of a malloc'd buffer is not a sanitizer-detectable error under ASAN; the 0xBE malloc fill pattern makes it observable). Verification output from the pristine ASAN build (browser_evaluator, 2026-07-18):
[Child]: I/console log: "CONTROL(small canvas, valid texture): nonzero=0/3072 topbytes=[[\"0\",3072]]"
[Child]: I/console log: "LEAK(big canvas, oversized filter input): nonzero=8192/8192 topbytes=[[\"255\",6144],[\"110\",2048]]"
[Child]: I/console log: "LEAK sample RGBA bytes: 255,255,255,110,255,255,255,110,255,255,255,110,..."
The drawn pattern is a gradient whose stops all have alpha=0, so a correct rendering can only produce all-zero pixels (as the control canvas does). The leaked bytes are exactly the expected result of blurring and unpremultiplying a buffer uniformly filled with ASAN's 0xBE (190) malloc fill: color 190/190 -> 255, with blur-attenuated alpha 110. In release builds the same path returns recycled privileged-process heap content instead of the fill pattern.
| Reporter | ||
Comment 1•4 months ago
|
||
| Reporter | ||
Comment 2•4 months ago
|
||
| Reporter | ||
Comment 3•4 months ago
|
||
| Reporter | ||
Comment 4•4 months ago
|
||
| Reporter | ||
Comment 5•4 months ago
|
||
| Reporter | ||
Comment 6•4 months ago
|
||
Comment 7•4 months ago
|
||
This bug was filed automatically by an AI-powered security testing tool. The analysis, testcase, and any suggested patches were generated by an AI model and have NOT been verified by a human.
Please review all details carefully before triaging. The crash is real (confirmed by ASAN), but the root cause analysis and suggested fix may contain errors.
Updated•4 months ago
|
Updated•4 months ago
|
Updated•4 months ago
|
| Assignee | ||
Updated•4 months ago
|
| Assignee | ||
Comment 9•4 months ago
|
||
Updated•4 months ago
|
Comment 10•4 months ago
|
||
Comment 11•4 months ago
|
||
:lsalzman, please update all release status flags to reflect the affected/unaffected/disabled state correctly. Which branches (beta, release, and/or ESR) are affected by this flaw?
Comment 12•4 months ago
|
||
Updated•4 months ago
|
Comment 13•4 months ago
|
||
The patch landed in nightly and beta is affected, along with ESR.
:lsalzman, is this bug important enough to require an uplift?
- If yes, please nominate the patch for beta and ESR approvals.
- See https://wiki.mozilla.org/Release_Management/Requesting_an_Uplift for documentation on how to request an uplift.
- If no, please set
status-firefox154and the ESR status flag(s) towontfix.
For more information, please visit BugBot documentation.
| Assignee | ||
Updated•4 months ago
|
| Assignee | ||
Comment 14•4 months ago
|
||
Original Revision: https://phabricator.services.mozilla.com/D313599
Updated•4 months ago
|
Comment 15•4 months ago
|
||
firefox-beta Uplift Approval Request
- User impact if declined/Reason for urgency: Memory disclosure
- Code covered by automated testing?: yes
- Fix verified in Nightly?: yes
- Needs manual QE testing?: no
- Steps to reproduce for manual QE testing:
- Risk associated with taking this patch: low
- Explanation of risk level: Just adds some failure checking.
- String changes made/needed?: None
- Is Android affected?: yes
| Assignee | ||
Comment 16•4 months ago
|
||
Original Revision: https://phabricator.services.mozilla.com/D313599
Updated•4 months ago
|
Comment 17•4 months ago
|
||
firefox-esr153 Uplift Approval Request
- User impact if declined/Reason for urgency: Memory disclosure
- Code covered by automated testing?: yes
- Fix verified in Nightly?: yes
- Needs manual QE testing?: no
- Steps to reproduce for manual QE testing:
- Risk associated with taking this patch: low
- Explanation of risk level: Just adds some failure checking.
- String changes made/needed?: None
- Is Android affected?: yes
Updated•4 months ago
|
Updated•4 months ago
|
Comment 18•4 months ago
|
||
| uplift | ||
Updated•3 months ago
|
Updated•3 months ago
|
Comment 19•3 months ago
|
||
| uplift | ||
Updated•3 months ago
|
Updated•3 months ago
|
Updated•3 months ago
|
Updated•26 days ago
|
Description
•