News for hackers. Stuff that matters.
[dead]
Re:Memcmp being wrongly stripped like strcmp by segfaultbuserr on Friday October 09, 2020 @01:12AM (#24727051)
The original secp256k1 developer Russell O’Connor who was hit by the bug (was on HN [0]) [1] said he rebuilt every package in his system after the bug was identified, and found only 10 lines of code that were miscompiled. Also, note that the bug was found during an attempt to add more test cases, pre-existing code in secp256k1 was not affected.

> Three lines are tests. All of the lines could be rewritten as a comparison to 0. None of the lines looked that serious. I am not sure which one is the worse: the reduced message integrity code(?) from some ARCFOUR implementation or the something something from an ATM driver?

Two unusual conditions are needed to trigger it...

> * at least one of the compared byte arrays is constant and has a zero byte in position 0, 1, 2, or 3, and

> * the result of the memcmp isn't immediately used in a "== 0" or "!= 0" test (or equivalently "if(memcmp(...))" or "if(!memcmp(...))").

> In particular the second condition makes this bug pretty rare and explains why it's mostly hit in non-inlined memcmp wrappers. (But in our case we hit it with a "<" comparison. )

Looks like a critical bug, but doesn't look like a conspiracy.

[0] https://news.ycombinator.com/item?id=24636326

[1] http://r6.ca/blog/20200929T023701Z.html

Re:Memcmp being wrongly stripped like strcmp by qwertox on Friday October 09, 2020 @05:50AM (#24728349)
For those interested, ATM doesn't refer to an automated teller machine, but to the UPD98401 high-performance Asynchronous Transfer Mode (ATM) controller.

https://www.digchip.com/datasheets/parts/datasheet/322/UPD98...

Re:Memcmp being wrongly stripped like strcmp by moonchild on Friday October 09, 2020 @01:52AM (#24727228)
Or, alternately, it's a conspiracy which is intended to have very tight coverage; it's very difficult to detect, if most code slips it by.
Re:Memcmp being wrongly stripped like strcmp by segfaultbuserr on Friday October 09, 2020 @02:24AM (#24727362)
> it's very difficult to detect, if most code slips it by.

What would be the point if it has missed nearly every target? Based on the field survey by Russell O’Connor, no major crypto project or server project has been affected. The only security victim is a RC4-HMAC implementation for Kerberos 5, which has very limited uses - for Windows 2000, and deprecated since a long time ago.

The only possible explanation would be either,

1. A long-term time bomb, intended to hit a big fish in the future, in a random, non-specific way.

2. Targeted attack (which doesn't make much sense, if you have enough exploitation capabilities to launch many types of targeted attacks already, why bother to leave a public record in GCC?).

Re:Memcmp being wrongly stripped like strcmp by moonchild on Friday October 09, 2020 @03:44AM (#24727742)
Sure. I don't think it's particularly likely to have been a conspiracy. Just speculating. If I were to try to put an illicit backdoor in a compiler, I would try and make damned sure it's not traceable to me.

It's a very subtle thing. You have to submit a patch with an improvement (or, at least, an apparent one) to the compiler, which also contains your backdoor. You have to ensure said patch doesn't immediately cause test failures in gcc, or in projects using gcc. If you can manage that, though, it'd be very difficult to prove that you were responsible, which is why I think the targeted attack is entirely plausible.

Re:Memcmp being wrongly stripped like strcmp by HourglassFR on Friday October 09, 2020 @04:48AM (#24728029)
> If you can manage that, though, it'd be very difficult to prove that you were responsible, which is why I think the targeted attack is entirely plausible.

So the only argument you have to suggest it might be an intentionally introduced bug is that it doesn't look like one… I understand the sentiment but this is clearly a ridiculous line of reasoning.

Re:Memcmp being wrongly stripped like strcmp by moonchild on Friday October 09, 2020 @04:40PM (#24734213)
The patch that introduced the bug is at [1]. Does it look to you like it introduced a bug? Granted, you're not a gcc developer—neither am I—but the gcc developers didn't think so either.

Bugs are accidentally introduced all the time, true. But I don't think it's fair to say that this is a ridiculous line of reasoning.

1. https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=14b7950f12...

Re:Memcmp being wrongly stripped like strcmp by nullc on Friday October 09, 2020 @01:37AM (#24727164)
There is no security concern about it in libsecp256k1: The compilation was only happening in a newly written test case and didn't impact the production code.

The miscompilation of the implementation of draft-brezak-win2k-krb-rc4-hmac-04.txt seemed interesting to me and potentially of a security concern. They looked to me like they were potentially significantly reducing the length of the message integrity check in an authentication protocol.

https://github.com/heimdal/heimdal/blob/7ae2dfd853c87f9cbecb...

https://github.com/heimdal/heimdal/blob/7ae2dfd853c87f9cbecb...

https://github.com/heimdal/heimdal/blob/7ae2dfd853c87f9cbecb...

Though its hard to say for sure without even a passing familiarity with that protocol or its implementation. If you wanted to go vulnerability hunting, however, that is where I'd start.

That said, even if there is a bug that is no evidence that it would have been intentional. Sadly, an intentionally introduced bug could be absurdly subtle. One of the downsides of software bugs being relatively common is that you can't be sure if a bug was intentional or not... and at the same time it's silly to assume one was intentional because we know that real bugs are so common.

It's long been my view that if you're not occasionally finding compiler bugs -- even in somewhat older compilers-- you're just not testing hard enough. They've become more rare but are not so rare that a single developer comprehensively testing a small library won't eventually find one (or more). (Libsecp256k1 is ~9,964 lines of code and ~8,235 lines of test code).

Many other cases found by Russell's system wide recompilation were also in test cases or were otherwise pretty obviously not that big of a deal.

Re:Memcmp being wrongly stripped like strcmp by segfaultbuserr on Friday October 09, 2020 @02:25AM (#24727371)
> The miscompilation of the implementation of draft-brezak-win2k-krb-rc4-hmac-04.txt seemed interesting to me and potentially of a security concern.

Fortunately, this ancient and deprecated [0] authentication protocol from Windows 2000 is uncommon today. AES-HMAC is used since Windows Vista.

[0] https://web.mit.edu/kerberos/krb5-devel/doc/admin/enctypes.h...

Re:Memcmp being wrongly stripped like strcmp by nullc on Friday October 09, 2020 @04:13AM (#24727880)
Re:Memcmp being wrongly stripped like strcmp by kstenerud on Friday October 09, 2020 @02:26AM (#24727377)
Everything smells fishy when you want it to be.
Re:Memcmp being wrongly stripped like strcmp by beowulfey on Friday October 09, 2020 @04:58AM (#24728064)
It was a fairly recent regression (this past March?) and based on developer comments in the source it really looks more like a mistake than anything. Personally I’m gonna go with Occam’s razor on this one.
Re:Memcmp being wrongly stripped like strcmp by rurban on Friday October 09, 2020 @02:11AM (#24727304)
Unlikely. We were hit by a series of similar string builtin related bugs in the tree optimizer since gcc 9.0. And the bugfest is still ongoing. The most likely explanation is an incompetent developer touching these areas.
Re:Memcmp being wrongly stripped like strcmp by segfaultbuserr on Friday October 09, 2020 @02:38AM (#24727420)
Not sure why has this comment been downvoted. It simply describes the bug in context ("there has been a series of similar string builtin related bugs in the tree optimizer since gcc 9.0") and offers a plausible explanation of the bug ("an incompetent developer touching these areas") based on Hanlon's Razor.

Even this is not welcomed on HN nowadays?

Re:Memcmp being wrongly stripped like strcmp by kbenson on Friday October 09, 2020 @03:02AM (#24727545)
rurban often gets flak for his method of communication, which is generally blunt. Whether from a language barrier or just how he communicates, I think people have a problem separating the message from the delivery, so that might be what's going on here.

I agree with his assessment that it's probably just someone's mistake. I also personally wouldn't have worded quite that way, even if technically correct (incompetent is fairly harsh wording in English). I don't think it's worth down voting over.

Re:Memcmp being wrongly stripped like strcmp by joosters on Friday October 09, 2020 @03:00AM (#24727528)
Perhaps because it is unfairly assuming incompetence? Everyone makes mistakes.
Re:Memcmp being wrongly stripped like strcmp by naniwaduni on Friday October 09, 2020 @03:04AM (#24727556)
It's attributing the error to incompetence instead of malice. It's not particularly unfair, it's providing an alternate explanation, if a bit bluntly.
Re:Memcmp being wrongly stripped like strcmp by rbanffy on Friday October 09, 2020 @03:21AM (#24727649)
Even the most competent among us makes mistakes from time to time. I make them almost daily.

Sometimes you just have a problem that's hard to wrap your head around and you think you found a way to make code faster that just isn't so.

Now the issue is better understood and we may end up with a couple good tests to prevent future regressions.

Re:Memcmp being wrongly stripped like strcmp by Dylan16807 on Friday October 09, 2020 @03:33AM (#24727699)
A bunch of mistakes all in the same area mean you're doing something wrong, moreso than "everyone makes mistakes". And if it's an accident, and not caused by someone overworking you, then it falls under the umbrella of "incompetence". That doesn't mean you're a failure in general, it means you weren't up to doing this particular work at this moment in your life.
Re:Memcmp being wrongly stripped like strcmp by Someone on Friday October 09, 2020 @03:55AM (#24727798)
Depends on how much work you did in that area, and even if the proportion of mistakes is high, it doesn’t necessarily imply incompetence. Could be a bad day.

Also, I would guess gcc does code reviews. If so, gcc seems to be full of incompetent programmers, making it a miracle that this thing can even compile hello world. I don’t think that’s the case.

Re:Memcmp being wrongly stripped like strcmp by Dylan16807 on Friday October 09, 2020 @04:17AM (#24727892)
If you had that bad of a day while being extremely "productive", and never double checked, then that falls under the umbrella of incompetence.

> If so, gcc seems to be full of incompetent programmers

Are you bristling at a word that looks like an insult and then ignoring what I'm actually saying? I specifically said you can be incompetent at a particular thing at a particular moment in time and that it is not a summary of you in general!

Re:Memcmp being wrongly stripped like strcmp by rbanffy on Friday October 09, 2020 @09:29AM (#24729698)
"Incompetent", in special if you use it without any further qualification, is not usually meant as "incompetent at a particular thing at a particular time".

I'd say that pretty much everyone is completely incompetent when it comes to correctly implement a complicated piece of software like GCC. OTOH, the people who develop GCC are incredibly competent at what they do because the compiler does insanely complicated things the vast majority of the human race would struggle to comprehend and, yet, its surprisingly correct, with the occasional bug and confusion here and there.

We all work at the limits of our wits. Right now I'm waiting for a timeout so I can continue to test a hypothesis. If I am lucky, I'll be right and the system will malfunction in the way I expect it to. I'd say my chances at this point are 50/50.

Re:Memcmp being wrongly stripped like strcmp by Dylan16807 on Friday October 09, 2020 @02:03PM (#24732614)
In the context of malice vs. incompetence, malice certainly doesn't refer to an innate quality you possess all the time, so why would the alternative mean that?

> with the occasional bug and confusion here and there

And the point of this thread was talking about a big batch of bugs, the opposite of "occasional".

Re:Memcmp being wrongly stripped like strcmp by shawnz on Friday October 09, 2020 @07:09AM (#24728736)
Maybe that area just has a high complexity, making mistakes there more likely?
Re:Memcmp being wrongly stripped like strcmp by joosters on Friday October 09, 2020 @03:29AM (#24727682)
It was declaring that the developer was incompetent. That's needlessly insulting to anyone. Making a mistake doesn't make you an incompetent person.
Re:Memcmp being wrongly stripped like strcmp by archgoon on Friday October 09, 2020 @03:45AM (#24727746)
Also, because it badly models how the error occurred in the first place. It wasn't any one developer who made a mistake, as a comment in the thread makes clear, it was a series of mistakes, made by different people, coupled with poor documentation that ultimately led to this.
Re:Memcmp being wrongly stripped like strcmp by segfaultbuserr on Friday October 09, 2020 @03:43AM (#24727738)
Fair enough.
Re:Memcmp being wrongly stripped like strcmp by Gibbon1 on Friday October 09, 2020 @05:24AM (#24728188)
Yes... but breaking similar things repeatedly.
Re:Memcmp being wrongly stripped like strcmp by rurban on Friday October 09, 2020 @11:38AM (#24730942)
Certainly not needless. The whole world relies on a new gcc release not to introduce new severe bugs in good code. Mistakes need to found and fixed before the release, but not 3 years after. Then the mistake becomes incompetence. I wish I would not need to sprinkle my code with

    #if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__) && \
       (((__GNUC__ == 9) && (__GNUC_MINOR__ <= 3) || \
        (__GNUC__ > 9)))
Also their arrogant attitude. Incompetence is rarely the only problem, it only gets problematic if paired with disfunctional management or arrogance.
Re:Memcmp being wrongly stripped like strcmp by inopinatus on Friday October 09, 2020 @05:49AM (#24728345)
Hanlon's razor isn't a binary device. It recommends a preference ordering of two well-known attributions, malice and stupidity, but does not close the door to the many other possible explanations for any given undesirable outcome.
Re:Memcmp being wrongly stripped like strcmp by FandangoRanger on Friday October 09, 2020 @12:24AM (#24726807)
Reflections on trusting trust?
Re:Memcmp being wrongly stripped like strcmp by mrtnmcc on Friday October 09, 2020 @12:39AM (#24726882)
OK my getting downvoted shouldn't be a surprise. But it sure seems suspicious that the author introducing the bug made commits that end with this bug - and then silence. https://gcc.gnu.org/git/?p=gcc.git;a=search;h=d01b568a78351b...

His name and hotmail email is associated in git with various cryptography projects including openssl.

Re:Memcmp being wrongly stripped like strcmp by pvg on Friday October 09, 2020 @02:16AM (#24727334)
Pepe Silvia, this name keeps comin' up over and over and over again. Every day Pepe's mail's getting sent back to me. Pepe Silvia, Pepe Silvia, I look in the mail, this whole box is Pepe Silvia! So I say to myself I gotta find this guy. I gotta go up to his office, I gotta put his mail in the guy's goddamn hands! Otherwise he's never gonna get it, it's gonna keep coming back down here. So I go up to Pepe's office and what do I find out, Mac, what do I find out? There is no Pepe Silvia. The man does not exist, okay? So I decided, ohh shit, buddy, I gotta dig a little deeper.
Re:Memcmp being wrongly stripped like strcmp by admax88q on Friday October 09, 2020 @12:42PM (#24731697)
Your search is broken, you are searching up to the specific commit.

Look now the history "ends" at a different commit: https://gcc.gnu.org/git/?p=gcc.git;a=search;h=5828c09abe00cc...

Re:Memcmp being wrongly stripped like strcmp by reader_mode on Friday October 09, 2020 @01:05AM (#24727014)
>But it sure seems suspicious that the author introducing the bug made commits for a few months that end with this bug

Your links shows commits 2016-2018

Re:Memcmp being wrongly stripped like strcmp by viraptor on Friday October 09, 2020 @01:10AM (#24727043)
Re:Memcmp being wrongly stripped like strcmp by tomku on Friday October 09, 2020 @01:13AM (#24727054)
Actually 2013-2018 if you click the "next" link hidden in the lower left corner.
Re:Memcmp being wrongly stripped like strcmp by xvector on Friday October 09, 2020 @01:03AM (#24726996)
Wow, nice find.
Re:Memcmp being wrongly stripped like strcmp by DarthGhandi on Friday October 09, 2020 @01:06AM (#24727023)
thought I'd heard that name before, he's quite active, no idea how you ended up with "silence"

https://www.theregister.com/2020/04/23/gcc_openssl_vulnerabi...

Re:Memcmp being wrongly stripped like strcmp by lwansbrough on Friday October 09, 2020 @12:55AM (#24726958)
That’s a very interesting discovery.
Re:Memcmp being wrongly stripped like strcmp by segfaultbuserr on Friday October 09, 2020 @01:17AM (#24727073)
And it's wrong, as the comment pointed out. Bernd Edlinger has been active since 2013, his most recent work was on GCC 10's static analyzer, which led to the discovery of an exploitable OpenSSL bug, and was seen in the press in April 2020 [0]. The initial bug report was posted on March, this can hardly be qualified as "going silent".

[0] https://www.theregister.com/2020/04/23/gcc_openssl_vulnerabi...

Re:Memcmp being wrongly stripped like strcmp by lwansbrough on Friday October 09, 2020 @01:11PM (#24732055)
Thanks for clarifying.
Re:Memcmp being wrongly stripped like strcmp by segfaultbuserr on Friday October 09, 2020 @02:47AM (#24727466)
> OK my getting downvoted shouldn't be a surprise

FandangoRanger made a comment, said it can be a backdoor. And rurban made a comment, said it's unlikely to be a backdoor. Both have been downvoted. I guess the hivemind is fair enough...

Re:Memcmp being wrongly stripped like strcmp by setr on Friday October 09, 2020 @03:10AM (#24727595)
A hivemind by definition does not conflict with itself. If both are being downvoted, that implies your hivemind does not exist, at least for this topic.
Re:Memcmp being wrongly stripped like strcmp by nurettin on Friday October 09, 2020 @04:16AM (#24727888)
The hivemind thinks that this qualifies as both conspiracy theory and nerd sniping and both sides of the argument should be abandoned.
Re:Memcmp being wrongly stripped like strcmp by jobigoud on Friday October 09, 2020 @03:20AM (#24727645)
A hive mind with internal conflict or cognitive issues makes for great scifi in Ann Leckie's "Ancillary Justice".
Re:Memcmp being wrongly stripped like strcmp by segfaultbuserr on Friday October 09, 2020 @03:18AM (#24727633)
> If both are being downvoted, that implies your hivemind does not exist, at least for this topic.

Not necessarily so. Perhaps the hivemind is not interpreting the question as a binary one. For example, the downvote for "Reflections on trusting trust?" can be result from the cliche fatigue.