Explanation for newbies: setuid is a special permission bit that makes an executable run with the permissions of its owner rather than the user executing it. This is often used to let a user run a specific program as root without having sudo access.

If this sounds like a security nightmare, that’s because it is.

In linux, setuid is slowly being phased out by Capabilities. An example of this is the ping command which used to need setuid in order to create raw sockets, but now just needs the cap_net_raw capability. More info: https://unix.stackexchange.com/questions/382771/why-does-ping-need-setuid-permission. Nevertheless, many linux distros still ship with setuid executables, for example passwd from the shadow-utils package.

  • tal@lemmy.today
    link
    fedilink
    English
    arrow-up
    59
    arrow-down
    10
    ·
    5 days ago

    If this sounds like a security nightmare, that’s because it is.

    You can perfectly-reasonably implement suid binaries securely. They need to be simple and carefully constructed, and there shouldn’t be many of them, but the assertion that suid is “a security nightmare” is ridiculous. sudo itself relies on the suid bit.

    • renzev@lemmy.worldOP
      link
      fedilink
      arrow-up
      47
      arrow-down
      2
      ·
      edit-2
      5 days ago

      They need to be simple and carefully constructed

      Yeah, that’s the difficult part. It’s always better to go with the principle of least privilege (which is Capabilities is trying to do) than to just cross your fingers and hope that there are not bugs in your code. And who exactly is going to police people to make sure that their programs are “simple and carefully constructed”? The article I linked is about a setuid-related vuln in goddamn Xorg which is anything but.

      • Jajcus@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        8
        ·
        5 days ago

        Yes, Xorg being suid is stupid. That used to be needed due to several historical reasons, but is not any more.

        But for ‘su’ or ‘sudo’ suid is still the right mechanism to use. Capabilities won’t help, when the tool is supposed to give one full privileges. Of course, in some use cases no such command is needed, then the system can run with no suid. Similar functionality could be implemented without suid too (e.g. ssh to localhost), but with its own security implications, usually bigger than those brought but a mechanism as simple as suid (the KISS rule).

    • ricecake@sh.itjust.works
      link
      fedilink
      arrow-up
      37
      arrow-down
      2
      ·
      5 days ago

      I would describe need to proactively go out of your way to ensure a program is simple, minimal, and carefully constructed to avoid interactions potentially outside of a restricted security scope as a “security nightmare”.

      Being possible to do right or being necessary in some cases at the moment doesn’t erase the downsides.

      It’s the opposite of secure by default. It throws the door wide open and leaves it to the developer and distro maintainer to make sure there’s nothing dangerous in the room and that only the right doors are opened. Since these are usually not coordinated, it’s entirely possible for a change or oversight by the developer to open a hole in multiple distros.
      In a less nightmarish system a program starting to do something it wasn’t before that should be restricted is for the user to get denied, not for it to fail open.

      https://www.cve.org/CVERecord/SearchResults?query=Setuid

      It may be possible, but it’s got the hallmarks of a nightmare too.

      • corsicanguppy@lemmy.ca
        link
        fedilink
        English
        arrow-up
        5
        arrow-down
        1
        ·
        3 days ago

        need to proactively go out of your way to ensure a program is simple, minimal, and carefully constructed to avoid interactions potentially outside of a restricted security scope as a “security nightmare”.

        You must fear hammers.

        • ricecake@sh.itjust.works
          link
          fedilink
          arrow-up
          3
          arrow-down
          1
          ·
          3 days ago

          Walk me through that analogy, and what point you’re trying to make. My hammer doesn’t typically have unexpected interactions with things I’m not hammering. When I build a bookshelf, I don’t have to make sure my desk is clean to keep people I let borrow books from unlocking my front door without a key.

          Do you think that improper setuid isn’t a common enough vulnerability to have a name and designation?

          What constitutes a security nightmare if not something that requires a large and annoying amount of work, and can be made insecure by a mistake somewhere else?

      • Billegh@lemmy.world
        link
        fedilink
        arrow-up
        16
        arrow-down
        3
        ·
        edit-2
        5 days ago

        Hard agree. This is why rust is getting so much attention, and the c/c++ crowd are so mad. They’re happy just blaming it on a “skill issue” while losing their shit over [the rust crowd] saying “how about we don’t let you in the first place.”

        • Shanmugha@lemmy.world
          link
          fedilink
          arrow-up
          2
          arrow-down
          2
          ·
          3 days ago

          Or maybe I just think that Rust has crappy design, just like JavaScript. The suid question is of a different kind: capabilities is better because they are an expression of least-required-permission principle, and going this way can’t be argued as a skill issue

                • Shanmugha@lemmy.world
                  link
                  fedilink
                  arrow-up
                  2
                  ·
                  3 days ago

                  Complaining? No, I counter your evangelistic attitude that whoever does not like Rust is just self-important elitist. That kind of people does exist, but not liking Rust is not a sign. Cheers

                  • Billegh@lemmy.world
                    link
                    fedilink
                    arrow-up
                    1
                    ·
                    3 days ago

                    Sure, but that was a strong response for a comment on the situation. Sounds like you care. I do not. 😊

    • StaticFlow@feddit.uk
      link
      fedilink
      English
      arrow-up
      5
      ·
      5 days ago

      Does passwd rely on it as well? I’m curious to it’s benefits, and what we’re it’s original use cases. Is it a necessary component of multi-user systems?