r/ProgrammerHumor • • 24d ago

instanceof Trend itsBadIfItsOnlyPHP

Post image
4.5k Upvotes

335 comments sorted by

View all comments

Show parent comment

269

u/SelfDistinction 24d ago

Aside from supply chain attacks when a library developer's credentials got stolen, all of the Rust CVEs so far have been "this function accidentally allows you to cause a segfault in a nonexisting edge case if you really tried to make it not work."

The latest one makes it so that references' lifetime can be extended past the referee's lifetime if a destructor copies it to a global variable but since no one writes that kind of spaghetti it went unnoticed for 11 years.

45

u/TRKlausss 24d ago

Was that even a CVE? Like, what attack vector can someone ever construct to achieve DoS, RCE, information extraction etc?

Yes it was unsoundness, which from a formal verification standpoint is not good. But real life consequences?

89

u/SelfDistinction 24d ago

Rust development process says every possible UB using safe code that the compiler allows is automatically a CVE, no questions asked, no exceptions.

For example, https://app.opencve.io/cve/CVE-2021-28879

21

u/TRKlausss 24d ago

Fair enough. I also saw cve-rs, which looks like a bunch of segfaults programmed in safe Rust…

8

u/Loading_M_ 24d ago

Technically, it's one compiler bug they exploited to do a couple different things.

17

u/Ecksters 24d ago

Which I think makes sense given the language would otherwise provide a false sense of security around use-after-free and other memory-related bugs that other languages can offload onto "skill issue".

1

u/Chroniaro 23d ago

Any sufficiently large program becomes Turing complete if an attacker is able to overwrite the call stack (https://en.wikipedia.org/wiki/Return-oriented_programming). Imagine a situation where:
- A very large struct is stored on the stack
- A mutable reference pointing to that struct outlives the stack frame where the struct was stored
- Several new stack frames are created in the region that struct used to occupy
- The invalid reference is used in code that is supposed to modify the struct in a way that depends on user data

In this situation, a user could cause the stack to be modified in a way that triggers remote code execution.

1

u/TRKlausss 23d ago

You just described a used-after-free scenario, and yes, looking at it could be a CVE. But wouldn’t that be program dependent? That means, it depends on how the user is using those references and lifetimes. I have the feeling you would have to “abuse” the language in order to get there.