• merthyr1831@lemmy.world
    link
    fedilink
    arrow-up
    127
    arrow-down
    1
    ·
    2 years ago

    I know this is being treated as a social engineering attack, but having unreadable binary blobs as part of your build/dev pipeline is fucking insane.

    • suy
      link
      fedilink
      arrow-up
      41
      arrow-down
      1
      ·
      2 years ago

      Is it, really? If the whole point of the library is dealing with binary files, how are you even going to have automated tests of the library?

      The scary thing is that there is people still using autotools, or any other hyper-complicated build system in which this is easy to hide because who the hell cares about learning about Makefiles, autoconf, automake, M4 and shell scripting at once to compile a few C files. I think hiding this in any other build system would have been definitely harder. Check this mess:

        dnl Define somedir_c_make.
        [$1]_c_make=`printf '%s\n' "$[$1]_c" | sed -e "$gl_sed_escape_for_make_1" -e "$gl_sed_escape_for_make_2" | tr -d "$gl_tr_cr"`
        dnl Use the substituted somedir variable, when possible, so that the user
        dnl may adjust somedir a posteriori when there are no special characters.
        if test "$[$1]_c_make" = '\"'"${gl_final_[$1]}"'\"'; then
          [$1]_c_make='\"$([$1])\"'
        fi
        if test "x$gl_am_configmake" != "x"; then
          gl_[$1]_config='sed \"r\n\" $gl_am_configmake | eval $gl_path_map | $gl_[$1]_prefix -d 2>/dev/null'
        else
          gl_[$1]_config=''
        fi
      
    • nxdefiant@startrek.website
      link
      fedilink
      arrow-up
      27
      arrow-down
      1
      ·
      2 years ago

      It’s not uncommon to keep example bad data around for regression to run against, and I imagine that’s not the only example in a compression library, but I’d definitely consider that a level of testing above unittests, and would not include it in the main repo. Tests that verify behavior at run time, either when interacting with the user, integrating with other software or services, or after being packaged, belong elsewhere. In summary, this is lazy.

      • inetknght@lemmy.ml
        link
        fedilink
        arrow-up
        18
        arrow-down
        1
        ·
        2 years ago

        and would not include it in the main repo

        Tests that verify behavior at run time belong elsewhere

        The test blobs belong in whatever repository they’re used.

        It’s comically dumb to think that a repository won’t include tests. So binary blobs like this absolutely do belong in the repository.

        • nxdefiant@startrek.website
          link
          fedilink
          arrow-up
          5
          arrow-down
          1
          ·
          edit-2
          2 years ago

          A repo dedicated to non-unit-test tests would be the best way to go. No need to pollute your main code repo with orders of magnitude more code and junk than the actual application.

          That said, from what I understand of the exploit, it could have been avoided by having packaging and testing run in different environments (I could be wrong here, I’ve only given the explanation a cursory look). The tests modified the code that got released. Tests rightly shouldn’t be constrained by other demands (like specific versions of libraries that may be shared between the test and build steps, for example), and the deploy/build step shouldn’t have to work around whatever side effects the tests might create. Containers are easy to spin up.

          Keeping them separate helps. Sure, you could do folders on the same repo, but test repos are usually huge compared to code repos (in my experience) and it’s nicer to work with a repo that keeps its focus tight.

          It’s comically dumb to assume all tests are equal and should absolutely live in the same repo as the code they test, when writing tests that function multiple codebases is trivial, necessary, and ubiquitous.

          • balp@lemmy.world
            link
            fedilink
            arrow-up
            1
            arrow-down
            1
            ·
            2 years ago

            It’s also easier to work if one simple git command can get everything you need. There is a good case for a bigger nono-repo. It should be easy to debug tests on all levels else it’s hard to fix issues that the bigger tests find. Many new changes in git make the downsides of a bigger repo less hurtful and the gains now start to outweigh the losses of a bigger repo.

            • Hexarei
              link
              fedilink
              arrow-up
              4
              ·
              2 years ago

              A single git command can get everything for split repos if you use submodules

              • balp@lemmy.world
                link
                fedilink
                arrow-up
                2
                arrow-down
                1
                ·
                2 years ago

                I would say yes and no, but yes the clone command can do it. But branching and CI get a bit more complicated. Pushing and reviewing changes gets more complicated to get the overview. If the functionality and especially the release cycle is different the submodules still have great values. As always your product and repo structure is a mix of different considerations and always a compromise. I think the additions in git the last years have made the previous really bad pain points with bigger repos less annoying. So that I now see more situations it works well.

                I always recommend keeping all testing in the same repo as the code that affects the tests. It keeps tracking changes in functionality easier, needing to coordinate commits, merging, and branches in more than one repo is a bigger cognitive load.

      • balp@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        2 years ago

        I agree that in most cases it’s more of an E2E or integratiuon test, not sure of the need to split into different repo, and well in the end I’m not sure that would have made any big protection anyhow.

    • xlash123@sh.itjust.works
      link
      fedilink
      arrow-up
      24
      ·
      2 years ago

      As mentioned, binary test files makes sense for this utility. In the future though, there should be expected to demonstrate how and why the binary files were constructed in this way, kinda like how encryption algorithms explain how they derived any arbitrary or magic numbers. This would bring more trust and transparency to these files without having to eliminate them.

      • noli
        link
        fedilink
        arrow-up
        1
        ·
        2 years ago

        You mean that instead of having a binary blob you have a generator for the data?

  • d3Xt3r@lemmy.nzM
    link
    fedilink
    arrow-up
    101
    ·
    2 years ago

    This is informative, but unfortunately it doesn’t explain how the actual payload works - how does it compromise SSH exactly?

    • Aatube@kbin.melroy.org
      link
      fedilink
      arrow-up
      51
      arrow-down
      4
      ·
      2 years ago

      It allows a patched SSH client to bypass SSH authentication and gain access to a compromised computer

      • d3Xt3r@lemmy.nzM
        link
        fedilink
        arrow-up
        67
        ·
        edit-2
        2 years ago

        From what I’ve heard so far, it’s NOT an authentication bypass, but a gated remote code execution.

        There’s some discussion on that here: https://bsky.app/profile/filippo.abyssdomain.expert/post/3kowjkx2njy2b

        But it would be nice to have a similar digram like OP’s to understand how exactly it does the RCE and implements the SSH backdoor. If we understand how, maybe we can take measures to prevent similar exploits in the future.

        • underisk@lemmy.ml
          link
          fedilink
          arrow-up
          28
          arrow-down
          1
          ·
          2 years ago

          I think ideas about prevention should be more concerned with the social engineering aspect of this attack. The code itself is certainly cleverly hidden, but any bad actor who gains the kind of access as Jia did could likely pull off something similar without duplicating their specific method or technique.

          • whereisk@lemmy.world
            link
            fedilink
            arrow-up
            13
            ·
            2 years ago

            Ideally you need a double-blind checking mechanism definitionally impervious to social engineering.

            That may be possible in larger projects but I doubt you can do much in where you have very few maintainers.

            I bet the lesson here for future attackers is: do not affect start-up time.

            • underisk@lemmy.ml
              link
              fedilink
              arrow-up
              9
              ·
              2 years ago

              I imagine if this attacker wasn’t in a rush to get the backdoor into the upcoming Debian and Fedora stable releases he would have been able to notice and correct the increased CPU usage tell and remain undetected.

        • baseless_discourse@mander.xyz
          link
          fedilink
          arrow-up
          6
          ·
          edit-2
          2 years ago

          I am not a security expert, but the scenario they describe sounds exactly like authentication bypass to a layman like me.

          According to https://www.youtube.com/watch?v=jqjtNDtbDNI the software installs a malicious library that overwrite the signature verification function of ssh.

          I was wondering if the bypass function was designed to be slightly less resource intensive, it probably won’t be discovered and will be shipped to production.

          Also I have mixed feeling about dynamic linking, on the one hand, it allows projects like harden malloc to easily integrate into the system, on the other hand, it also enables the attacker to hijack the library in a similar fashion.

          EDIT: This is a remote code execution exploit, not authentication bypass. The payload is sent as an authentication message and will be executed by the compromised authentication function.

          This means:

          • the payload will be executed as root, since sshd run as root.
          • the payload will leave no trace in login log.

          So this is much worse than ssh authentication bypass.

          • Aatube@kbin.melroy.org
            link
            fedilink
            arrow-up
            6
            ·
            2 years ago

            5.6.1 in fact made it less resources-intensive, but the distro happened to not have updated yet when Freund discovered the backdoor.

          • Cochise@lemmy.eco.br
            link
            fedilink
            arrow-up
            2
            ·
            2 years ago

            Authentication bypass should give you interactive access. “I’m in” like. Remote code execution only allows you to run a command, without permanent access. You can use some RCE vulnerabilities to bypass authentication, but not all.

            • baseless_discourse@mander.xyz
              link
              fedilink
              arrow-up
              2
              ·
              edit-2
              2 years ago

              Yeah, but the malicious code replaces the ssh signature verification function to let it allow a specific signature. Hence attacker, with the key, can ssh into any system without proper authentication by ssh.

              This kind of describes authentication by-pass, not just remote code execution…

              EDIT: it is remote code execution, see the edit of parent comment.

        • Aatube@kbin.melroy.org
          link
          fedilink
          arrow-up
          3
          ·
          2 years ago

          Under the right circumstances this interference could potentially enable a malicious actor to break sshd authentication and gain unauthorized access to the entire system remotely. —Wikipedia, sourced to RedHat

          Of course, the authentication bypass allows remote code execution.

    • uis@lemm.ee
      link
      fedilink
      arrow-up
      4
      ·
      2 years ago

      There is RedHat’s patch for OpenSSH that adds something for systemd, which adds libsystemd as dependency, which has liblzma as its own dependency.

  • UnityDevice@startrek.website
    link
    fedilink
    arrow-up
    97
    ·
    2 years ago

    If this was done by multiple people, I’m sure the person that designed this delivery mechanism is really annoyed with the person that made the sloppy payload, since that made it all get detected right away.

    • bobburger@fedia.io
      link
      fedilink
      arrow-up
      21
      ·
      2 years ago

      I like to imagine this was thought up by some ambitious product manager who enthusiastically pitched this idea during their first week on the job.

      Then they carefully and meticulously implemented their plan over 3 years, always promising the executives it would be a huge pay off. Then the product manager saw the writing on the wall that this project was gonna fail. Then they bailed while they could and got a better position at a different company.

      The new product manager overseeing this project didn’t care about it at all. New PM said fuck it and shipped the exploit before it was ready so the team could focus their work on a new project that would make new PM look good.

      The new project will be ready in just 6-12 months, and it is totally going to disrupt the industry!

      • nxdefiant@startrek.website
        link
        fedilink
        arrow-up
        26
        ·
        2 years ago

        I see a dark room of shady, hoody-wearing, code-projected-on-their-faces, typing-on-two-keyboards-at-once 90’s movie style hackers. The tables are littered with empty energy drink cans and empty pill bottles.

        A man walks in. Smoking a thin cigarette, covered in tattoos and dressed in the flashiest interpretation of “Yakuza Gangster” imaginable, he grunts with disgust and mutters something in Japanese as he throws the cigarette to the floor, grinding it into the carpet with his thousand dollar shoes.

        Flipping on the lights with an angry flourish, he yells at the room to gather for standup.

  • refreeze@lemmy.world
    link
    fedilink
    arrow-up
    80
    ·
    2 years ago

    I have been reading about this since the news broke and still can’t fully wrap my head around how it works. What an impressive level of sophistication.

    • rockSlayer@lemmy.world
      link
      fedilink
      arrow-up
      84
      arrow-down
      4
      ·
      2 years ago

      And due to open source, it was still caught within a month. Nothing could ever convince me more than that how secure FOSS can be.

      • Lung@lemmy.world
        link
        fedilink
        arrow-up
        97
        arrow-down
        2
        ·
        2 years ago

        Idk if that’s the right takeaway, more like ‘oh shit there’s probably many of these long con contributors out there, and we just happened to catch this one because it was a little sloppy due to the 0.5s thing’

        This shit got merged. Binary blobs and hex digit replacements. Into low level code that many things use. Just imagine how often there’s no oversight at all

        • rockSlayer@lemmy.world
          link
          fedilink
          arrow-up
          50
          arrow-down
          1
          ·
          2 years ago

          Yes, and the moment this broke other project maintainers are working on finding exploits now. They read the same news we do and have those same concerns.

            • rockSlayer@lemmy.world
              link
              fedilink
              arrow-up
              11
              arrow-down
              1
              ·
              2 years ago

              Bug fixes can be delayed for a security sweep. One of the quicker ways that come to mind is checking the hash between built from source and the tarball

              • Lung@lemmy.world
                link
                fedilink
                arrow-up
                14
                ·
                2 years ago

                The whole point here is that the build process was infiltrated - so you’d have to remake the build system yourself to compare, and that’s not a task that can be automated

          • Corngood@lemmy.ml
            link
            fedilink
            arrow-up
            19
            ·
            2 years ago

            I wonder if anyone is doing large scale searches for source releases that differ in meaningful ways from their corresponding public repos.

            It’s probably tough due to autotools and that sort of thing.

        • The Quuuuuill@slrpnk.net
          link
          fedilink
          English
          arrow-up
          28
          ·
          2 years ago

          I was literally compiling this library a few nights ago and didn’t catch shit. We caught this one but I’m sure there’s a bunch of “bugs” we’ve squashes over the years long after they were introduced that were working just as intended like this one.

          The real scary thing to me is the notion this was state sponsored and how many things like this might be hanging out in proprietary software for years on end.

      • slazer2au@lemmy.world
        link
        fedilink
        English
        arrow-up
        8
        ·
        2 years ago

        Yea, but then heartbleed was a thing for how long that no-one noticed?

        The value of foss is so many people with a wide skill set can look at the same problematic code and dissect it.