Memory Safety Bugs in Rust Standard Library forge-blog.github.io · 15 points · 2...
HN Best 200 @best
Memory Safety Bugs in Rust Standard Library forge-blog.github.io · 15 points · 2 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 entirely safe code, found partly with its AI scanner Hyenas (research version of MDASH). The post groups them into three patterns of misplaced trust: code not panicking, user-provided trait implementations being correct, and the underlying OS and C library state staying as expected.
- Examples include a panic-safety bug in MapWindows::clone (#156501) and a str::replace bug where a safe custom Pattern produced invalid UTF-8 (#156491), fixed by changing StringPattern to hold &str.
- Allocator API stabilization (Rust 1.100, November 12) requires implementors never to unwind, after reports of BTreeMap::insert becoming unsound with unwinding allocators.
- process::exit from a child thread unmaps the main thread's signal stack (#161018), a bug dating to 2015; the authors 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 and risking use of a freed array.
- The authors argue soundness bugs in std are not automatically vulnerabilities in programs; they need unusual setups to trigger, and the fixes are made once in the library.
Discussion The comment thread is nearly empty: only one comment, from nektro, which is a short quote-style remark naming the lab that wrote the post. There is no substantive discussion yet, so no community view on the bugs or on the AI-assisted methodology has formed.