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.
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.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?
passwd uses it to update your password in an root-only-writable file
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.
The
nosuid
mount option disables this behavior per mount. Just be sure you don’t use suid binaries.Example:
sudo
ordoas
. 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).How do you set up the tty method?
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.
Thanks! I hadn’t heard about agetty before. Will save this for later.
So you can’t become root on your system unless you switch to that tty? That sounds like a gigantic pain in the ass.
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.
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!
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.
You can also create a custom keyboard layout in Linux. From what I have written down, here is how to do it (can’t double check because work computer).
I suspect this could be X11 only because it is X keyboard extension, pop_OS! didn’t adopt Wayland as early Ubuntu.
- Start by navigating to
/usr/share/X11/xkb/symbols/
. - Open the file that corresponds to your keyboard layout (I think it is
us
for American). - Add a new layout:
partial alphanumeric_keys xkb_symbols "custom" { include "us(basic)" // includes another configuration to build on, see current file you are editing. name[Group1]="US (custom)"; // will be the name of your configration/layout. key <LSGT> { [ greater, less, bar, brokenbar ] }; // < key <SPCE> { [ space, space, nobreakspace, space ] }; // Space // Add more key maps as you see fit. };
- Go to
/usr/share/X11/xkb/rules/
- Locate
evdev.xml
andbase.xml
- Edit both and look for the following block
<layout> <configItem> <name>us</name> <!--- some comment --->
- Add the following to both files on the row after the comment:
<variant> <configItem> <name>custom</name> <description>US (custom)</description> </configItem> </variant>
You might have to reboot afterwards.
- Start by navigating to