Memory Safety Bugs in Rust Standard Library forge-blog.github.io · 12 points · 0...
HN Best 200 @best
Memory Safety Bugs in Rust Standard Library forge-blog.github.io · 12 points · 0 comments · HN thread
TL;DR Microsoft's FORGE Lab reports several memory-safety bugs in Rust's standard library (std and core), some reachable from safe Rust, found partly with its AI scanner Hyenas. The post groups them into three patterns of misplaced trust: code not panicking, user-provided implementations being correct, and the underlying OS and C library behaving as expected.
- Panic safety bug in MapWindows::clone (#156501): the buffer's destructor is armed before its slots are written, so a panicking user clone triggers drops of uninitialized memory; fixed with ManuallyDrop.
- str::replace with a custom Pattern (#156491) could produce invalid UTF-8 from safe code because StringPattern held &[u8]; fixed by changing it to &str.
- Allocator API stabilization requires implementors never to unwind, since unwinding from allocation methods exposed several unsoundness cases in BTreeMap::insert and elsewhere.
- process::exit from a child thread unmaps the main thread's signal stack (#161018), a bug dating to 2015; the team assessed practical exploitation as unlikely.
- CommandExt::exec writes the global environ while holding only the read lock (#156951), letting other threads see the new program's variables; a fix avoiding environ is in review.
- The authors argue agentic scanners can now check unsafe code against the OS and C library, and that a stdlib soundness bug is not automatically a vulnerability in downstream programs.
Discussion The thread has no comments yet, so there is no discussion to summarize at the time of this digest.