GPU-process type confusion in DrawTargetCairo::DrawFilter
DrawTargetCairo::DrawFilter casts an incoming filter node to FilterNodeSoftware without checking its backend, so a filter node created for the WebGL backend is dispatched through the wrong vtable slot. A compromised content process can supply mismatched texture and backend types to reach this, causing a type confusion and a reliable GPU process crash.
- Fixed in 18 days
- Paid in 52 days
- Disclosed after 18 days
Created attachment 9620850 bug1-submission.zip
Steps to reproduce
- Build mozilla-central
fdd583cd5a10d051053acda8b760c3bd5d800034on macOS after applyingpatches/filternode-poc-instrumentation.patch, which makes the content process behave like a compromised one (see Environment for why that is the right model). - Run
./run-poc.sh asan. It loads a page that draws on a canvas, which brings up remote canvas. The script creates a fresh profile per run. - The patched content process sends
TextureType::MacIOSurface+BackendType::CAIROinPCanvas::InitTranslator, creates a 128x1 and a 128x128 draw target in the same translator, recordsDEFERFILTERINPUTwhile the 128x128 (WebGL) target is current, then recordsDRAWFILTERagainst the 128x1 (Cairo) target using that same filter node.
Alternatively, with no browser, no IPC and no GL context:
git apply patches/gtest-cross-backend-resources.patch
./mach gtest 'GfxCrossBackendResources.DISABLED_*' --gtest_also_run_disabled_tests
Actual results
The GPU process dies. DrawTargetCairo::DrawFilter casts the WebGL-backend filter node to FilterNodeSoftware* without checking, so the first backend-specific virtual call in FilterNodeSoftware::Draw() lands in FilterNodeDeferInputWebgl::ResolveInputs() and a stack address is used as a DrawTargetWebgl*.
Under ASan: stack-use-after-scope, WRITE of size 4. Without ASan: EXC_BAD_ACCESS (SIGSEGV). The gtest binary exits with code 245 mid-test.
Expected results
DrawFilter rejects a filter node from another backend and returns, as DrawTargetSkia::DrawFilter() already does, leaving the GPU process alive.
Reproducibility
Every run. ASan build 2/2 identical reports; non-ASan build and gtest also reproduce every time.
Each run uses a new profile — required, because after a GPU-process crash Firefox disables accelerated canvas in the profile, which silently neutralizes a rerun.
Earliest affected version
The accelerated-canvas filter code this depends on (dom/canvas/FilterNodeWebgl.cpp, DeferFilterInput) landed on mozilla-central on 2025-07-05 in bug 1912897, "Support blurring and shadows for Accelerated Canvas2D", i.e. the Firefox 142 nightly cycle. I verified the defect on current main (155.0a1) and did not bisect the intervening releases, so treat 142 as the likely first affected release rather than a confirmed one.
Description
gfx/2d/DrawTargetCairo.cpp casts the incoming FilterNode* to FilterNodeSoftware* with no backend check:
FilterNodeSoftware* filter = static_cast<FilterNodeSoftware*>(aNode);
filter->Draw(this, aSourceRect, aDestPoint, aOptions);
DrawTargetSkia::DrawFilter() performs exactly the check Cairo is missing (aNode->GetBackendType() != FILTER_BACKEND_SOFTWARE).
Reachability from a compromised content process:
CanvasTranslator::RecvInitTranslator()stores the child-suppliedTextureTypeandBackendTypeverbatim. A child sendsTextureType::MacIOSurface+BackendType::CAIRO, both valid enum values.CanvasTranslator::CreateDrawTarget()triesDrawTargetWebgl::Create()first, else falls back throughTextureData::Create(mTextureType, ..., mBackendType)toMacIOSurfaceTextureData::BorrowDrawTarget(), which honours the supplied backend.DrawTargetWebgl::CanCreate()rejects any dimension below 16, so a 128x1 target becomes a Cairo target and a 128x128 target becomes a WebGL target, both inside the same translator.- Filter nodes live in a translator-wide map.
DEFERFILTERINPUTon the WebGL target creates aFilterNodeDeferInputWebgl;RecordedDrawFilter::PlayEvent()then looks up target and node by independent reference ids, with no creator-backend comparison, and callsDrawFilter()on the Cairo target.
FilterNodeSoftware::Draw()'s first backend-specific virtual call therefore dispatches into FilterNodeDeferInputWebgl::ResolveInputs(), which occupies the same vtable slot, and a stack address is consumed as a DrawTargetWebgl*. Dumping the layouts from the real headers with the tree's own compile flags confirms the collision on both architectures (logs/vtable-slot-collision-both-arches.txt):
slot 25 FilterNodeSoftware::GetOutputRectInRect(const IntRect&)
slot 25 FilterNodeDeferInputWebgl::ResolveInputs(DrawTargetWebgl*, bool,
FilterNodeWebgl*)
Result
ASan build, reproduced 2/2 (logs/asan-run1-stack-use-after-scope.txt, logs/asan-run2-stack-use-after-scope.txt):
ERROR: AddressSanitizer: stack-use-after-scope, WRITE of size 4
#0 SharedContextWebgl::ResolveFilterInputAccel(DrawTargetWebgl*, ...)
#2 FilterNodeDeferInputWebgl::ResolveInputs(DrawTargetWebgl*, bool, ...)
#3 FilterNodeSoftware::Draw(DrawTarget*, ...)
#4 DrawTargetCairo::DrawFilter(FilterNode*, ...)
#5 RecordedDrawFilter::PlayEvent(Translator*)
Plain -O2 build with jemalloc and the sandbox enabled: GPU process SIGSEGV, KERN_INVALID_ADDRESS, same stack.
Negative control with BackendType::SKIA: Skia's guard rejects the node, the GPU process survives and keeps rendering, which isolates the defect to the missing Cairo check.
Impact
Established: reachable type confusion and wrong-signature virtual dispatch in the GPU process, driven entirely by values a compromised content process supplies; a reliable crash in a normal build. With crop or Gaussian-blur nodes at the same slot the wrong function instead returns normally and the process keeps running, i.e. silent UB rather than a fail-stop.
Not established, after direct attempts: control of the written value or offset (grooming with attacker-chosen FillRect/StrokeLine changed nothing; varying the attacker-controlled sourceRect changed nothing), control of the fabricated object's vtable slot (measures as a constant zero), code execution, or parent-process escape. No write lands in the caller's frame in a shipping-style build — the ASan caller-frame write is a sanitizer-layout effect.
No forward-edge CFI applies. I checked the official Nightly binary (Version=155.0a1, BuildID=20260801211258): the arm64 slice is ARM64 ALL, not arm64e, so pointers are unsigned, and neither slice contains any CFI symbol, ptrauth load command or CFI section.
Precondition: a compromised content process. Normal macOS content initializes the recorder with BackendType::SKIA, so plain web content cannot request Cairo. This is a sandbox-escape building block, not reachable from script alone.
Suggested fix
Add the guard DrawTargetSkia already has:
if (aNode->GetBackendType() != FILTER_BACKEND_SOFTWARE) {
gfxCriticalNote << "DrawFilter with incompatible filter backend "
<< int(aNode->GetBackendType());
return;
}
Defense in depth: validate the TextureType/BackendType pair in RecvInitTranslator() rather than storing whatever the child sends, and bind recorded resources to their creating target's backend.
Proof of concept as an in-tree test
Besides the browser-level PoC, I added a gtest so this can go straight into your test coverage (patches/gtest-cross-backend-resources.patch, which is independent of the instrumentation patch):
gfx/tests/gtest/TestCrossBackendResources.cpp
GfxCrossBackendResources.DISABLED_CairoDrawFilterRejectsWebglFilterNode
It builds a DrawTargetCairo and a FilterNodeDeferInputWebgl and calls DrawFilter(). Against current main the test process dies inside the unchecked cast (exit code 245), so no test completes; with the guard added, DrawFilter returns early and the test passes. No GPU process, no IPC and no GL context are needed.
Because it reproduces the defect by crashing, it would take the rest of the gtest run with it, so I marked it DISABLED_ by default. Run it explicitly with:
./mach gtest 'GfxCrossBackendResources.DISABLED_*' --gtest_also_run_disabled_tests
Once DrawFilter validates the filter backend it stops crashing and the DISABLED_ prefix can be dropped. The default suite run stays green apart from the regression test for my other report, which fails as intended.
Related
I am filing a second, independent issue with the same root cause (translator-wide resources not bound to a backend): an unchecked static_cast<const PathSkia*> in the WebGL filter path, reachable without this bug. Please link them.
Environment
mozilla-central fdd583cd5a10d051053acda8b760c3bd5d800034 (155.0a1), macOS 26.5.2 (25F84), Apple M4 Pro (arm64). Two objdirs: ASan (--enable-address-sanitizer --disable-jemalloc, which ASan requires) and plain -O2 with jemalloc and the sandbox enabled (MOZ_SANDBOX=1, no MOZ_DISABLE_*_SANDBOX in the environment). Both reproduce in the sandboxed, jemalloc-enabled build, so neither depends on the sanitizer or on a weakened build configuration. No Breakpad ID, as these builds have the crash reporter disabled; macOS crash reports are attached instead.
The content-process side is patched to send the malicious InitTranslator values and to emit the event sequences through CanvasDrawEventRecorder. That is not a shortcut around the threat model: the premise is a compromised content process, which by definition runs attacker code inside that process and can call these same code paths. The events are produced by Firefox's own recorder, so the byte stream reaching the GPU process is the one a real attacker would write.
The attachment contains a README.txt describing every file, the patches, all logs, and the repro scripts.
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 missing backend-type check in DrawTargetCairo::DrawFilter, which static_casts any FilterNode to FilterNodeSoftware while the translator-wide filter map lets nodes from one backend be used with a draw target from another.
Impact
A compromised content process can reliably crash the GPU process through this type confusion, and with other filter nodes at the same slot it causes silent undefined behaviour; control of the written value, code execution and parent-process escape were not established, and normal web content cannot request the Cairo backend.
What the attacker needed
Compromised content process; macOS build with accelerated canvas
The fix
Add the same backend-type guard that DrawTargetSkia uses, and as defence in depth validate the texture and backend pair in RecvInitTranslator and bind recorded resources to their creating target's backend.
How it was found
- Build mozilla-central with the instrumentation patch applied.
- Run the PoC script, which loads a page drawing on a canvas and brings up remote canvas.
- The patched content process sends MacIOSurface texture type with Cairo backend in InitTranslator.
- It creates a 128x1 and a 128x128 draw target in the same translator.
- It records a deferred filter input while the WebGL target is current.
- It records a draw filter against the Cairo target using that same filter node.
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 filter node is an object that describes an effect like a blur, and it is built for one particular drawing backend. Cairo's drawing code assumed every filter node it received was a software one and used it as such, without checking. When a node built for the WebGL backend arrived, the program called the wrong function and treated a stack address as a pointer to a WebGL drawing target, which crashed the GPU process.
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.