News for hackers. Stuff that matters.
Re:Is OpenSMTPD worthy of OpenBSD inclusion? by vezzy-fnord on Monday October 05, 2015 @02:12PM (#10333650)
The only currently-extant memory-unsafe language.

Some variants of Forth?

OpenSMTPD actually dates back earlier to around 2009, when it was introduced in 4.6.

Not that this is even notable, as virtually all major OpenBSD projects are C-based.

Re:Is OpenSMTPD worthy of OpenBSD inclusion? by jerf on Monday October 05, 2015 @02:32PM (#10333769)
Starting in 2009 mitigates my criticism by, oh, let's say, 40%. Which I mean as an acknowledgment of your correction, even as I'm not generally backing down from the core point.

I want to respect OpenBSD. To a great extent, I do. And there are reasons to prefer tested C codebases to untested code bases in new languages, sure. But to the extent I can't give my full, unadulterated respect to OpenBSD, it is because I don't see that they consider everything being in C a problem to be solved.

I mean, I get engineering considerations and that we can't rewrite everything at the drop of a hat and performance matters, etc. But it is my opinion that any engineer that cares about security really ought to see "written in C" as starting out with a huge entry on the debit side, and take appropriate actions. And every year that goes by that's more true.

Re:Is OpenSMTPD worthy of OpenBSD inclusion? by vezzy-fnord on Monday October 05, 2015 @02:51PM (#10333930)
I'm conflicted on the issue. As a general principle, writing security-conscious code in C should be avoided.

On the other hand, the issue is a tad more subtle. There seems to be an almost Pavlovian revilement and panic against C code, and this usually comes from people who haven't dealt with the language in a long time or at all in any depth.

For one thing, the blanket assertion that secure C code is a Herculean task, doesn't quite pan out. djb showed one way, based on a few general principles espoused in qmail, that has since successfully been reapplied by people like Wayne Marshall, Laurent Bercot, Bruce Guenter, Paul Jarc, JdeBP and so on. Much of it comes from abandoning the C standard library in favor of more robust alternatives like libdjb variants, clearly architecting process/module boundaries, using simple formats like netstrings and text0 that need not be "parsed" in the conventional sense, etc.

Further along the line, we have the SEI CERT C Coding Standard that comprehensively identifies many pitfalls. [1]

Deeper still, cryptography is one area where abstraction can be an enemy. You actually have to deeply worry about time complexity, branch prediction, precise timing, compiler optimizations and so on [2]. A tool like C becomes desirable here.

Lastly, but crucially - you're on Unix, for better or for worse. POSIX, SUS, all of those standards? They're deeply written with the conventions and API/ABI semantics of C in mind. Such is life. When you primarily write code at that level, the easiest way not to have any impedance mismatch is to just write it in C.

[1] https://www.securecoding.cert.org/confluence/display/c/SEI+C...

[2] https://cryptocoding.net/index.php/Coding_rules

Re:Is OpenSMTPD worthy of OpenBSD inclusion? by jerf on Monday October 05, 2015 @04:02PM (#10334459)
I don't consider my revulsion Pavlovian. Even if I have had that particular connection repeatedly made, the point is that if it requires super-mega-experts to code in a totally specialized manner, using libraries other than the easiest to use, using levels of care attainable only by the top 1% of programmers, it's not a suitable language for the vast bulk of people to pick up. And even the top 1% of programmers would probably be well suited to do something else with their cognitive firepower. The fact that somebody once proved capable of walking on a tightrope between World Trade towers does not prove tightrope walking above vast chasms to be a safe mode of transport.

For crypto, at this point, C is now too abstracted from the hardware to be useful. You need assembler, and that's getting dangerously abstract too, since it's actually an abstract language over the microcode that actually execute, the entire point of which is generally to provide lovely, wonderful things... that trash timing guarantees that crypto would like.

"I had to write code that allows remote attackers to own the machine because it was the only way to avoid impedence mismatch."

Incidentally, since it hasn't come up, note that I consider "C + useful static analysis tools" to be a different language. "C + useful static analysis tools" can be a sensible choice. I still at least have questions about the cognitive load being loaded on to the developer vs. a language that removes the problems entirely, but it must be acknowledged as having radically different cost/benefit profiles. However, I observe that very few people seem to be using useful static analysis tools beyond -Wall.

Re:Is OpenSMTPD worthy of OpenBSD inclusion? by nickpsecurity on Monday October 05, 2015 @02:16PM (#10333667)
Yeah, there are other memory-unsafe languages. His overall point remains. Matter of fact, thanks to you, I can now drop bombs on concurrency angle thanks to Concurrent Pascal, Solo, etc. Relevant given all the C & BSD apps juggling threads. To think mainstream is just now solving these problems in past 3-5 years despite proven solutions available... (rolls eyes)
Re:Is OpenSMTPD worthy of OpenBSD inclusion? by vezzy-fnord on Monday October 05, 2015 @02:22PM (#10333707)
I don't see what concurrency has to do with any of this.

Concurrent Pascal was an interesting project for its time, heavily dated by now. The greatest victory for concurrency was having architectures with thread-level parallelism instead of the dominant instruction-level parallelism, and one specifically optimized for CSP in the occam language. This was, of course, the transputer. So much for that.

Erlang/OTP leads in the modern era.

But I don't see any relation to our current topic of discussion.

Re:Is OpenSMTPD worthy of OpenBSD inclusion? by nickpsecurity on Monday October 05, 2015 @02:30PM (#10333753)
Server apps, including mail, implement forms of concurrency to handle incoming requests. Smart ones use either multi-threading or event model for performance. OpenBSD and others have all kinds of such apps they built on C. There have been numerous concurrency-related errors in major server apps due to this. So, just like with C itself, ignoring the safe, concurrency approaches from languages like Concurrent Pascal (or SCOOP/Eiffel today) is a failure to learn from the past with a direct, proven cost.

Think all the race conditions, deadlocks, etc that have hit server apps would've happened on Solo, Ada tasking, or SCOOP? Probably fewer to none. So, it's still relevant and Ada/Eiffel are actually building on it. Especially SCOOP R&D community.

Re:Is OpenSMTPD worthy of OpenBSD inclusion? by vezzy-fnord on Monday October 05, 2015 @02:37PM (#10333815)
Oh, you're criticizing shared-state concurrency, I take it. Event loops seem to have been the norm for C projects for a while.

Both OpenSMTPD and qmail seem to rely on concurrency through forkexec, which would entail deferring to the kernel's CPU scheduling and job control.

Re:Is OpenSMTPD worthy of OpenBSD inclusion? by nickpsecurity on Monday October 05, 2015 @02:45PM (#10333889)
Yeah, specifically unsafe handling of it. Forkexec seems to be a heavyweight (and less portable) approach that even DJB defended in his paper. My gripe should apply to any using threads.

"Event loops seem to have been the norm for C projects for a while."

I'll take you word for it as I've seen that in the few, top-tier ones I scrutinized. There's a similar trail of research dealing with that alternate model. Have a feeling the meme might apply there, too, but won't accuse them until I see for sure. ;)