Endless Censorship Demands from Brazil

2024-04-0822:5590113www.hezmatt.org

Posted: Tue, 9 April 2024 | permalink | 2 Comments Those of you who haven’t been in IT for far, far too long might not know that next month will be the 16th(!) anniversary of the disclosure of what…

Posted: Tue, 9 April 2024 | permalink | 2 Comments

Those of you who haven’t been in IT for far, far too long might not know that next month will be the 16th(!) anniversary of the disclosure of what was, at the time, a fairly earth-shattering revelation: that for about 18 months, the Debian OpenSSL package was generating entirely predictable private keys.

The recent xz-stential threat (thanks to @nixCraft for making me aware of that one), has got me thinking about my own serendipitous interaction with a major vulnerability. Given that the statute of limitations has (probably) run out, I thought I’d share it as a tale of how “huh, that’s weird” can be a powerful threat-hunting tool – but only if you’ve got the time to keep pulling at the thread.

Prelude to an Adventure

Our story begins back in March 2008. I was working at Engine Yard (EY), a now largely-forgotten Rails-focused hosting company, which pioneered several advances in Rails application deployment. Probably EY’s greatest claim to lasting fame is that they helped launch a little code hosting platform you might have heard of, by providing them free infrastructure when they were little more than a glimmer in the Internet’s eye.

I am, of course, talking about everyone’s favourite Microsoft product: GitHub.

Since GitHub was in the right place, at the right time, with a compelling product offering, they quickly started to gain traction, and grow their userbase. With growth comes challenges, amongst them the one we’re focusing on today: SSH login times. Then, as now, GitHub provided SSH access to the git repos they hosted, by SSHing to git@github.com with publickey authentication. They were using the standard way that everyone manages SSH keys: the ~/.ssh/authorized_keys file, and that became a problem as the number of keys started to grow.

The way that SSH uses this file is that, when a user connects and asks for publickey authentication, SSH opens the ~/.ssh/authorized_keys file and scans all of the keys listed in it, looking for a key which matches the key that the user presented. This linear search is normally not a huge problem, because nobody in their right mind puts more than a few keys in their ~/.ssh/authorized_keys, right?

2008-era GitHub giving monkey puppet side-eye to the idea that nobody stores many keys in an authorized_keys file

Of course, as a popular, rapidly-growing service, GitHub was gaining users at a fair clip, to the point that the one big file that stored all the SSH keys was starting to visibly impact SSH login times. This problem was also not going to get any better by itself. Something Had To Be Done.

EY management was keen on making sure GitHub ran well, and so despite it not really being a hosting problem, they were willing to help fix this problem. For some reason, the late, great, Ezra Zygmuntowitz pointed GitHub in my direction, and let me take the time to really get into the problem with the GitHub team. After examining a variety of different possible solutions, we came to the conclusion that the least-worst option was to patch OpenSSH to lookup keys in a MySQL database, indexed on the key fingerprint.

We didn’t take this decision on a whim – it wasn’t a case of “yeah, sure, let’s just hack around with OpenSSH, what could possibly go wrong?”. We knew it was potentially catastrophic if things went sideways, so you can imagine how much worse the other options available were. Ensuring that this wouldn’t compromise security was a lot of the effort that went into the change. In the end, though, we rolled it out in early April, and lo! SSH logins were fast, and we were pretty sure we wouldn’t have to worry about this problem for a long time to come.

Normally, you’d think “patching OpenSSH to make mass SSH logins super fast” would be a good story on its own. But no, this is just the opening scene.

Chekov’s Gun Makes its Appearance

Fast forward a little under a month, to the first few days of May 2008. I get a message from one of the GitHub team, saying that somehow users were able to access other users’ repos over SSH. Naturally, as we’d recently rolled out the OpenSSH patch, which touched this very thing, the code I’d written was suspect number one, so I was called in to help.

The lineup scene from the movie The Usual Suspects
They're called The Usual Suspects for a reason, but sometimes, it really is Keyser Söze

Eventually, after more than a little debugging, we discovered that, somehow, there were two users with keys that had the same key fingerprint. This absolutely shouldn’t happen – it’s a bit like winning the lottery twice in a row1 – unless the users had somehow shared their keys with each other, of course. Still, it was worth investigating, just in case it was a web application bug, so the GitHub team reached out to the users impacted, to try and figure out what was going on.

The users professed no knowledge of each other, neither admitted to publicising their key, and couldn’t offer any explanation as to how the other person could possibly have gotten their key.

Then things went from “weird” to “what the…?”. Because another pair of users showed up, sharing a key fingerprint – but it was a different shared key fingerprint. The odds now have gone from “winning the lottery multiple times in a row” to as close to “this literally cannot happen” as makes no difference.

Milhouse from The Simpsons says that We're Through The Looking Glass Here, People

Once we were really, really confident that the OpenSSH patch wasn’t the cause of the problem, my involvement in the problem basically ended. I wasn’t a GitHub employee, and EY had plenty of other customers who needed my help, so I wasn’t able to stay deeply involved in the on-going investigation of The Mystery of the Duplicate Keys.

However, the GitHub team did keep talking to the users involved, and managed to determine the only apparent common factor was that all the users claimed to be using Debian or Ubuntu systems, which was where their SSH keys would have been generated.

That was as far as the investigation had really gotten, when along came May 13, 2008.

Chekov’s Gun Goes Off

With the publication of DSA-1571-1, everything suddenly became clear. Through a well-meaning but ultimately disasterous cleanup of OpenSSL’s randomness generation code, the Debian maintainer had inadvertently reduced the number of possible keys that could be generated by a given user from “bazillions” to a little over 32,000. With so many people signing up to GitHub – some of them no doubt following best practice and freshly generating a separate key – it’s unsurprising that some collisions occurred.

You can imagine the sense of “oooooooh, so that’s what’s going on!” that rippled out once the issue was understood. I was mostly glad that we had conclusive evidence that my OpenSSH patch wasn’t at fault, little knowing how much more contact I was to have with Debian weak keys in the future, running a huge store of known-compromised keys and using them to find misbehaving Certificate Authorities, amongst other things.

Lessons Learned

While I’ve not found a description of exactly when and how Luciano Bello discovered the vulnerability that became CVE-2008-0166, I presume he first came across it some time before it was disclosed – likely before GitHub tripped over it. The stable Debian release that included the vulnerable code had been released a year earlier, so there was plenty of time for Luciano to have discovered key collisions and go “hmm, I wonder what’s going on here?”, then keep digging until the solution presented itself.

The thought “hmm, that’s odd”, followed by intense investigation, leading to the discovery of a major flaw is also what ultimately brought down the recent XZ backdoor. The critical part of that sequence is the ability to do that intense investigation, though.

When I reflect on my brush with the Debian weak keys vulnerability, what sticks out to me is the fact that I didn’t do the deep investigation. I wonder if Luciano hadn’t found it, how long it might have been before it was found. The GitHub team would have continued investigating, presumably, and perhaps they (or I) would have eventually dug deep enough to find it. But we were all super busy – myself, working support tickets at EY, and GitHub feverishly building features and fighting the fires in their rapidly-growing service.

As it was, Luciano was able to take the time to dig in and find out what was happening, but just like the XZ backdoor, I feel like we, as an industry, got a bit lucky that someone with the skills, time, and energy was on hand at the right time to make a huge difference.

It’s a luxury to be able to take the time to really dig into a problem, and it’s a luxury that most of us rarely have. Perhaps an understated takeaway is that somehow we all need to wrestle back some time to follow our hunches and really dig into the things that make us go “hmm…”.

Support My Hunches

If you’d like to help me be able to do intense investigations of mysterious software phenomena, you can shout me a refreshing beverage on ko-fi.


Read the original article

Comments

  • By justinclift 2024-04-0823:092 reply

    Mirror: https://twiiit.com/ggreenwald/status/1777392222851240334

    That bounces to a random Nitter instance (there are a few still working), to show the subsequent posts and replies.

    The next post in the series (it comes from ggreenwald as well) also seems relevant:

        Last year, we received one of the censorship orders sent by Moraes. This was *after*
        the 2022 election and thus after these powers expired.
    
        You can see: they are done with no notice to those banned, and with a requirement
        that the order be kept secret:
    
    https://nitter.privacydev.net/pic/orig/media%2FFmaDDYxWYAY9k...

    https://nitter.privacydev.net/pic/orig/media%2FFmaDE0BWAAEBe...

    https://nitter.privacydev.net/pic/orig/media%2FFmaDGF7XkAECc...

    https://nitter.privacydev.net/pic/orig/media%2FFmaDG1VXgAAJ2...

    • By thiagoharry 2024-04-0919:171 reply

      Brazilian law allows content to be removed online for reasons of investigation, hate speech or unbased defamation. And this was always the case. Moreover, recent laws tried to control the amount of fake news trying to manipulate the elections. The Brazilian electoral laws forbid spending in secret for the purpose of buying or making propaganda for electoral campaign and also regulate what is allowed in the elections. Before the new laws, manipulating social media with lots of fake accounts spreading fake news was a loophole that was being explored by the far right. What they are calling "censorship" is just the application of law.

      • By lobocinza 2024-04-0922:301 reply

        > Before the new laws, manipulating social media with lots of fake accounts spreading fake news was a loophole that was being explored by the far right.

        The left also does that. Their goals is to monopolize and not combat fake news.

        • By vitorgrs 2024-04-100:412 reply

          Yes, and the left already got banned from TV ads when that happened during the election.

          In my state, former Governor and candidate Requião (PT, left) said that the current governor (Ratinho Jr, PSD, Right-wing) didn't give give teachers a salary increase.

          It was a lie.

          He was banned from TV ads for almost two weeks because he lied.

          • By matheusmoreira 2024-04-125:141 reply

            That's also censorship. He should not be silenced just because he lied. People should recognize him as a liar and stop trusting what he says instead.

            • By thiagoharry 2024-04-1314:531 reply

              That's not how our laws work...

              • By matheusmoreira 2024-04-1413:50

                Yes?

                Our laws work by enabling censorship. I recognized that, and said that they should not work that way.

                Saying wrong things should just hurt your reputation. As in, you become known for being wrong. It should not lead to the fucking government knocking on your door.

          • By lobocinza 2024-04-1012:511 reply

            I couldn't find any news regarding this ban. Even if true it looks like an exception rather than the rule.

            What makes Ratinho Jr right-wing? PSD is the the "Social Democractic" Party, it's center and aligned to whoever is in power.

  • By joegibbs 2024-04-0823:276 reply

    Do we need to rethink the idea of global social media platforms? Maybe even the idea of a global internet. If countries like Brazil or India want to have everything censored then perhaps western companies should simply withdraw their main platform and create some subsidiary application solely for people within each of those countries.

    • By andrenth 2024-04-091:591 reply

      “Countries” do not want censorship. Corrupt bureaucrats in power do.

      • By Ekaros 2024-04-095:222 reply

        Essentially corrupt bureaucrats are the countries. They might have to occasionally follow whims of elected representatives, which the populous is forced to vote and select from small pool.

        • By andrenth 2024-04-096:45

          I think putting it that way could lead someone to believe a country’s population agrees with the actions of the managerial elite. But yes, I agree with the essence of the idea, though I think it’s clearer to say they own or run the country.

        • By matheusmoreira 2024-04-0915:431 reply

          No, they're not. These judges do not represent me. I did not vote for them at all. Actually not a single person did.

          • By lobocinza 2024-04-1013:001 reply

            They are. Brazil isn't a democracy. There is a non-elected elite with absolute power. They can indict, investigate, prosecute and condemn anyone at their whim. Elected representatives aren't immune (e.g. Deltan Dallagnol, Sergio Moro). They can nullify and change laws made by elected representatives. They can create new laws out of thin air. They can uncondemn criminals.

            • By matheusmoreira 2024-04-112:261 reply

              I know, and I agree. I just consider it completely illegitimate. If anyone attempted a coup in Brazil, it was the supreme court. Looks like they succeeded too, unlike Bolsonaro and his clumsy flirtations with the topic.

              • By lobocinza 2024-04-113:361 reply

                Yes and Bolsonaro flirtations are theatrical. He and his sons are always the firsts to dose water on the fire when things get close to reaching a critical mass. They sabotaged the opening of a parliamentary investigation of the supreme court (CPI da Lava-Toga).

                e.g. https://youtu.be/jivOclOWSVY?si=TRiw6yBaTYRh94n9&t=84

                To foreigners: you don't understand how powerful the Brazilian supreme court is and how flawed our short-lived constitution is. Due to "foro privilegiado" they are the ones who judge politicians for their crimes and ensure that only the few who fell out of favor get condemned. As pretty much every politician is involved in some sort of wrongdoing, the supreme court pretty much owns everybody. Bolsonaro is no exception and his anti-democratic show is the only thing providing a simulacrum of legitimacy to the authoritarian acts of the supreme court.

                • By matheusmoreira 2024-04-125:21

                  > He and his sons are always the firsts to dose water on the fire when things get close to reaching a critical mass.

                  That's why I no longer have any respect for him at all. He's a coward with no balls, no convictions and no vision. It's hilarious to me how he's being treated like some ruthless dictator. If only he had been one. He's being treated like Hitler anyway, might as well have tried it just to see what happens. Too cowardly to even do that.

    • By helpfulclippy 2024-04-092:00

      For my money, I think the way this works out is that the idea of global social media conglomerates also falls apart. I think instead of subsidiaries of mostly US companies, governments will prefer to have the social media platform and its officers entirely subject to their jurisdiction with no option of leaving, or have it directly operated by the state, or not have it at all.

    • By HeatrayEnjoyer 2024-04-0917:42

      The US has pressured the rest of the world to censor anything it considers to be copyright infringement and enforce its draconian domestic copyright laws.

    • By rileymat2 2024-04-091:25

      This is a very complicated issue, because enabling some censorship is harmful in itself.

    • By Ekaros 2024-04-095:29

      I could see setup where there is local wholly independent companies that simply buy IP from some original company, maybe federate allowed content. These would then live on their own domains and be fully controlled by states they are in.

    • By alephknoll 2024-04-092:322 reply

      > Do we need to rethink the idea of global social media platforms? Maybe even the idea of a global internet.

      Yes.

      > If countries like Brazil or India want to have everything censored

      They aren't even the worst. The biggest advocates of censorship on american social media is europe, canada, israel, etc.

      > create some subsidiary application solely for people within each of those countries

      Or maybe brazil or india should outright ban these platforms and create their own? These countries have their own national tv stations, newspapers, etc? Why don't they have their own twitter, facebook, etc?

      If media essentially controls who you vote for, shouldn't india, brazil and every democracy control their own media? Seems to me that a foreign nation controlling so much of your social media is a direct threat to your democracy.

      Besides, if we continue on this path of global social media, we would have to censor everything everyone finds offensive. It would be the tyranny of the offended. The worst kind of tyranny.

      • By rajishx 2024-04-096:491 reply

        > They aren't even the worst. The biggest advocates of censorship on american social media is europe, canada, israel, etc.

        any sources on this ? and for most things you are mentioning in your post ?

        • By AlexeyBelov 2024-04-116:11

          You're replying to a throwaway troll account. You won't get any sources.

      • By lobocinza 2024-04-1013:11

        Because most state controlled/sponsored media are filled with incompetency, hugely impopular and prone to follow the official narrative.

        The idea of fragmenting the Internet into country level information silos controlled by each state is authoritarian and stupid.

        It is a good thing to be able to talk to anyone regardless of border, to be able to express yourself freely, to have open access information.

  • By illusive4080 2024-04-0823:08

    2 hours, no reason given, order of confidentiality? Straight up abuse of power.

HackerNews