News for hackers. Stuff that matters.
Re:Let’s Stop Bashing C by kstrauser on Friday December 02, 2016 @11:53AM (#13090185)
I don't think that's true. Let's pick the Node.js ecosystem for an example (chosen because I use it very little, so I'm not hyping up my own pet language). Lots of non-expert programmers are writing Node packages, both for their own in-house use and to share with others. I'm going to assert that the average Node user has fewer years programming than the average C user. And yet, they seem to have fewer critical vulnerabilities per amount of code written. They still make mistakes all the time, sure! But they're a higher class of mistakes, more "this sets the wrong HTTP status code" and less "this exposes kernel memory to remote users". JavaScript handles the low-level abstractions so that its users can concentrate on breaking the higher-level stuff, hopefully in ways that are easier to test and notice.

Also, almost every language has a way to use C code directly (For example, see Go: https://golang.org/cmd/cgo/). C may be the best way to write low-level driver code. If it is, use it for that! I'm not convinced that there's a single best language for Ethernet card drivers and HTTP stacks, though.

Re:Let’s Stop Bashing C by dmitrygr on Friday December 02, 2016 @03:04PM (#13091829)
> fewer critical vulnerabilities per amount of code written

Because nobody uses node.js in serious infrastructure. Show me a serious ISP whose DHCP server is written in node. Know any whose DNS server is written in node?

Your statement is equivalent to: we should build bridges out of legos and not out of concrete because fewer people have been killed by collapsing lego bridges

Re:Let’s Stop Bashing C by taeric on Friday December 02, 2016 @12:04PM (#13090279)
What systems are we talking about, then? Few people are writing stuff in C/C++ nowdays. And the fields that do this on a regular basis are pretty much unchallenged by any of the higher level languages.

And, agreed, on truly expert systems, things do go polyglot. This has been true since pretty much the beginning of computers. I'm not sure what sort of evidence this provides, though.

So, to bring it directly to point. Where is the evidence that the systems people typically write in C could be written well in another language? About the best I have seen is some system utilities written in rust. Which is awesome, no doubt. And the beginnings of the evidence I'm asking for.

(To be fair, we often speak of mysterious wizards that wrote the symbolic lisp systems as though they succeeded at this. I want that to count as evidence, but it feels more like hearsay.)

Re:Let’s Stop Bashing C by hodgesrm on Friday December 02, 2016 @12:19PM (#13090420)
(Now arguing the other side...) There is a case for looking at safety issues in C. Reducing the possibilities for mayhem from null pointers would be helpful.

What I don't fully understand is critiques of C that lump safety issues in with use of braces or semi-colons.

Re:Let’s Stop Bashing C by taeric on Friday December 02, 2016 @12:23PM (#13090466)
A lot of the safety issues in C have been decently solved, though. You just have to use a larger tool chain than just the compiler. (Valgrind, coverity, etc.)
Re:Let’s Stop Bashing C by hodgesrm on Friday December 02, 2016 @12:50PM (#13090702)
Fair point, I think what's missing from some of the discussion here is that very few languages are productive without an effective toolchain.
Re:Let’s Stop Bashing C by taeric on Friday December 02, 2016 @01:32PM (#13091030)
Yeah. I have tried times in the past to make sure folks don't just think in terms of language, but full toolchains. I confess I am not good at that thinking, either. :(
Re:Let’s Stop Bashing C by ksk on Friday December 02, 2016 @12:16PM (#13090386)
IMHO, people constantly introduce vulnerabilities when using high level code. Most websites are defaced this way. They're not exploiting flaws in Apache or IIS anymore. Its the Python or PHP or Node.js application or wordpress blog or similar that doesn't sanitize user input or has a buggy web api.
Re:Let’s Stop Bashing C by jerf on Friday December 02, 2016 @12:19PM (#13090414)
A C program talking to the web will have memory vulnerabilities, encoding vulnerabilities, and business logic vulnerabilities.

A modern program talking to the web will have encoding vulnerabilities and business logic vulnerabilities.

It's still progress.

There are cutting edge stacks which will effectively eliminate the encoding vulnerabilities, too, leaving more-or-less just the bugs you put in.

(Obviously I'm simplifying the types of vulnerabilities that exist to make a point.)

Re:Let’s Stop Bashing C by ksk on Friday December 02, 2016 @12:32PM (#13090558)
Well, you could make another argument too. Given X amount of time in a day, a C programmer can't really pump out _that much_ business logic code because they're also dealing with the other lower level stuff.

A high level language OTOH allows you to be more productive in terms of the business logic stuff, and therefore, I'm using a rough metric here, more lines of code, which also means more bugs in the business logic.

Like you said, these are all simplifications, but I think the primary problem is that people undertake projects that are way above their competency level.

Edit: If we could get some multiplayer-game like matching system where you are matched with the project depending on your skill level that would be awesome.

Re:Let’s Stop Bashing C by Retra on Friday December 02, 2016 @08:23PM (#13093681)
If you're working on a project that is not above your competency level, then you're wasting your time.
Re:Let’s Stop Bashing C by EpicEng on Friday December 02, 2016 @09:19PM (#13093898)
Yes, because the ultimate purpose of delivering software is to challenge the company's developers.

/s

Re:Let’s Stop Bashing C by petra on Saturday December 03, 2016 @05:26PM (#13097800)
What stacks eliminate encoding vulnerabilities ? And are there any stacks that even protect you from writing bad business logic , if that's even possible ?
Re:Let’s Stop Bashing C by jerf on Sunday December 04, 2016 @05:00PM (#13102010)
Using something like Shakespeare for Haskell makes it very difficult to write HTML that is incorrectly encoded without doing it on purpose: https://hackage.haskell.org/package/shakespeare

More conventionally, even something like Go's html/template [1], though I believe it uses a technique that can ultimately be fooled, is much harder to write accidental encoding vulnerabilities into. If you do the natural thing in the templates, the templates do the right thing.

Business logic errors I don't expect to be prevented by, well, anything. Oh, you can do some work to prevent certain sorts of errors with type systems, but a lot of business logic errors often start in the requirements, or the translation of the requirements into the code. Nothing will ever stop us from taking fuzzy requirements and translating them into wrong code, even if we can at least ensure the wrong code doesn't crash, corrupt memory, expose encoding errors, or violate simple invariants.

Re:Let’s Stop Bashing C by nickpsecurity on Saturday December 03, 2016 @06:06PM (#13097932)
You can use secure parser generators like HAMMER or Nail for encodings. If it's about integration, you can use something like ZeroMQ.

Far as eliminaging logic errors, you can make a lot of progress on that using formal specifications combined with modular code that matches them well. That's how med-high assurance was done. Some companies also specify domain rules in formal logic then implement them in Prolog or Mercury. You will have a hard time straying from intended logic when executing the logic itself. ;) Toolkits like Allegro CL and sklogic's DSL scheme let you mix and match things like LISP for power, ML for safety, and Prolog for logic execution.

Really niche stuff in industry, though.

Re:Let’s Stop Bashing C by kstrauser on Friday December 02, 2016 @12:21PM (#13090442)
That's all true, but consider how many vulnerabilities we'd be seen if the programmers who wrote those applications also had to deal with pointers and memory management. You'd get the current problems plus all of the stuff that regularly snags systems programmers.
Re:Let’s Stop Bashing C by ksk on Friday December 02, 2016 @12:28PM (#13090516)
I agree and we can take it further. If we had to hand encode the instructions it would cause even more bugs. The more decisions you have to make as a programmer, the more chances there are of making errors. High level languages make some decisions for you, but people still end up making mistakes. Maybe the goal should be to increase the bar at which a programmer is considered competent.
Re:Let’s Stop Bashing C by zzzcpan on Friday December 02, 2016 @12:48PM (#13090678)
I think you look at it a bit incorrectly. Those high level languages were designed not to avoid mistakes, but to push software complexity to a whole new level. You simply won't be able to get to that complexity with a lower level language, because people have limited ability to think about things and tend to fallback to solutions they can fit in their mind. Which is why you shouldn't expect high level languages to eliminate vulnerabilities, people still use their minds to the limits and make mistakes. Other approaches must be taken.
Re:Let’s Stop Bashing C by ksk on Friday December 02, 2016 @12:56PM (#13090752)
I think we agree. Its hard to encapsulate everything, so I just chose a smaller context for my argument. I was primarily thinking about resource allocation and such.

A HLL does indeed allow you to compose solutions to problems in terms of higher level abstractions, which I gather is your point.

Re:Let’s Stop Bashing C by hodgesrm on Friday December 02, 2016 @12:06PM (#13090303)
But it seems the OP's implicit point was that C is not the right language for higher-level operations. For low-level access it's not very obvious what else you would use.

Personally I rarely use C because I currently write network services with REST APIs. C is close to worthless for that purpose for many reasons, not just errors. It's analogous to writing an accounting app in assembler. Most people stopped doing that in the 1960s.

Re:Let’s Stop Bashing C by pjmlp on Friday December 02, 2016 @04:18PM (#13092375)
> For low-level access it's not very obvious what else you would use.

Extended Algol, created in 1961. Almost 10 years before C.

There are tons of other examples.

C got widespread thanks to UNIX, just like a few decades later, JavaScript got widespread thanks to Web 2.0 and the browser.

> It's analogous to writing an accounting app in assembler. Most people stopped doing that in the 1960s.

Lotus 1-2-3 was initially written in Assembler, Ι will let you track down when it was created.

My last 100% Assembly program was for MS-DOS in 1996.

Re:Let’s Stop Bashing C by hodgesrm on Friday December 02, 2016 @07:03PM (#13093357)
> Lotus 1-2-3 was initially written in Assembler, Ι will let you track down when it was created.

Interesting! I did not know that. I would still stand by the point that application programming by the end of the 60s was leaving the Assembler era and moving on to languages like COBOL and FORTRAN. (And weird cul-de-sacs like RPG which was my second programming language after BASIC.)

Re:Let’s Stop Bashing C by pjmlp on Saturday December 03, 2016 @02:18AM (#13094774)
This was true on mainframes and workstations.

At 8 bit and 16 bit computers target for consumers it was a different story.

Forth, Basic, Pascal, C, Amos, Modula-2, Clipper were the "managed languages".

Anything that required performance was written in Assembly, or high level in such "managed language" (Turbo Pascal on my case) with lots of inline Assembly.