Use after free in Dawn (CVE-2024-6991)
A WebGPU shader written in WGSL is translated by Chromium's tint compiler into HLSL and then compiled by dxcompiler.dll, where a stack use-after-return occurs in the HLSL matrix lowering pass. Opening a crafted HTML file on Windows with the D3D12 backend crashes the GPU process.
- Fix shipped in 42 days
VULNERABILITY DETAILS
Chromium translates wgsl shaders via tint to an OS-specific shader format. On Windows, the OS-specific file format is hlsl, processed in dxcompiler.dll. When compiling chrome-generated hlsl files, this triggers an stack use-after-return inside the hlsl compiler.
VERSION
Chrome Version: Pre-compiled ASAN Chromium 127.0.6535.0 (Developer Build) (64-bit)
Operating System: Win10 Build 19045.4291
REPRODUCTION CASE
Attached is a .html file containing a WebGPU shader. Opening the html file (on windows with the D3D12 backend) crashes the GPU process.
Reproducing the issue stand-alone on Linux also possible:
- Compile the standalone.wgsl with tint (commit 236295367f2e20a213d0b80f06d8b32175e54731) to hlsl via
./tint standalone.wgsl -o standalone.hlsl. I also attached standalone.hlsl, but you should get the very same file when compiling standalone.wgsl yourself - Compile the hlsl with dxc (commit 1c7cb4ffb89107ce2aea583b2387f88225a4a634):
./dxc-3.7 standalone.hlsl -T cs_6_2 -opt-disable structurize-loop-exits-for-unroll -HV 2018. Instead of a use-after-return, this triggers a heap UAF.
Attached:
- html that triggers an ASAN violation in chromium
- wgsl for producing the hlsl shader
- the hlsl shader
- asan log file
[7500:6748:0612/034217.772:WARNING:dns_config_service_win.cc(605)] Failed to read DnsConfig.
[7500:7272:0612/034223.767:WARNING:dns_config_service_win.cc(605)] Failed to read DnsConfig.
[5080:6500:0612/034224.690:WARNING:dns_config_service_win.cc(605)] Failed to read DnsConfig.
[7500:6748:0612/034233.783:WARNING:dns_config_service_win.cc(605)] Failed to read DnsConfig.
[5080:2152:0612/034244.714:WARNING:dns_config_service_win.cc(605)] Failed to read DnsConfig.
[7500:6748:0612/034253.798:WARNING:dns_config_service_win.cc(605)] Failed to read DnsConfig.
[5080:268:0612/034509.922:ERROR:sandbox_win.cc(836)] Sandbox cannot access executable. Check filesystem permissions are valid. See https://bit.ly/31yqMJR.: Access is denied. (0x5)
[5080:8872:0612/034953.671:INFO:CONSOLE(20)] "[object GPUDevice]", source: file://vboxsvr/shared/indexDropAllReferences.html (20)
=================================================================
==10144==ERROR: AddressSanitizer: stack-use-after-return on address 0x1274848db930 at pc 0x7ffd7248b011 bp 0x0026e77f9e50 sp 0x0026e77f9e98
READ of size 4 at 0x1274848db930 thread T0
==10144==WARNING: Failed to use and restart external symbolizer!
==10144==*** WARNING: Failed to initialize DbgHelp! ***
==10144==*** Most likely this means that the app is already ***
==10144==*** using DbgHelp, possibly with incompatible flags. ***
==10144==*** Due to technical reasons, symbolization might crash ***
==10144==*** or produce wrong results. ***
#0 0x7ffd7248b010 in `anonymous namespace'::TempOverloadPool::~TempOverloadPool C:\b\s\w\ir\cache\builder\src\third_party\dawn\third_party\dxc\lib\HLSL\HLMatrixLowerPass.cpp:63
#1 0x7ffd7248acf7 in `anonymous namespace'::HLMatrixLowerPass::runOnModule C:\b\s\w\ir\cache\builder\src\third_party\dawn\third_party\dxc\lib\HLSL\HLMatrixLowerPass.cpp:258
#2 0x7ffd70aeffff (<unknown module>)
Address 0x1274848db930 is located in stack of thread T0 at offset 2352 in frame
#0 0x7ffd7248622f in `anonymous namespace'::HLMatrixLowerPass::runOnModule C:\b\s\w\ir\cache\builder\src\third_party\dawn\third_party\dxc\lib\HLSL\HLMatrixLowerPass.cpp:213
This frame has 33 object(s):
[32, 40) 'agg.tmp.i.i.i23.i.i'
[64, 120) 'Builder.i.i.i' (line 778)
[160, 184) 'ref.tmp.i265.i.i.i.i'
[224, 232) 'agg.tmp.i.i.i.i.i'
[256, 280) 'ref.tmp.i.i233.i.i.i.i'
[320, 328) 'agg.tmp.i.i212.i.i.i.i'
[352, 376) 'ref.tmp.i.i.i.i.i'
[416, 424) 'agg.tmp.i.i183.i.i.i.i'
[448, 472) 'ref.tmp.i.i.i.i.i.i'
[512, 520) 'agg.tmp.i.i.i.i.i.i'
[544, 600) 'PreCallBuilder.i.i.i.i' (line 815)
[640, 696) 'agg.tmp.i.i.i122.i' (line 815)
[736, 760) 'ref.tmp.i.i.i.i' (line 833)
[800, 816) 'RetMatTy.i.i.i.i' (line 851)
[832, 888) 'AllocaBuilder.i.i.i.i' (line 863)
[928, 952) 'ref.tmp63.i.i.i.i' (line 865)
[992, 1048) 'PostCallBuilder.i.i.i.i' (line 867)
[1088, 1112) 'ref.tmp74.i.i.i.i' (line 868)
[1152, 1176) 'ref.tmp82.i.i.i.i' (line 876)
[1216, 1224) 'tmp.i.i' (line 308)
[1248, 1272) 'ref.tmp.i.i.i'
[1312, 1320) 'agg.tmp.i.i.i.i'
[1344, 1400) 'Builder.i.i' (line 734)
[1440, 1464) 'ref.tmp.i.i' (line 735)
[1504, 1520) 'ref.tmp5.i.i' (line 735)
[1536, 1952) 'DIB.i.i' (line 742)
[2016, 2040) 'MatAllocas.i' (line 268)
[2080, 2104) 'MatInsts.i' (line 269)
[2144, 2168) 'ref.tmp.i' (line 663)
[2208, 2224) 'ref.tmp14.i' (line 663)
[2240, 2288) 'matToVecStubs' (line 214)
[2320, 2368) 'vecToMatStubs' (line 215) <== Memory access at offset 2352 is inside this variable
[2400, 2424) 'Globals' (line 228)
HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
(longjmp, SEH and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-use-after-return C:\b\s\w\ir\cache\builder\src\third_party\dawn\third_party\dxc\lib\HLSL\HLMatrixLowerPass.cpp:63 in `anonymous namespace'::TempOverloadPool::~TempOverloadPool
Shadow bytes around the buggy address:
0x1274848db680: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
0x1274848db700: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
0x1274848db780: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
0x1274848db800: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
0x1274848db880: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
=>0x1274848db900: f5 f5 f5 f5 f5 f5[f5]f5 f5 f5 f5 f5 f5 f5 f5 f5
0x1274848db980: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
0x1274848dba00: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
0x1274848dba80: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
0x1274848dbb00: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
0x1274848dbb80: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
==10144==ADDITIONAL INFO
==10144==Note: Please include this section with the ASan report.
Task trace:
#0 0x7ffd37c492b0 in gpu::SchedulerDfs::TryScheduleSequence C:\b\s\w\ir\cache\builder\src\gpu\command_buffer\service\scheduler_dfs.cc:473
==10144==END OF ADDITIONAL INFO
==10144==ABORTING
[5080:8872:0612/034958.742:ERROR:gpu_process_host.cc(1007)] GPU process exited unexpectedly: exit_code=1
[5080:8872:0612/034958.742:WARNING:gpu_process_host.cc(1443)] The GPU process has crashed 1 time(s)
[5080:8872:0612/034958.777:INFO:CONSOLE(0)] "A valid external Instance reference no longer exists.", source: file://vboxsvr/shared/indexDropAllReferences.html (0)
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 lifetime bug in the HLSL compiler's matrix lowering pass, where a temporary overload pool is destroyed while still referenced, causing a stack use-after-return.
Impact
Opening a crafted page could crash the GPU process, causing a denial of service; the report does not claim code execution.
What the attacker needed
Windows with D3D12 backend; victim opens a crafted HTML file
How it was found
- Open the attached HTML file containing a WebGPU shader on Windows with the D3D12 backend.
- Observe the GPU process crash with an AddressSanitizer stack-use-after-return report.
- Alternatively, compile the standalone WGSL file with tint to produce HLSL.
- Compile the resulting HLSL with dxc using the given target and options to reproduce a heap use-after-free on Linux.
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.
WebGPU lets web pages run graphics code on the GPU. Chromium converts the page's shader code into another language (HLSL) and hands it to a compiler library. A bug in that compiler library makes it read memory that is no longer valid, which crashes the browser's 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.