rust-runtime-bug-classes
Installation
SKILL.md
Bugs Rust's Type System Won't Catch
Rust prevents memory unsafety and data races, not logic bugs that live in syscalls, encoding, error propagation, or trust boundaries. These are the recurring classes.
Filesystem race & identity bugs
| Bug | Wrong | Right |
|---|---|---|
TOCTOU between remove_file + create |
fs::remove_file(p)?; File::create(p)? |
OpenOptions::new().create_new(true).open(p) — atomic, refuses dangling symlinks |
| Default perms then chmod | create_dir(p)?; set_permissions(p, 0o700)? |
DirBuilderExt::mode(0o700) / OpenOptions::mode() at creation; set umask explicitly |
| Path equality via string | file == Path::new("/") |
fs::canonicalize(file)?; for identity, compare (dev, inode) from MetadataExt |
| Path operations on tainted input | resolving paths repeatedly | Anchor on a file descriptor (e.g. openat, cap-std crate) instead of re-resolving paths |
OsStr / bytes vs String
Filesystem paths and process args are not guaranteed UTF-8 on Unix.