• FizzyOrange@programming.dev
    link
    fedilink
    arrow-up
    54
    ·
    11 months ago

    Seems a bit clickbaity to me. It’s a flaw in Windows/cmd.exe, not Rust. Rust is just called out because it tries to emulated proper argument passing on Windows (and didn’t get it perfectly right). All languages are affected by this but most of them just throw their hands in the air and say “you’re on your own”:

    • Erlang (documentation update)
    • Go (documentation update)
    • Haskell (patch available)
    • Java (won’t fix)
    • Node.js (patch will be available)
    • PHP (patch will be available)
    • Python (documentation update)
    • Ruby (documentation update)

    It’s also extremely unlikely that you’d be running a bat script with untrusted arguments on Windows.

  • eveninghere@beehaw.org
    link
    fedilink
    arrow-up
    26
    ·
    edit-2
    11 months ago

    In February, the White House Office of the National Cyber Director (ONCD) urged technology companies to adopt memory-safe programming languages like Rust.

    My comment is somewhat unfair, but WH is not the right body to make this kind of recommendation.

    • thingsiplay@beehaw.org
      link
      fedilink
      arrow-up
      9
      ·
      11 months ago

      Why not? I mean they are right. Adopting memory safe languages is a good step forward, because it would eliminate bunch of mistakes before they happen. And the White House does not recommend Rust only, but a memory-safe language, something like Rust or something different. I wish my government would do the same.

    • thingsiplay@beehaw.org
      link
      fedilink
      arrow-up
      23
      ·
      11 months ago

      But it got a 10/10 on the scoring system by Github.

      The issue isn’t actually too much related to the Rust core language itself, but rather how they handle scripts on Windows platform. So if you don’t have a Windows program that runs Batch scripts, then it doesn’t matter to you. I wonder how common it is to run Batch scripts in Rust?

      • TehPers@beehaw.org
        link
        fedilink
        English
        arrow-up
        8
        ·
        11 months ago

        if you don’t have a Windows program that runs Batch scripts with untrusted arguments

        This only matters when running the scripts with user inputs passed as arguments to the command, which I can’t imagine being remotely common at all.

      • tatterdemalion@programming.dev
        link
        fedilink
        arrow-up
        6
        ·
        11 months ago

        I don’t think my company uses batch scripts anywhere, but if they did, it would probably be in the app installer for Windows or something.

    • Sekoia
      link
      fedilink
      arrow-up
      17
      ·
      11 months ago

      Also, the reason this is a CVE is because Rust itself guarantees that calling commands doesn’t evaluate shell stuff (but this breaks that guarantee). As far as I know C/C++ makes no such guarantee whatsoever.

      • xmunk@sh.itjust.works
        link
        fedilink
        arrow-up
        6
        ·
        11 months ago

        C++ has no guarantees built into stdlib but frameworks like Qt provide safe access - the ecosystem has options. C++ itself is quite a simple language, most of the power comes out of toolsets and frameworks built on top of it.

            • arendjr@programming.dev
              link
              fedilink
              arrow-up
              5
              ·
              edit-2
              11 months ago

              That’s certainly not the case, because that’s like saying the issue is with Rust’s string slices. I think you may have missed the part of the issue where batch scripts require additional escaping due to Windows’ command handling. It’s a ridiculous design of the Windows API system, which is also why (almost?) every language they tested was vulnerable, so it would be actually very outstanding if Qt prevented this.

              For C++ devs not using Qt it’s just another footgun they’ll likely keep introducing security issues with as well. But if you do use Qt, I think it’s better to double-check since it may also require a patch.

  • xmunk@sh.itjust.works
    link
    fedilink
    arrow-up
    21
    ·
    11 months ago

    Now that it has been identified, it should be an easy fix, at least.

    Still, it’s important to remember that Rust is still a relatively young ecosystem and flaws like this exist until we get burned by them.

      • anton
        link
        fedilink
        arrow-up
        1
        ·
        11 months ago

        I looked at the diff, it’s around 100 lines of new code and a few hundred lines of comments and tests.
        I couldn’t have written it, but there are many smarter people that fixed it after they learned of the problem.

        What also made it easier to fix is that they (sensibly) chose to error on certain strings that can’t be escaped safely.

        • bizdelnick@lemmy.ml
          link
          fedilink
          arrow-up
          1
          ·
          11 months ago

          It’s not a proper fix, there are still cases when correct escaping is impossible and the function simply returns a error. I don"t know if if this possible at all to escape any string or if it is just because of lack of documentation, but anyway i wouldn’t call this a thing that is easy to fix.

  • drjkl@programming.dev
    link
    fedilink
    arrow-up
    11
    ·
    11 months ago

    I’ve run into bizarre behavior with windows command lines plenty of times before, but I’d never put all the pieces together and realized that:

    a) windows really does pass around unadorned monolithic strings containing the entire command line of an executed command, and

    b) there’s no parsing standard for command lines in windows

    sigh, windows