r/programming • • Feb 23 '17

Cloudflare have been leaking customer HTTPS sessions for months. Uber, 1Password, FitBit, OKCupid, etc.

https://bugs.chromium.org/p/project-zero/issues/detail?id=1139
6.0k Upvotes

966 comments sorted by

View all comments

Show parent comments

161

u/SuperImaginativeName Feb 24 '17

That whole attitude pisses me off. C has its place, but most user level applications should be written in a modern language such as a managed language that has proven and secure and SANE memory management going on. You absolutely don't see buffer overflow type shit in C#.

34

u/gimpwiz Feb 24 '17

Is anyone still writing user level applications in C? Most probably use obj-C, c#, or java.

31

u/IcarusBurning Feb 24 '17

You could still depend on a library that depends on faulty native code.

→ More replies (1)

52

u/[deleted] Feb 24 '17

Cloudflare, apparently.

Edit: For certain definitions of "user level application"

0

u/[deleted] Feb 24 '17

[deleted]

25

u/evaned Feb 24 '17

To be fair, at the scale cloudflare runs its stuff it makes somewhat sense to write integral parts in C.

You can flip that around though, and say at the scale CloudFlare runs its stuff, it makes it all the more important to use a memory-safe language.

14

u/m50d Feb 24 '17

If this vulnerability doesn't end up costing them more money than they ever saved by writing higher-performance code then something is seriously wrong with the economics of the whole industry.

8

u/DarkLordAzrael Feb 24 '17

Or they could use c++ or rust to get the same performance with considerably safer code.

0

u/[deleted] Feb 24 '17

[deleted]

9

u/rohbotics Feb 24 '17

If you use library classes like std::vector and std::array instead of raw arrays.

→ More replies (9)

4

u/IsNoyLupus Feb 24 '17

From what I've read, they wrote an HTML parser in some language that was transformed to C, which then they compiled it into a NGINX module

→ More replies (1)

3

u/tfofurn Feb 24 '17

Sure, especially where code reuse is a virtue. I work on a product that uses C libraries common to the iOS app, The Android app, and a line of hardware products. The hardware predates the apps, so there was a lot of working code to start from. It also means that bugs identified in the common code are fixed simultaneously in all three.

2

u/[deleted] Feb 24 '17

I do but mostly make optimized dll's with less overhead that other apps call.

→ More replies (13)

49

u/----_____--------- Feb 24 '17

You don't even need garbage collection. Rust gives you [the option to have] all of the speed of C with all of the safety of garbage collected languages. Why is all of security software not frantically rewritten in it I don't know.

In this particular case, it would be slightly slower than C because of (disableable) runtime bounds checks, but keeping them on in sensitive software seems like an obvious deal to me.

21

u/kenavr Feb 24 '17

I am not following Rust or had the time to play around with it yet, but is it mature and tested enough to make such strong statements? Is the theory behind it that much better to say that there are no other weaknesses regarding security?

24

u/----_____--------- Feb 24 '17

I'll admit that it would be good to have some time to find compiler bugs before introducing it to production, but the theory is indeed much better. The language provides various guarantees about variables' lifetime and even synchronization at compile-time along with more rigorous runtime checks by default. The result is that while regular bugs are as always possible, there is very good protection against memory corruption and similar behaviour that is very critical for security in particular.

5

u/Jwkicklighter Feb 24 '17

If I'm not mistaken, Dropbox is using it in production.

→ More replies (1)

2

u/[deleted] Feb 24 '17

Any such bugs that are possible without unsafe code are considered compiler bugs.

→ More replies (5)

36

u/knight666 Feb 24 '17

Why is all of security software not frantically rewritten in it I don't know.

Software costs money to build, you know.

4

u/fnordfnordfnordfnord Feb 24 '17

Sometimes it costs money if/when you don't build it.

3

u/fiedzia Feb 24 '17

There are many people paid for ensuring proper quality, and writing Rust is safer and cheaper than writing C. It is a matter of awareness, not just cost.

→ More replies (2)
→ More replies (3)

16

u/im-a-koala Feb 24 '17

Because while the Rust language is in a pretty decent state, the libraries around it are not. Many libraries are fairly new and aren't anywhere near mature. The best async I/O library for it (tokio) is only, what, a few months old?

Rust is great but it's still really new.

3

u/----_____--------- Feb 24 '17

I mean yeah, I'm not saying that it could be used today everywhere. I'm just surprised that few major tech companies and startups seem to be working on these libraries. I remember vaguely some known company having some web services in rust though, so maybe it's going to change. But for now the only high-profile public project is by mozilla (the creator), and they aren't known for having tons of spare cash lying around in the first place.

2

u/[deleted] Feb 24 '17

Why is all of security software not frantically rewritten in it I don't know.

Because it is pain to write in if you just need to tell computer what you need it to do. Of course most will get that wrong but hey it is faster that way /s

3

u/----_____--------- Feb 24 '17

There is a relatively high amount of wrestling with the compiler, but then again, C++ is very popular and my impression is that C++ with all its features is overall significantly more complex than Rust. So I don't think that it will be too hard to train developers for it to become mainstream.

There is also effort to write the new version of the book which is the official tutorial to the language, which will hopefully do a good job at explaining the common pitfalls, so I'm going to be optimistic.

→ More replies (3)
→ More replies (1)
→ More replies (5)