News for hackers. Stuff that matters.
Re:DARPA: Translating All C to Rust (Tractor) by pjmlp on Wednesday July 31, 2024 @02:40AM (#41116874)
Modern C still has the same security exploits in arrays and strings as Classical C, nothing changed in 50 years.
Re:DARPA: Translating All C to Rust (Tractor) by Y_Y on Wednesday July 31, 2024 @04:23AM (#41117324)
The 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.
Re:DARPA: Translating All C to Rust (Tractor) by pjmlp on Wednesday July 31, 2024 @05:00AM (#41117481)
Meaningless changes, as proven by the CVE database, or the kernel corruption by a bad pointer caused by Crowdstrike.
Re:DARPA: Translating All C to Rust (Tractor) by Y_Y on Wednesday July 31, 2024 @07:41AM (#41118283)
I 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.
Re:DARPA: Translating All C to Rust (Tractor) by pjmlp on Wednesday July 31, 2024 @07:56AM (#41118395)
ISO 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.

Re:DARPA: Translating All C to Rust (Tractor) by Y_Y on Wednesday July 31, 2024 @09:07AM (#41118872)
You'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.

Re:DARPA: Translating All C to Rust (Tractor) by RavSS on Wednesday July 31, 2024 @04:23PM (#41123058)
>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.

Re:DARPA: Translating All C to Rust (Tractor) by Avamander on Wednesday July 31, 2024 @05:44AM (#41117666)
All 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.

Re:DARPA: Translating All C to Rust (Tractor) by nanolith on Wednesday July 31, 2024 @07:20AM (#41118151)
Bounded 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.

Re:DARPA: Translating All C to Rust (Tractor) by pjmlp on Wednesday July 31, 2024 @07:55AM (#41118383)
The 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.

Re:DARPA: Translating All C to Rust (Tractor) by nanolith on Wednesday July 31, 2024 @08:05AM (#41118459)
> 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.

Re:DARPA: Translating All C to Rust (Tractor) by pjmlp on Wednesday July 31, 2024 @10:17AM (#41119376)
50 years are more than enough time to improve C's security story.
Re:DARPA: Translating All C to Rust (Tractor) by nanolith on Wednesday July 31, 2024 @11:29AM (#41120068)
Yep, but we have to deal with what we have. For better or for worse, C remains where it is. We can either use process and tools to improve existing C, or throw our hands up.

I prefer to work toward fixing what is. We are unlikely to see things like array slices in C, and even if such features were added, this does nothing to fix the billions of lines of legacy code out there.