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.

  • unhrpetby@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    12
    arrow-down
    2
    ·
    edit-2
    4 days ago

    The nosuid mount option disables this behavior per mount. Just be sure you don’t use suid binaries.

    Example: sudo or doas. I replaced those with switching to a tty with an already open root account on startup. Generally faster and (for me) more secure (you need physical access to get to the tty).

      • unhrpetby@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        5
        ·
        edit-2
        4 days ago

        All I do is have agetty --autologin root tty2 linux run as a service. It launches on startup, and I just hit CTRL + ALT + F2 if I ever need a root shell.

        All its doing is just auto logging-in as root on TTY2.

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

        From what I’ve read, no. Though it doesn’t solve the fundamental problem of a root process handling untrusted input from a regular user.

        The TTY method is IMO better as it ties privileges to a piece of physical hardware, bypassing the complexities of userspace elevation of privileges.

    • DefederateLemmyMl@feddit.nl
      link
      fedilink
      arrow-up
      2
      arrow-down
      1
      ·
      4 days ago

      So you can’t become root on your system unless you switch to that tty? That sounds like a gigantic pain in the ass.

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

        Your needs must be different than mine.

        I press one button combination and have root without ever entering a password. I press a similar combination and go back. Not sure how this is a pain in the ass.

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

          Yea, it sounds pretty nice actually. I’m considering doing that as well. Makes it obvious when you’re running in a root shell too which is nice. I’d probably still keep sudo around though.

          With a programmable keyboard it can just be one button too!

          • unhrpetby@sh.itjust.works
            link
            fedilink
            English
            arrow-up
            2
            ·
            3 days ago

            You can modify the keybinds in software too. You would need to change your console keymap (TTY) and your desktop environment keybindings. Programmable keyboard is most likely easier though.

            I played around with it and changed both to just use F1 = tty1 and so on, without requiring CTRL+ALT.