diff --git a/crates/potato/RUSTSEC-0000-0000.md b/crates/potato/RUSTSEC-0000-0000.md new file mode 100644 index 0000000000..12723083d8 --- /dev/null +++ b/crates/potato/RUSTSEC-0000-0000.md @@ -0,0 +1,27 @@ +```toml +[advisory] +id = "RUSTSEC-0000-0000" +package = "potato" +date = "2026-05-02" +url = "https://github.com/fawdlstty/potato/issues/1" +informational = "unsound" +categories = ["memory-corruption"] +keywords = ["undefined-behavior", "utf-8"] + +[versions] +patched = [] +``` + +# `RefStr::from_slice()` allows constructing invalid UTF-8 from safe code + +`RefStr::from_slice(data, start, len)` is declared safe but uses +`unsafe { data.get_unchecked(start) }` internally without validating `start` +and `len`. Callers can construct a `RefStr` pointing to arbitrary bytes. + +Combined with `to_str()`, which calls `std::str::from_utf8_unchecked()` on +the underlying bytes, a caller can produce an invalid `&str` that violates +Rust's safety requirements. For example, slicing a multi-byte UTF-8 character +in the middle produces an invalid `&str`. + +Both `from_slice()` and `to_str()` are public safe APIs, so this undefined +behavior can be triggered without writing any `unsafe` code. \ No newline at end of file