News for hackers. Stuff that matters.
Re:Why CVE-2022-3602 was not detected by fuzz testing by jeffbee on Monday November 21, 2022 @11:09AM (#33694118)
tl;dr: because ossl_a2ulabel had no unit tests until a few days ago, the fuzzer could not have reached it through any combination of other tests.

That fuzzing is tricky was not the problem here. The problem is the culture that allowed ossl_a2ulabel to exist without unit tests. And before some weird nerd jumps in to say that openssl is so old we can't apply modern standards of project health, please note that the vulnerable function was committed from scratch in August 2020. Without unit tests.

Re:Why CVE-2022-3602 was not detected by fuzz testing by adql on Monday November 21, 2022 @11:41AM (#33694567)
Seems OpenSSL as an organization is just irreparably broken if they haven't still learned the lesson
Re:Why CVE-2022-3602 was not detected by fuzz testing by Someone1234 on Monday November 21, 2022 @11:56AM (#33694789)
OpenSSL still receives minimum funding. Until Heartbleed they had nearly no funding, and now it is two full time people.

https://en.wikipedia.org/wiki/Core_Infrastructure_Initiative...

Re:Why CVE-2022-3602 was not detected by fuzz testing by pizza234 on Monday November 21, 2022 @12:14PM (#33695045)
I'm of the opinion that in cases like this, it'd be better for the organization to close, and allow the gap to be filled naturaly.

If the current OpenSSL maintainers closed the project, given its importance, there would be a rush to follow up maintenance. Chances are, it'd be better funded; even in worst case, it'll hardly be assigned less than two devs.

This a case of the general dynamic where a barely-sufficient-but-arguably-insufficient solution prevents actors from finding and executing a proper one.

Re:Why CVE-2022-3602 was not detected by fuzz testing by SoftTalker on Monday November 21, 2022 @03:05PM (#33697220)
For a project like OpenSSL, it's not just having "enough" developers (whatever that is) it's having qualified developers. Writing good crypto code requires deep expertise. There aren't a lot of people with such expertise whose time is not already fully committed.
Re:Why CVE-2022-3602 was not detected by fuzz testing by AdamJacobMuller on Monday November 21, 2022 @03:06PM (#33697231)
You don't even have to close. You can just refuse to merge code which does not include 100% test coverage. If someone wants the feature badly enough, they will figure out a way to fill the gap. Alternatively, someone can always fork the code and release "OpenSSL-but-with-lots-of-untested-code" variant.
Re:Why CVE-2022-3602 was not detected by fuzz testing by coder543 on Monday November 21, 2022 @12:15PM (#33695054)
I think at this point we've established that it's C which is just irreparably broken.

Blaming the OpenSSL developers for writing bad C is just a "no true scotsman" at this point, since there is no large, popular C codebase in existence that I'm aware of that avoids running into vulnerabilities like this; vulnerabilities that just about every other language (mainly excluding C++) would have prevented from becoming an RCE, and likely prevented from even being a DoS. Memory safe languages obviously can't prevent all vulnerabilities, since the developer can still intentionally or unintentionally write code that simply does the wrong thing, but memory safe languages can prevent a lot of dumb vulnerabilities, including this one.

No feasible amount of funding would have prevented this, since it continues to happen to much better funded projects also written in C.

On the other hand, I guess we could blame the OpenSSL developers for writing C at all, being unwilling to start writing new code in a memory safe language of some kind, and ideally rewriting particularly risks code paths like parsers as well. We've learned this lesson the hard way a thousand times. C isn't going away any time soon (unfortunately), but that doesn't mean we have to continue writing new vulnerabilities like this one, which was written in the last two years.

Re:Why CVE-2022-3602 was not detected by fuzz testing by jabart on Monday November 21, 2022 @12:29PM (#33695258)
Keep in mind that Ubuntu compiled OpenSSL using a gcc flag that turns this one byte overflow into a crash instead of a memory leak/corrpution because it has a way to do that already. It's very risky, and a very long term project to rewrite something with this level of history into a completely new language.
Re:Why CVE-2022-3602 was not detected by fuzz testing by coder543 on Monday November 21, 2022 @12:33PM (#33695332)
> It's very risky, and a very long term project to rewrite something with this level of history into a completely new language.

I did not suggest a complete rewrite of the project. However, they could choose to only write new code in something else, and they could rewrite certain critical paths too. The bulk of the code would continue to be a liability written in C.

I agree that it would be nearly impossible to rewrite OpenSSL as-is. It would take huge amounts of funding and time. In general, people with that much funding are probably better off starting from scratch and focusing on only the most commonly used functionality, as well as designing the public interface to be more ergonomic / harder to misuse.

Re:Why CVE-2022-3602 was not detected by fuzz testing by tredre3 on Monday November 21, 2022 @02:29PM (#33696778)
> Blaming the OpenSSL developers for writing bad C is just a "no true scotsman" at this point, since there is no large, popular C codebase in existence that I'm aware of that avoids running into vulnerabilities like this; vulnerabilities that just about every other language (mainly excluding C++) would have prevented from becoming an RCE

No, this whole thing is about the lack of testing. Adding a parser without matching tests is just absurd regardless of the language it's implemented with. If only for basic correctness check, you want a test.

Not all vulnerabilities or bugs are memory-related, vulnerabilities are bound to surface in any language with that kind of organizational culture.

Re:Why CVE-2022-3602 was not detected by fuzz testing by klqwr on Monday November 21, 2022 @06:54PM (#33699913)
qmail in 32-bit mode (which was the default when it was written) had no issues. One issue was found in 64-bit mode without memory limits (against the explicit recommendation).

Most "safe" languages like Python are written in C and are full of segfaults, mostly due to the high churn rate and the attitude of the developers.

I haven't tried Rust yet, so I won't comment on that.

Re:Why CVE-2022-3602 was not detected by fuzz testing by cryptonector on Monday November 21, 2022 @03:08PM (#33697250)
The OpenSSL team is actually very good and they do very good work, and they even have funding. The problem is that legacy never goes away, and OpenSSL is a huge pile of legacy code, and it will take a long long time to a) fix all the issues (e.g., code coverage), b) migrate OpenSSL to not-C or the industry to not-OpenSSL.
Re:Why CVE-2022-3602 was not detected by fuzz testing by cjbprime on Tuesday November 22, 2022 @12:45AM (#33702473)
This vulnerable parser of attacker-controlled remote input was written from scratch in C in 2020, without a fuzz harness even though OpenSSL is critical infrastructure and is already hooked up to oss-fuzz.

It is simply difficult to reconcile these facts with the idea that it is a very good team doing very good work.

Re:Why CVE-2022-3602 was not detected by fuzz testing by MuffinFlavored on Monday November 21, 2022 @11:15AM (#33694215)
> because ossl_a2ulabel had no unit tests until a few days ago

it's not realistic to enforce unit test coverage % with a project at the scale of OpenSSL, right?

Re:Why CVE-2022-3602 was not detected by fuzz testing by masklinn on Monday November 21, 2022 @11:26AM (#33694360)
> it's not realistic to enforce unit test coverage % with a project at the scale of OpenSSL, right?

Why not?

You can enforce that all new files should be covered (at the very least line-covered). It requires some setup effort (collecting code coverage and either sending it to a tool which perform the correlation or correlating yourself), but once that's done... it does its thing.

Then you can work on increasing coverage for existing files, and ratcheting requirements.

Re:Why CVE-2022-3602 was not detected by fuzz testing by duped on Monday November 21, 2022 @11:30AM (#33694426)
It's realistic to reject a CR for a new parsing function without proof that it works, which usually comes in the form of a unit test
Re:Why CVE-2022-3602 was not detected by fuzz testing by planede on Monday November 21, 2022 @11:34AM (#33694470)
Nit: a unit test never proves that it works. At best it can prove that it doesn't work.

Otherwise, I agree.

Re:Why CVE-2022-3602 was not detected by fuzz testing by hardware2win on Monday November 21, 2022 @11:54AM (#33694767)
Nit: "never"? Even if you unit test all cases?
Re:Why CVE-2022-3602 was not detected by fuzz testing by tz18 on Monday November 21, 2022 @12:08PM (#33694958)
Yes, never. You are assuming that the implementation of all unit test cases are themselves correct (that they would fail if there was any error in the case they cover). In fact unit tests are often wrong. In that context a unit test can't even prove code incorrect, unless we know that the unit test is correct.

IMO to prove that code is correct requires a proof; a unit test can only provide evidence suggestive of correctness.

Re:Why CVE-2022-3602 was not detected by fuzz testing by planede on Monday November 21, 2022 @12:21PM (#33695152)
Mistakes in proofs are just as probable as mistakes in exhaustive tests.

An exhaustive test is just one type of a machine verified proof.

Re:Why CVE-2022-3602 was not detected by fuzz testing by nicoburns on Monday November 21, 2022 @01:48PM (#33696289)
> An exhaustive test is just one type of a machine verified proof.

Not entirely sure I agree with this. A proof by construction is a very different beast to empirical unit tests that only cover a subset of inputs. The equivalent would be units tests that cover every single possible input.

Re:Why CVE-2022-3602 was not detected by fuzz testing by planede on Tuesday November 22, 2022 @03:57AM (#33703600)
> The equivalent would be units tests that cover every single possible input.

That's what "exhaustive" means.

Re:Why CVE-2022-3602 was not detected by fuzz testing by planede on Monday November 21, 2022 @12:19PM (#33695113)
Touché
Re:Why CVE-2022-3602 was not detected by fuzz testing by bluGill on Monday November 21, 2022 @04:59PM (#33698635)
How do you know you covered all cases. You can verify you cover all cases the code handles easily enough. However does the code actually handle all the cases that could exist? A formal proof can bring to your attention a case that you didn't handle at all.

Formal proofs also have limits. Donald Knuth once famously wrote "beware of bugs in the above code, I proved it correct but never ran it". Which is why I think we should write tests for code as well as formally prove it. (On the later I've never figured out how to prove my code - writing C++ I'm not sure if it is possible but I'd like to)

Re:Why CVE-2022-3602 was not detected by fuzz testing by planede on Tuesday November 22, 2022 @03:59AM (#33703606)
There are limited cases where this is possible. Like a pure function that takes a single 32bit number as input. Just go over all the possible inputs.
Re:Why CVE-2022-3602 was not detected by fuzz testing by bluGill on Tuesday November 22, 2022 @08:48AM (#33705710)
You can't as a verify all the outputs though, only that it doesn't crash, which isn't useful for detecting edge cases where the results are wrong but don't crash. And that is a single pure function, if that pure function with a wrong output is then fed into/used by some other function (a non-pure data storage in particular - a large part of what computers are used for is storage of some form, not pure functions) you can read off the end of the buffer or other bad things.

Even running through all 4 billion some cases a single 32 bit number can result in your test taking a significant amount of time - enough that you wouldn't want to run it very often. One value of real world tests is often that they can detect that you broke what you thought was a completely unrelated area of code.

Re:Why CVE-2022-3602 was not detected by fuzz testing by hardware2win on Tuesday November 22, 2022 @02:52PM (#33710476)
Seriously? It is pretty easy to imagine function which has limited and low combinations count

Enums, bools, etc.

>can result in your test taking a significant amount of time - enough that you wouldn't want to run it very often.

It is irrelevant in theoretical discussions like this

Re:Why CVE-2022-3602 was not detected by fuzz testing by asveikau on Monday November 21, 2022 @11:31AM (#33694433)
It's worth noting that coverage can be a deceptive metric sometimes.

You can have coverage on code that divides - it won't tell you if you ever divide by zero.

You can have coverage on code that follows a pointer - it won't tell you if you ever pass a bad pointer.

Re:Why CVE-2022-3602 was not detected by fuzz testing by adql on Monday November 21, 2022 @11:40AM (#33694548)
yeah but there isn't even a try here
Re:Why CVE-2022-3602 was not detected by fuzz testing by asveikau on Monday November 21, 2022 @12:55PM (#33695603)
Not saying it isn't worth an attempt, just that the real meaning shouldn't be lost.
Re:Why CVE-2022-3602 was not detected by fuzz testing by pca006132 on Monday November 21, 2022 @11:20AM (#33694261)
It should be realistic, line coverage isn't really that hard. The hard thing is that high line coverage alone is usually not enough for numerical stuff...
Re:Why CVE-2022-3602 was not detected by fuzz testing by stefan_ on Monday November 21, 2022 @11:27AM (#33694365)
No one is asking for that. But this is code that did one thing: punycode decoding, with millions of well documented test vectors. The code had zero dependencies on anything OpenSSL related. It is a very simple "text in, text out" problem, the most trivial thing to write unit tests for. At the same time, it's code that parses externally provided buffers and has to deal with things like unicode in C - there should be a massive red flashing warning light in every developers head here.
Re:Why CVE-2022-3602 was not detected by fuzz testing by jeffbee on Monday November 21, 2022 @11:22AM (#33694294)
It is trivial to enforce that new functions have new unit tests and fuzz tests. You are the reviewer of https://github.com/openssl/openssl/pull/9654 and you just say "Please add unit tests and fuzz tests for foo and bar" and you don't approve it.

I don't know what the deal is with their testing culture but in year 27 of the project they demonstrably haven't learned this lesson. It's nice that they added integration tests (testing given encoded certs) but as the article points out that was insufficient.

Re:Why CVE-2022-3602 was not detected by fuzz testing by dralley on Monday November 21, 2022 @11:44AM (#33694622)
IMO, one of the biggest benefits of "modern" systems languages like Rust, D, Zig is how much easier they make writing and running tests compared to C and C++. Yes, you can write tests for those languages, but it's nowhere near as trivial. And that makes a difference.
Re:Why CVE-2022-3602 was not detected by fuzz testing by pjmlp on Monday November 21, 2022 @12:31PM (#33695284)
I was writing unit tests for C in 1996, naturally we still haven't coined the term, so we just called them automatic tests.

It was part of our data structures and algorithms project, failure to execute the automatic tests meant no admission to the final exam.

We had three sets of tests, those provided initially at the begin of the term, those that we were expected to write ourselves, and a surprise set on the integration week at the end of the semester.

Re:Why CVE-2022-3602 was not detected by fuzz testing by fisf on Monday November 21, 2022 @12:07PM (#33694945)
I am not buying it.

Writing unit tests for c/c++ is trivial. There are perfectly fine test frameworks, used by developers every day, integrated in any major IDE or runnable as one-liner from the command line.

This is absolutely a cultural problem.

Re:Why CVE-2022-3602 was not detected by fuzz testing by edgyquant on Tuesday November 22, 2022 @12:43AM (#33702454)
In modern languages you either have built in testing or it’s a single package install away. It is nowhere near this simple with C or C++
Re:Why CVE-2022-3602 was not detected by fuzz testing by bluGill on Monday November 21, 2022 @05:03PM (#33698682)
Last week I code a "please add unit tests for this code". The person who wrote that comment wasn't aware that this was a refactoring where the functionality was well tested.

There is no substitute for reviewers who really understand the code in question. The problem is they are the ones writing the code and so are biased and not able to give a good review.