←back to thread

358 points dgl | 9 comments | | HN request time: 0.001s | source | bottom
Show context
dwrodri[dead post] ◴[] No.44502622[source]
[flagged]
1. jerf ◴[] No.44502680[source]
As the article says: "I find this particularly interesting because this isn't fundamentally a problem of the software being written in C. These are logic errors that are possible in nearly all languages, the common factor being this is a vulnerability in the interprocess communication of the components (either between git and external processes, or within the components of git itself). It is possible to draw a parallel with CRLF injection as seen in HTTP (or even SMTP smuggling)."

You can write this in any language. None of them will stop you. I'm on the cutting edge of "stop using C", but this isn't C's fault.

replies(1): >>44502905 #
2. gpm ◴[] No.44502905[source]
You can, but in languages like python/java/go/rust/... you wouldn't, because you wouldn't write serialization/de-serialization code by hand but call out to a battle hardened library.

This vulnerability is the fault of the C ecosystem where there is no reasonable project level package manager so everyone writes everything from scratch. It's exacerbated by the combination of a lack of generics (rust/java's solution), introspection (java/python's solution), and poor preprocessor in C (go's solution) so it wouldn't even be easy to make a ergonomic general purpose parser.

replies(2): >>44503022 #>>44504184 #
3. bangaladore ◴[] No.44503022[source]
I have a feeling that this code was developed before any of those languages were widely popular and before their package managers or packages were mature.

This file was written like 20 years ago.

replies(1): >>44503063 #
4. gpm ◴[] No.44503063{3}[source]
Sure, I'm not trying to assign blame to Linus for deciding to write git in C, I'm saying that modern tooling (not C) would prevent the bug with reasonably high probability and that that's a factor when deciding what to do going forwards.
5. shakna ◴[] No.44504184[source]
Python's pathlib wouldn't help you here, it can encode the necessary bits. Especially with configparser - it's 20 year old configuration reader. Java's story is worse.

What part of this would be prevented by another language?

You'd need to switch your data format to something like json, toml, etc. to prevent this from the outset. But JSON was first standardised 25 years ago, and AJAX wasn't invented when this was written. JSON was a fledgling and not widely used yet.

I guess we had netrc - but that's not standardised and everyone implements it differently. Same story for INI.

There was XML - at a time when it was full of RCEs, and everyone was acknowledging that its parser would be 90% of your program. Would you have joined the people disparaging json at the time as reinventing xml?

This vulnerability is the fault of data formats not being common enough to be widely invented yet.

replies(1): >>44504218 #
6. gpm ◴[] No.44504218{3}[source]
> What part of this would be prevented by another language?

> You'd need to switch your data format to something like json, toml, etc.

The part where if you wrote this in any modern languages ecosystem you would do this.

Yes, modern languages and their ecosystems likely did not exist back then. The lesson going forwards is that we shouldn't keep doing new things like we did back then.

Saying smithing metal by using a pair of hand driven bellows is inefficient isn't to say the blacksmiths ages ago who had no better option were doing something wrong.

replies(1): >>44504433 #
7. shakna ◴[] No.44504433{4}[source]
Ok... So you're not saying C is a problem.

You're saying every few years, we should torch our code and rewrite from scratch, using new tools.

... Enjoy your collapsing codebase. I'll stick with what works, thanks.

replies(1): >>44504480 #
8. gpm ◴[] No.44504480{5}[source]
What an absurdly bad faith interpretation. I never said anything to even suggest abandoning old code.

As demonstrated by vulnerabilities like the one in the article, C (and its ecosystem) doesn't "work", so I'm glad to hear that you won't be sticking with that for new projects going forwards.

replies(1): >>44508101 #
9. shakna ◴[] No.44508101{6}[source]
... Except you have already admitted that it has bupkus to do with C.

You said it was a lack of "modern tooling". Modern C toolchains vastly outstrip most, for modernity. C23 is three years old.

But no. I wont be breaking compatibility for everyone, just to chase a shiny nickel. That is burning the barnyard for fear of geese.