r/programming • • Apr 09 '14

Theo de Raadt: "OpenSSL has exploit mitigation countermeasures to make sure it's exploitable"

[deleted] — view deleted post

2.0k Upvotes

661 comments sorted by

View all comments

Show parent comment

329

u/pmrr Apr 09 '14

I bet the developer thought he was super-smart at the time.

This is a lesson to all of us: we're not as smart as we think.

514

u/zjm555 Apr 09 '14

Well said. This is why, after years of professional development, I have a healthy fear of anything even remotely complicated.

351

u/none_shall_pass Apr 09 '14

Well said. This is why, after years of professional development, I have a healthy fear of anything even remotely complicated.

After spending the late 90's and early 2000's developing and supporting high profile (read: constantly attacked) websites, I developed my "3am rule".

If I couldn't be woken up out of a sound sleep at 3am by a panicked phone call and know what was wrong and how to fix it, the software was poorly designed or written.

A side-effect of this was that I stopped trying to be "smart" and just wrote solid, plain, easy to read code. It's served me well for a very long time.

This should go triple for crypto code. If anybody feels the need to rewrite a memory allocator, it's time to rethink priorities.

220

u/frymaster Apr 09 '14

A side-effect of this was that I stopped trying to be "smart" and just wrote solid, plain, easy to read code

There's a principle that states that debugging is harder than writing code, so if you write the "smart"est possible code, by definition you aren't smart enough to debug it :)

176

u/dreucifer Apr 09 '14

"Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?" -- Brian Kernighan The Elements of Programming Style

→ More replies (1)

36

u/none_shall_pass Apr 09 '14

That works.

I've always thought that complex code was the result of poor understanding of the problem or bad design.

73

u/BigRedRobotNinja Apr 09 '14

Complication is what happens when we "solve" a problem that we don't understand.

0

u/[deleted] Apr 09 '14

[deleted] — view deleted comment

18

u/thermite451 Apr 09 '14

GET OUT OF MY HEAD. I got 2hrs down that road one day before I realized I was being TRULY stupid.

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

30

u/ericanderton Apr 09 '14

We had this discussion at work. Halfway through, the following phrase lept from my mouth:

Because no good thing ever came from the thought: "Hey, I bet we can write a better memory management scheme than the one we've been using for decades."

38

u/wwqlcw Apr 09 '14

Years ago I was maintaining a system that had its roots in the DOS days. Real-mode, segmented addressing.

My predecessor had some genuine difficulties with real mode, there were structures he wanted to keep in RAM that were too big for the segments. That was a genuine issue for many systems at the time.

The easiest solution would have been to be a little more flexible about his memory structures. Another choice might have been to license a commercial memory extender. He opted to instead roll his own version of malloc.

I would not consider myself to be qualified to undertake such a project, but he was if anything less qualified.

I only discovered all of this at the end of an 11 hour debugging session. The reason my memory was becoming corrupt was because of bugs in the allocator itself. By the time I was working on this project, the compiler had better support for large memory structures, and I was able to fix it by deleting his malloc and twiddling some compiler flags.

Lo and behold, a zillion other bugs went away. And the whole system got faster, too.

The trouble is, if you're not cautious enough to be given pause by the notion of implementing memory management yourself, you're almost certainly the kind of person who needs that pause the most.

→ More replies (3)
→ More replies (3)
→ More replies (9)

163

u/emergent_properties Apr 09 '14

But remember The Linux Backdoor Attempt of 2003

A malicious bug can hide in 1 line of code in plain sight.

Looking complex is not even necessary.

77

u/zjm555 Apr 09 '14

I do indeed remember that :) This is why some teams rigidly enforce, as a coding style rule, that comparisons against literals always have the literal on the left-hand side.

67

u/[deleted] Apr 09 '14

54

u/DarkNeutron Apr 09 '14

Several bugs have I written that this would catch...

42

u/tequila13 Apr 09 '14

As someone who had to maintain Yoda-style code, that's not funny.

43

u/GratefulTony Apr 09 '14

funny: it is not.

→ More replies (10)
→ More replies (1)

45

u/syncsynchalt Apr 09 '14

I prefer to trust the compiler's warnings on this one. I've had to maintain yoda code and it's terrible to read.

→ More replies (14)

27

u/IICVX Apr 09 '14 edited Apr 09 '14

Unfortunately some people try to enforce that sort of thing in languages that aren't C and C++, where you'll actually get type errors because you're trying to put an integer or something where a boolean should go.

Edit: though to be fair, you do see that sort of thing in Java with the whole CONSTANT.equals(variable) thing, but that's just due to Java's handling of the billion dollar mistake.

→ More replies (3)
→ More replies (10)
→ More replies (25)

26

u/CheezyBob Apr 09 '14

I wish more of my co-workers thought like you. As a programmer, our job should be to manage and reduce complexity whenever possible. Software gets complex plenty fast without adding extra complexity just because it was fun, made you feel smart or was more "optimized".

→ More replies (1)
→ More replies (10)

58

u/emergent_properties Apr 09 '14

Nothing here implied intent.. but it also didn't discount it either.

Normally, I would say "Do not ascribe to malice to what could be incompetence." HOWEVER considering that this is probably one of THE most relied on packages.. and this is such a FAR REACHING BUG.. the author better have a damn good explanation.

It is speculation, but the converse is also true "Sufficiently advanced malice can be mistaken as incompetence."

What is the audit process? What is the proper discovery and reporting mechanisms of the people who developed OpenSSL?

16

u/amvakar Apr 09 '14

Normally I'd think like you, but OpenSSL is no stranger to no auditing. We had the Debian entropy clusterfuck, where downstream patches were never tested by anybody for years. And then we had the recent failure to implement the Dual EC DRBG algorithm,which was positive in this case for breaking a potential backdoor , but not encouraging considering it means that there are portions of the codebase that nobody has ever used in the history of the project floating around just waiting to break something important. And now this. The incompetence is simply too far reaching to allow a conclusion of malice. I refuse to believe that a good attacker infiltrating the project could not do better.

11

u/jsprogrammer Apr 09 '14

Better than two years of complete, undetectable access?

→ More replies (1)
→ More replies (1)
→ More replies (52)
→ More replies (4)