VFS: MergedFind TOCTOU use-after-free and missing pointer/dwSize checks in vfs_hooks #1378
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by microwave805 on 2026-11-24T15:31:20Z.
Checked on
main(930e8b4).Problem
TOCTOU use-after-free & aliased
&mutUB onMergedFind(crates/xcl/src/vfs_hooks.rs:952-961, 1128-1178):MERGEDtracks only raw pointer addresses (HashSet<usize>).hk_find_next_wandhk_find_next_acheckis_merged(h)(which locks and immediately unlocksMERGED), then callmerged_next(h)unlocked, creating&mut *(h as *mut MergedFind)while a concurrenthk_find_closecan dropBox::from_raw(h as *mut MergedFind):Unchecked caller pointers &
CREATEFILE2_EXTENDED_PARAMETERS.dwSize:find_first_vfs(vfs_hooks.rs:1051:*out = items[0]),hk_find_next_w(1139:*data = d), andw_to_a(1095:&mut *a) dereference caller output pointers without null checks.hk_create_file_2(vfs_hooks.rs:141) reads*((params as *const u8).add(8) as *const u32)without verifyingdwSize >= 12(unlikecopy_file_2_fail_if_existsat lines860-864).Minimal trigger
FindNextFileW/A(h, ...)concurrently withFindClose(h)(or two concurrentFindNextFile*calls) on a merged overlay find handle → UAF / aliased&mutUB.CREATEFILE2_EXTENDED_PARAMETERSstruct withdwSize < 12toCreateFile2, or a nullWIN32_FIND_DATA*toFindFirstFile*/FindNextFile*.Suggested fix
Store
HashMap<usize, MergedFind>keyed by synthetic opaque handle IDs inside theMERGEDmutex soFindNext*andFindClosehold the lock across lookup/mutation/removal, add null checks onout/data, and checkdwSize >= 12inhk_create_file_2.AI use: Antigravity (Gemini 4 Neon) performed the read-only source audit and drafted this issue; checked and verified on
930e8b4before opening.