• FizzyOrange@programming.dev
    link
    fedilink
    arrow-up
    55
    arrow-down
    1
    ·
    7 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.

    • UnfortunateShort@lemmy.world
      link
      fedilink
      arrow-up
      9
      arrow-down
      5
      ·
      7 months ago

      This hurts my brain. We have nice shell languages now, can we just lock down and phase out the rest please? I don’t even want to know the hidden cost of running Bash or sh scripts tbh. Both are languages where you can do something not right enough, because everything just has to be obnoxious.

      • Gobbel2000@programming.dev
        link
        fedilink
        arrow-up
        3
        ·
        7 months ago

        I won’t argue with you that bash is janky and easily insecure, but what shell language do you think should replace bash?

        • BatmanAoD@programming.dev
          link
          fedilink
          arrow-up
          1
          ·
          7 months ago

          The only semi-realistic way I can see Bash becoming mostly obsolete is with a tool that provides automated migration of large scripts, and the only project I know of that’s even attempting that is Oil: https://www.oilshell.org/

          But for spawning a command in a subprocess, there really ought to be a standard OS API that doesn’t involve invoking a shell at all. I expect that most or all implementations of posix_spawn and execve don’t invoke a shell, but the standard call to start a process on Windows, CreateProcess, apparently does involve cmd.exe for some bizarre reason, and that’s why this is a problem in the first place.

          • Gobbel2000@programming.dev
            link
            fedilink
            arrow-up
            7
            ·
            7 months ago

            While there certainly is some overlap, Python is a scripting language and not a shell language. Some tasks that involve calling lots of different programs and juggling input and output streams are much easier done in bash than in Python.

            • maiskanzler@feddit.de
              link
              fedilink
              arrow-up
              2
              ·
              7 months ago

              Absolutely true, it was more of a joke because Python is being used for pretty much anything today. I really don’t want to mess with correct indentation in my terminal.

        • UnfortunateShort@lemmy.world
          link
          fedilink
          arrow-up
          1
          arrow-down
          2
          ·
          7 months ago

          I think fish is simply fantastic. Not only is it significantly more readable than most other shell languages, it was also recently rewritten in Rust (still in testing I think), which gives me a lot of confidence when it comes to your typical vulnerabilities.

          I mean sure, a Rust vulnerability the reason we’re talking, but let’s not forget how valuable memory and thread safety are.

  • xmunk
    link
    fedilink
    arrow-up
    21
    arrow-down
    5
    ·
    7 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.

    • Sekoia@lemmy.blahaj.zone
      link
      fedilink
      arrow-up
      16
      arrow-down
      3
      ·
      7 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
        link
        fedilink
        arrow-up
        6
        ·
        7 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.

          • xmunk
            link
            fedilink
            arrow-up
            2
            arrow-down
            3
            ·
            7 months ago

            Vanishingly small. In Qt that’d have to be an issue in QStringList IIRC.

            • arendjr@programming.dev
              link
              fedilink
              arrow-up
              5
              arrow-down
              2
              ·
              edit-2
              7 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.

  • drjkl@programming.dev
    link
    fedilink
    arrow-up
    11
    ·
    7 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