this post was submitted on 04 May 2025
292 points (98.0% liked)

linuxmemes

25065 readers
1901 users here now

Hint: :q!


Sister communities:


Community rules (click to expand)

1. Follow the site-wide rules

2. Be civil
  • Understand the difference between a joke and an insult.
  • Do not harrass or attack users for any reason. This includes using blanket terms, like "every user of thing".
  • Don't get baited into back-and-forth insults. We are not animals.
  • Leave remarks of "peasantry" to the PCMR community. If you dislike an OS/service/application, attack the thing you dislike, not the individuals who use it. Some people may not have a choice.
  • Bigotry will not be tolerated.
  • 3. Post Linux-related content
  • Including Unix and BSD.
  • Non-Linux content is acceptable as long as it makes a reference to Linux. For example, the poorly made mockery of sudo in Windows.
  • No porn, no politics, no trolling or ragebaiting.
  • 4. No recent reposts
  • Everybody uses Arch btw, can't quit Vim, <loves/tolerates/hates> systemd, and wants to interject for a moment. You can stop now.
  • 5. πŸ‡¬πŸ‡§ Language/язык/Sprache
  • This is primarily an English-speaking community. πŸ‡¬πŸ‡§πŸ‡¦πŸ‡ΊπŸ‡ΊπŸ‡Έ
  • Comments written in other languages are allowed.
  • The substance of a post should be comprehensible for people who only speak English.
  • Titles and post bodies written in other languages will be allowed, but only as long as the above rule is observed.
  • 6. (NEW!) Regarding public figuresWe all have our opinions, and certain public figures can be divisive. Keep in mind that this is a community for memes and light-hearted fun, not for airing grievances or leveling accusations.
  • Keep discussions polite and free of disparagement.
  • We are never in possession of all of the facts. Defamatory comments will not be tolerated.
  • Discussions that get too heated will be locked and offending comments removed.
  • Β 

    Please report posts and comments that break these rules!


    Important: never execute code or follow advice that you don't understand or can't verify, especially here. The word of the day is credibility. This is a meme community -- even the most helpful comments might just be shitposts that can damage your system. Be aware, be smart, don't remove France.

    founded 2 years ago
    MODERATORS
     

    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.

    top 40 comments
    sorted by: hot top controversial new old
    [–] [email protected] 50 points 3 weeks ago (3 children)

    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.

    [–] [email protected] 46 points 3 weeks ago* (last edited 3 weeks ago) (1 children)

    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 8 points 3 weeks 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 35 points 3 weeks ago (2 children)

    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.

    [–] [email protected] 12 points 3 weeks ago* (last edited 3 weeks ago) (1 children)

    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."

    [–] [email protected] -1 points 2 weeks ago (1 children)

    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

    [–] [email protected] 0 points 2 weeks ago (1 children)

    It's OK, you don't have to use so many words to tell us you work with c.

    [–] [email protected] 1 points 2 weeks ago (1 children)

    wrong guess. I work mainly in PHP

    [–] [email protected] 1 points 2 weeks ago (1 children)

    And you're complaining about rust?

    [–] [email protected] 2 points 2 weeks ago (1 children)

    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

    [–] [email protected] 1 points 2 weeks ago (1 children)

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

    [–] [email protected] 1 points 2 weeks ago (1 children)

    Lol. Changing shoes in the air? Your root comment literally starts with word "hard"

    [–] [email protected] 1 points 2 weeks ago (1 children)

    Hard agree to setuid being a problem. And that it is a problem because any of these tools written in c can be a security hole, because c is hard to get right. And I find it funny that c devs are butthurt over how rust won't let them write obviously bad code.

    But it's OK, words are difficult. 😊

    [–] [email protected] 2 points 2 weeks ago (1 children)

    And now you do not care so much that this comment tree is already hilariously long, and also has two of your emojis used to hide your true emotions. As much as I would love to discuss how c devs are "butthurt" and Rust is so damn good (sarcasm, of course), I just won't do it with someone so full of themselves and insecure. Have a good day

    [–] [email protected] 1 points 2 weeks ago

    You continue responding. You are as complicit in this thread as I am. 😊

    [–] [email protected] 4 points 2 weeks ago (1 children)

    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 2 points 2 weeks 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?

    [–] [email protected] 5 points 3 weeks ago (1 children)

    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?

    [–] [email protected] 5 points 2 weeks ago* (last edited 2 weeks ago)

    passwd uses it to update your password in an root-only-writable file

    [–] [email protected] 44 points 3 weeks ago* (last edited 3 weeks ago) (2 children)

    Last time I was tempted to use suid, it was in order to allow an application I'd written to listen on 80 and 443. Fortunately I found the capabilities way of doing that (setcap 'cap_net_bind_service=+ep' executable) and that was the first I ever heard of capabilities. I consider myself pretty Linux-savvy, but it was pretty recently that I learned about capabilities.

    [–] [email protected] 9 points 2 weeks ago

    Another potential option here is https://www.kernel.org/doc/html/latest/networking/ip-sysctl.html

    ip_unprivileged_port_start - INTEGER
    
        This is a per-namespace sysctl. It defines the first unprivileged port in the network namespace. Privileged ports require root or CAP_NET_BIND_SERVICE in order to bind to them. To disable all privileged ports, set this to 0. They must not overlap with the ip_local_port_range.
    
        Default: 1024
    

    This is also per namespace so you could use it in combination with network namespaces if you really wanted to keep privileged ports.

    [–] [email protected] 2 points 2 weeks ago

    I just run everything as root

    What security

    [–] [email protected] 26 points 3 weeks ago (1 children)

    fork bomb still being possible out of the box in a couple of characters is funny to me

    [–] [email protected] 34 points 3 weeks ago (2 children)

    That's the thing about Linux. The developers generally assume you want to do the thing you're doing. So they don't stop you.

    [–] [email protected] 6 points 2 weeks ago* (last edited 2 weeks ago)

    ah the parenting toddlers approach

    [–] [email protected] 3 points 2 weeks ago

    And I am eternally grateful for that. Why, yes, if I am playing with something I don't understand - what was the last time a fire gently asked anyone "Do you really want to get a burn?"

    [–] [email protected] 16 points 2 weeks ago* (last edited 2 weeks ago)
    [–] unhrpetby 10 points 3 weeks ago* (last edited 2 weeks ago) (3 children)

    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).

    [–] [email protected] 7 points 3 weeks ago (1 children)

    Does run0 use suid? From my understanding, it shouldn't.

    [–] unhrpetby 4 points 3 weeks 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.

    [–] [email protected] 3 points 2 weeks ago (1 children)

    How do you set up the tty method?

    [–] unhrpetby 5 points 2 weeks ago* (last edited 2 weeks 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.

    [–] [email protected] 1 points 2 weeks ago (1 children)

    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 1 points 2 weeks ago (1 children)

    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.

    [–] [email protected] 2 points 2 weeks ago (1 children)

    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 2 points 2 weeks 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.

    [–] [email protected] 4 points 2 weeks ago

    But how am I going to use capabilities to have my equivalent of sl having setuid to nobody?

    [–] [email protected] 3 points 2 weeks ago* (last edited 2 weeks ago)
    [–] [email protected] -2 points 2 weeks ago (1 children)

    In linux, setuid is slowly being phased out by

    .. brittle resume-based non-unix neu tools designed to encourage quiet balkanization and vendor/dev lock-in after being pushed by vendor payola.

    See:

    • Systemd bag of festering wunderkinder shit,
    • networkManager and its 6 different competing manager-manager tools, and
    • anything else created in the dark post-mentor ages when "move fast and break things" was dreamed up by people who didn't give a fuck about must-work tools because must-work wasn't on their final exam at udemy.
    [–] [email protected] 1 points 1 week ago

    Systemd and network manager are deliberately malicious I'm with you on that one but I feel like the new kernel-specific features like capabilities and namespaces are actually pretty neat. Like, they don't even break backward compatibility. If you had a program that needs a special capability on linux and you wanted to port it to bsd, you could just make it a SUID executable. It's not like capabilities offers a new API that programs use or something. Same with namespaces. I see a lot of people complaining about docker somehow being bloat or something, but, like, it's still just linux on the inside of the container. Anything that can run in docker can run just as well outside of it. Worst-case scenario is that you have to change some environment variables from host.docker.internal to localhost. You're not being forced to use it.