A remote code execution vulnerability in GNOME
A remote code execution vulnerability in GNOME
Posted Oct 11, 2023 14:07 UTC (Wed) by farnz (subscriber, #17727)In reply to: A remote code execution vulnerability in GNOME by dvrabel
Parent article: A remote code execution vulnerability in GNOME
As a Rust reviewer, I pick on the following issues; let's assume that I don't spot the vulnerability, but that I throw this code back to you with the following comments. Can you rework to address my review comments, without making the bug more obvious?
- I see three casts using "as"; these are dangerous because they don't do checks as part of the cast. Can you rewrite these using from, into, try_from or try_into?
- The Rust compiler is great at optimizing out bounds checks in most situations; can you use get, instead of get_unchecked, and rely on the optimizer removing the bounds check? If not, why not?
Basically, you've got two things in there (get_unchecked, and as casting) which trigger my "this is likely to be buggy" radar. Add in "unsafe", which triggers my "this needs close inspection" radar, and I'm likely to spot that there is an issue when I try to get you to write better Rust.
