News for hackers. Stuff that matters.
Re:Stranger Strings: An exploitable flaw in SQLite by p-e-w on Tuesday October 25, 2022 @10:16AM (#33330746)
It's not about the borrow checker in this case. The borrow checker deals with ownership, which mostly protects against thread safety issues, data races, and use-after-free.

Here we are dealing with a memory safety problem of a type that cannot occur in Rust unless you use `unsafe` blocks. Rust doesn't allow unsafe memory access such as pointer arithmetic or out-of-bounds operations (those produce a runtime panic). C happily accepts those, and the effects may include buffer overflows leading to arbitrary code execution.

This should never, ever be possible when writing a normal program. I love that Rust has named the keyword that enables such things "unsafe", because that's precisely what it is. That C has this behavior as a default is nothing short of madness, though of course C is an artifact of a time when such issues weren't understood as well as they are today.

Re:Stranger Strings: An exploitable flaw in SQLite by schemescape on Tuesday October 25, 2022 @11:33AM (#33331984)
So if SQLite was written in Rust, this would cause a runtime panic and thus would only be a denial of service CVE. Is that correct?
Re:Stranger Strings: An exploitable flaw in SQLite by p-e-w on Tuesday October 25, 2022 @12:16PM (#33332624)
If the code were entirely analogous, that is correct, unless the Rust code used some kind of `unsafe` tricks in order to increase performance (this is fairly common in advanced Rust code).

That being said, whether a runtime panic leads to DoS depends on the execution model. In web applications, threads are usually mapped to connections in some way, and a runtime panic only unwinds the thread it occurs in, so this wouldn't necessarily mean that other users experience service disruptions.

More to the point, I'd expect modern application and/or library code to include default safety checks that prevent scenarios like absurdly large queries from happening in the first place, and provide recoverable errors if such pathological inputs are encountered.

Re:Stranger Strings: An exploitable flaw in SQLite by fps-hero on Tuesday October 25, 2022 @12:18PM (#33332651)
The bug relies on undefined behaviour in the C language, but it’s exploitable is due to the way memory access operations are written in C. Equivalent Rust code would not be exploitable at a language level because that type of raw pointer array access isn’t possible with resorting to unsafe blocks. The undefined behaviour that caused the bug also doesn’t not exist in Rust.
Re:Stranger Strings: An exploitable flaw in SQLite by chc4 on Tuesday October 25, 2022 @02:03PM (#33334088)
Yes. If you index out of bounds in a Rust program, it will raise a panic. This is infinitely better than causing memory unsafety and creating a remote code execution exploit, and the best you can possibly do.
Re:Stranger Strings: An exploitable flaw in SQLite by PathOfEclipse on Tuesday October 25, 2022 @12:14PM (#33332590)
If your bounds checks can make your programs as much as twice as slow, then I think it's worth considering that bounds checking is not a panacea for low-level code: https://coaxion.net/blog/2018/01/speeding-up-rgb-to-grayscal...
Re:Stranger Strings: An exploitable flaw in SQLite by danhor on Tuesday October 25, 2022 @12:36PM (#33332909)
If the compiler can be sure that there is no bounds checking needed and can skip it. Rust provides facilities for this, C and C++ less so.

We have seen time and time again that humans aren't good enugh at that task, even in low-level code (and 2x is very buch an outlier).