News for hackers. Stuff that matters.
Re:‘Zero-click’ hacks are growing in popularity by Dagonfly on Saturday February 19, 2022 @03:25PM (#30400199)
These Rust vs C comparison often get fixated on the, somewhat unique, memory safety advantage of Rust. But the proper comparison should be ANY modern language vs. C, cause those remove a heap of other C footguns as well. Most modern language have:

- sane integers: no unsafe implicit cast, more ergonomic overflow/saturate/checked casts

- sane strings: slices with length, standardized and safe UTF-8 operations

- expressive typing preventing API misuse: monads like Optional/Result, mandatory exception handling, better typedefs, ADTs vs tagged unions

And even without the full Rust ownership model, I'd expect the following to solve a majority of the memory safety problems:

- array bounds checks (also string bounds checks)

- typed alloc (alloc a specific type rather than N bytes)

- non-null types by default

- double-free, use-after-free analysis

- thread-save std APIs

In the write-up you linked, Section 2 is a missing error check => Result<T> would surface that. The macOS case contains a relative path vs string comparison => expressive typing of Path would disallow that. DriverKit exploit is a Non-NULL vs NULL API mistake. Kernel PAC is a legit ASM logic bug, but requires a confusion of kernel stack vs. user stack => might have been typed explicitly in another language.

There are no comments on this comment yet.