Most active commenters
  • gpm(5)
  • shakna(3)

←back to thread

358 points dgl | 28 comments | | HN request time: 1.681s | source | bottom
1. asplake ◴[] No.44502647[source]
The article refutes that somewhat:

> 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).

2. bpt3 ◴[] No.44502649[source]
As mentioned in the article, this is a logic error that has nothing to do with C strings.
replies(1): >>44502702 #
3. 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 #
4. eptcyka ◴[] No.44502702[source]
Whilst true, there’s a swathe of modern tooling that will aide in marshalling data for IPC. Would you not agree that if protobuf, json or yaml were used, it’d be far less likely for this bug have slipped in?
replies(4): >>44502886 #>>44502968 #>>44503106 #>>44504894 #
5. mrkeen ◴[] No.44502759[source]
C programmers don't see C problems. They see logic errors that are possible in any language.
replies(1): >>44503069 #
6. alexvitkov ◴[] No.44502788[source]
We keep getting RCEs in C because tons of useful programs are written in C. If someone writes a useful program in Rust, we'll get RCEs in Rust.
replies(2): >>44503167 #>>44504743 #
7. smileson2 ◴[] No.44502823[source]
If only it were just the c code that was causing people to be owned lol
8. ◴[] No.44502866[source]
9. alexvitkov ◴[] No.44502886{3}[source]
In isolation, for any one particular bug, yes, but if you start applying this logic to everything, even problems as simple as reading some bytes from a file, you end up with a heao of dependencies for the most mundane things. We've tried that, it's bad.
replies(3): >>44502921 #>>44503094 #>>44503589 #
10. tuetuopay ◴[] No.44502900[source]
Using other languages would likely fix the issue but as a side-effect. Most people would expect a C-vs-Rust comparison so I’ll take Go as an example.

Nobody would write the configuration parsing code by hand, and just use whatever TOML library available at hand for Go. No INI shenanigans, and people would just use any available stricter format (strings must be quoted in TOML).

So yeah, Rust and Go and Python and Java and Node and Ruby and whatnot would not have the bug just by virtue of having a package manager. The actual language is irrelevant.

However, whatever the language, the same hand implementation would have had the exact same bug.

11. 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 #
12. gpm ◴[] No.44502921{4}[source]
On the contrary, we've tried it and it works great.
13. bangaladore ◴[] No.44502968{3}[source]
The OC was about language choice. You can use protobuf, json or yaml in C as well.

In general, though, all these can be wildly overkill for many tasks. At some point you just need to write good code and actually test it.

14. bangaladore ◴[] No.44503022{3}[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 #
15. gpm ◴[] No.44503063{4}[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.
16. dietr1ch ◴[] No.44503069[source]
Running with scissors isn't a problem. The problem is stabbing yourself with them. Isn't it obvious?
17. sunshowers ◴[] No.44503094{4}[source]
No, I think in general you should trust other people with experience in an area more than your own naive self. Division of labor and all that.

There are exceptions, as always, but using dependencies is good as a first approximation.

18. greatgib ◴[] No.44503106{3}[source]
Having "safe" yaml parsing is a whole topic of head scratching in whatever language of your choice if you want a rabbit hole to look into...
19. dietr1ch ◴[] No.44503167[source]
It's not that only C programs are useful. It's that subtle mistakes on C result in more catastrophic vulnerabilities.

Make a mistake in application code in a language like, say Java, and you'll end up with an exception.

20. eptcyka ◴[] No.44503589{4}[source]
I don't believe we must apply any guideline ad absurdum. Using a battle tested marshalling/serialization library is clearly the way to go most often. Of course, one can still construct difficult to parse XML and JSON or any other blob for any given format, but the chances that bad input will result in an RCE are lower.
21. shakna ◴[] No.44504184{3}[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 #
22. gpm ◴[] No.44504218{4}[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 #
23. shakna ◴[] No.44504433{5}[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 #
24. gpm ◴[] No.44504480{6}[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 #
25. umanwizard ◴[] No.44504743[source]
There are a lot of useful programs written in Rust nowadays. This comment might have made more sense like 5 years ago.
26. bpt3 ◴[] No.44504894{3}[source]
No I would not agree that YAML or JSON parsers in any language are far less likely to have logic errors, and I'm not sure why protobuf (a binary format) would be a good choice for a human readable file.

INI is not a particularly complex format (less complex than YAML for example), and there are existing open source parsers written in C that could have been used.

You can dig in all you want, but this is not an issue with C strings or the INI format.

replies(1): >>44508438 #
27. shakna ◴[] No.44508101{7}[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.

28. account42 ◴[] No.44508438{4}[source]
This isn't even a parser error at all - the INI format comes from DOS/Windows where a trailing carriage return would not be considered part of the value either.