3 ms·
Modern C still has the same security exploits in arrays and strings as Classical C, nothing changed in 50 years.
by pjmlp 2y ago
Modern C still has the same security exploits in arrays and strings as Classical C, nothing changed in 50 years.
- Y_Y 2y agoThe programmers have changed, the machines have changed, the literature has changed, the compilers have changed a lot. You can still write and run the old insecure code, but you'll get warnings and hit stack canaries and your colleagues will gasp at you and your merge requests will be rejected.
- pjmlp 2y agoMeaningless changes, as proven by the CVE database, or the kernel corruption by a bad pointer caused by Crowdstrike.
- Y_Y 2y agoI respectfully disagree. GP claimed that nothing has changed [regarding string and array security bugs in C] in 50 years. I responded that many relevant factors have changed, such that people tend to write different code now which is less susceptible to those bugs. Of course the same old bugs are possible, and sometimes good coders will still write them. Still I argue that there has been meaningful change since there are more protections against writing bugs in the first place, less incentive to write dangerous code, and more security for when (some) bugs still appear.
- pjmlp 2y agoISO C89 is exactly like ISO C23 in that regard. CVE database proves that those kind of errors keep coming up in 2024, regardless of those changes. Not only do they keep coming up, the monetary cost of fixing those issues has raised up to a level that now even governments are looking into this.
- Y_Y 2y agoYou've made three true statements, but I don't agree if you're implying that they prove that "nothing has changed". Bugs still appear, but they are significantly less common (per project or line not per year) and not as damaging when they occur. This is a non-trivial change for the better in the realm of C application quality. There are more slaves in the world now than ever before in history, but global society has still made great progress on eliminating it in the last thousand years.
- RavSS 2y ago>ISO C89 Not that it matters, but isn't that technically ANSI C(89)? If I remember correctly, the first ISO C standard is instead C90, which is basically identical to C89.
- Avamander 2y agoAll that has changed but we still got the libcue code execution bug. I could not find an open-source static analyzer (including -analyzer) that would actually pick up the flaw before someone tries to exploit it. And that's a simple example. We can't tame the dragon C is, empirically nobody can.
- nanolith 2y agoBounded model checking has changed things. C on its own can't solve these problems. Likewise, Rust on its own -- while it can solve memory errors -- can't demonstrate safety from all errors that lead to CVEs. Practical formal methods using a tool like CBMC can make C safer. The existing code base can be made safer without porting it to a new language or using experimental mechanical translation. This isn't just something for C. Such tools exist for many languages now, including Rust, so that even Rust can be made safer.
- pjmlp 2y agoThe amount of people using stuff like CBMC is like trying to boil the ocean. WG14 can solve those problems, they decided it isn't their priority to fix C.
- nanolith 2y ago> The amount of people using stuff CBMC is like trying to boil the ocean. That's like saying, "Getting everyone to use Rust or TDD or X is like trying to boil the ocean." It's impossible to solve all things for all people at once. But, that doesn't mean that we can't advocate for tooling that can be used today to build safer software. This goes beyond C, as such tools and techniques are being ported to many languages and platforms. Rust is a solution that works for some people. Modern C with bounded model checking is another solution that works for some other people. I'm certainly not going to change the minds of folks who have decided to port a project to Rust and who are willing to spend the engineering budget for this. But, hopefully, I can convince someone to try bounded model checking instead of maintaining the status quo. Because, the status quo is where we are with projects like the Linux kernel. Linux may pay lip service to Rust folks and allow them to write some components in that language, but the majority of the kernel is still in C and is not being properly vetted for these vulnerabilities, as we can see with the stream of CVEs coming out weekly. > WG14 can solve those problems, they decided it isn't their priority to fix C. WG14 must maintain some semblance of backwards compatibility with previous versions of C. It's no good to make a feature that breaks older code. This happens from time to time -- old school K&R C won't work in a C18 or C23 compliant compiler -- but efforts are made to keep that legacy code compiling, for good or ill.