News for hackers. Stuff that matters.
Re:List of Unix binaries that can be used to bypass local se... by TacticalCoder on Friday July 07, 2023 @06:43AM (#36629788)
Most of them by very far rely on sudo. I've got a system without sudo. The only way to execute something as root on my system is to log in, using a U2F security key, from a second system (typically a small laptop sitting next to my workstation). That second system is connected to my workstation on a dedicated LAN only used by these two machines. Firewalls on both (for example my workstation only allow SSH in from that one LAN and only from the IP of my laptop on that LAN etc.). The laptop has no Internet access, WiFi disabled (modules prevented from loading, firewall preventing network access, etc.). The laptop's sole purpose is to run command as root on the workstation: it's its sole purpose.

The downside is that I allow "root SSH", contrarily to every single best practice out there. The upside... Well. Is that there's no "sudo" installed on my workstation.

I think no sudo even installed on the machine beats the "never allow root SSH" mantra but YMMV.

(to set up the system I install the system offline, from a Debian installation medium whose checksum and signature I've verified, do my thing as root on the workstation, set up the login using U2F from the laptop, then I "lock myself out" from login as root directly at the workstation by entering a password so long I'll never enter it, something like "neverenterthisrootpasswordanymoreusethelaptopu2fkeyinstead#$bey8rUtIopTY6"*. A bit of pain to enter twice but then I'm good to go)

Re:List of Unix binaries that can be used to bypass local se... by alufers on Friday July 07, 2023 @06:55AM (#36629866)
Out of curiosity: What sensitive things does the root account protect on your workstation?

On my desktop (and probably 99% of people's desktops here) getting access to the user account is game over. The password manager? Runs as my user - one ptrace and the key can be extracted. Cookies for all my online services? Sitting right there in the home directory.

The only thing root access would give somebody on my machine is to uninstall some random packages or corrupt my install.

And don't get me wrong, I don't like this situation - I tried running some high-risk programs (browser, Libre Office) under flatpak to achieve at least some separation - but it breaks too many things.

Re:List of Unix binaries that can be used to bypass local se... by mormegil on Friday July 07, 2023 @07:42AM (#36630228)
Yeah, that's the classic https://xkcd.com/1200/

I thought about using Qubes OS on my new computer but it seemed like a lot of work and tweaking and still having to live with the limitations so I abandoned the idea.

Re:List of Unix binaries that can be used to bypass local se... by jacquesm on Friday July 07, 2023 @09:10AM (#36631200)
It does guard against someone installing a keylogger or network trick. I wonder how Samy's USB stick would fare in such an environment.
Re:List of Unix binaries that can be used to bypass local se... by ElectricalUnion on Friday July 07, 2023 @01:22PM (#36635098)
If you're really paranoid, Qubes has a "USB qubes" vm to handle untrusted USB devices. Then you only need to trust that the attacker can't tamper with PS/2.
Re:List of Unix binaries that can be used to bypass local se... by mike_hearn on Friday July 07, 2023 @10:51AM (#36632618)
Probably not 99%, no. It may be worth noting that macOS doesn't have these issues. The password manager doesn't run as the user, and entries in it have ACLs that restrict which apps can read them. In turn that's enforced by the kernel: apps can't ptrace each other and they can't tamper with each other's files. Browsers, meanwhile, encrypt the cookie store using a key stored in the keychain, so you can't read the user's cookies either.

All this is true without app sandboxing being activated. Apps that are sandboxed get even more protections.

Apple have done the best job of incrementally isolating apps from each other using different levels of sandboxing. Linux and Windows are far behind even with Flatpak. For example, we tell people who use Conveyor (our product for deploying desktop apps [1]) that one of the most secure platforms to do signing on is a Mac laptop, because the signing keys can be protected such that only Conveyor itself can read them. Even if you execute malware, it would trigger a permission prompt if it tried to access the signing keys, and then the process doing the signing is also protected in the same way. To get the same effect on Linux you'd need to set up dedicated UNIX users and the like.

Maybe I should write up a blog post on this stuff. Apple tighten things incrementally with each major release and don't make much noise about it, so I've found a lot of people aren't aware of how advanced their security has actually become.

[1] https://hydraulic.dev/

Re:List of Unix binaries that can be used to bypass local se... by mistrial9 on Friday July 07, 2023 @11:52AM (#36633573)
security so advanced that an individual software author cannot write a small MacOSX app, add an About box and cool icon, and distribute it themselves, as they choose?
Re:List of Unix binaries that can be used to bypass local se... by NavinF on Friday July 07, 2023 @05:38PM (#36638670)
Why troll? Nothing stops you from distributing a .app from your website
Re:List of Unix binaries that can be used to bypass local se... by mistrial9 on Friday July 07, 2023 @06:51PM (#36639306)
`$xattr -d com.apple.quarantine /path/to/file`
Re:List of Unix binaries that can be used to bypass local se... by mike_hearn on Saturday July 08, 2023 @08:58AM (#36643950)
Assuming by "as they choose" you mean without buying a Developer ID then yes, they can do these things. In fact if you don't supply signing certificates Conveyor will self-sign your app and produce an HTML download page with instructions telling the user how to bypass GateKeeper. It'll also generate a `curl | bash` one liner to install it from the terminal. Obviously, this isn't meant for consumer software. Really you shouldn't bypass GateKeeper even if you're a pro level developer, although of course in reality we all do it.

I too used to be maximally skeptical about this stuff. I saw what Apple did with iOS and like so many others saw the writing on the wall. But it's been 15 years now and you can still distribute and run unsigned Mac software if you want to. Developer ID/notarization remains very different to app review. App sandboxing remains optional. You can still get root if you want, both the default de-privileged version and the full fat version (by disabling SIP).

In the end the wall writing existed only in our minds. Apple have never closed the macOS platform like with iOS, and honestly I see no sign they ever will.

Re:List of Unix binaries that can be used to bypass local se... by mistrial9 on Saturday July 08, 2023 @10:08AM (#36644568)
this is great to hear, thank you for posting a current overview
Re:List of Unix binaries that can be used to bypass local se... by mcdonje on Friday July 07, 2023 @01:56PM (#36635649)
>Maybe I should write up a blog post on this stuff.

Please do. And post it to HN. It could inspire some distro maintainers.

Re:List of Unix binaries that can be used to bypass local se... by TacticalCoder on Friday July 07, 2023 @12:42PM (#36634406)
I see that reasoning very often but I don't agree with it (note that I'm not saying a local exploit is great).

But first I'll start with a question: why don't you (and everybody else for that matter), run everything as root?

Why don't we all search our entire disks for every single executable and then execute chmod 777 on all of them? I mean: that'd make for a good XKCD...

If the idea is that it's game over anyway if there's a local exploit, we may as well just run everything as root right? Why even bother with sudo at all?

> Out of curiosity: What sensitive things does the root account protect on your workstation?

I'm one of those person using several user accounts on my own system. For example my professional account is separated from my personal account (and I do use both simultaneously). One of my browsers (I run several browsers) is in a throwaway user account: clean slate at every launch. Why not?

And a local exploit compromising one user account requires a second exploit to access what's in the other users accounts.

> The only thing root access would give somebody on my machine is to uninstall some random packages or corrupt my install.

Root access could allow the attacker to install a persistent backdoor which would be very hard to detect. Installing a persistent backdoor that can evade detection is incredibly harder to do if all you have is a local exploit.

I take a system on which I have more chances to detect that an exploit happened --even if the exploit did already happen-- any day over one with less chances to detect that an exploit happened.

And even if, for me, a local exploit means it may be too late for some stuff (although having U2F/webauthn and soon passkeys in many important places should limit damages), having a non-compromised root may allow me to detect a local exploit and share my findings with the community. Which has a lot of value too.

Re:List of Unix binaries that can be used to bypass local se... by sigotirandolas on Friday July 07, 2023 @03:44PM (#36637327)
Mostly:

* Logs: If my unprivileged user gets compromised, there's a much better chance that I can figure out what the attacker did if he can't wipe his traces as root.

* Money: I use a different unprivileged user for general use and for banking, so a compromise of my general purpose user doesn't immediately mean that my banking stuff gets compromised.

* Lateral escalation: Similarly I use another user to verify the checksums or PGP signatures of Windows/Linux images, so I don't end up booting a compromised image even if I download it from a compromised browser.

The ptrace issue you mention can be avoided by using the Yama LSM.

You mention that you tried Flakpak for isolation. If you set up a well-protected root account, along with multiple unprivileged users, you can also get isolation, but between different security contexts rather than different applications. It is less convenient than Flatpak for daily use, but is extremely mature and doesn't require any of the extra layers (user namespaces, bind mounts, proxies...) that Flatpak uses.

Re:List of Unix binaries that can be used to bypass local se... by westurner on Friday July 07, 2023 @04:36PM (#36637980)
> The only thing root access would give somebody on my machine is to uninstall some random packages or corrupt my install.

While I agree that compromise of an unprivileged account has significant costs, technically superusers do have significantly greater access to the system and so there are greater levels of risk.

RedoxOS is reimplementing Linux userspace utilities in rust in order to avoid C vulns in suid binaries; like ping, which requires raw sockets for ICMP (which most of us only need the Echo Request capability of)

Superuser: https://en.wikipedia.org/wiki/Superuser

Capability-based security: https://en.wikipedia.org/wiki/Capability-based_security

Privilege-based escalation: https://en.wikipedia.org/wiki/Privilege_escalation

Principle of least privilege: https://en.wikipedia.org/wiki/Principle_of_least_privilege

MAC: Mandatory Access Control: https://en.wikipedia.org/wiki/Mandatory_access_control

Re:List of Unix binaries that can be used to bypass local se... by kefyras on Friday July 07, 2023 @06:06PM (#36638905)
>in suid binaries; like ping

ping hasn't required suid in ages, there's net.ipv4.ping_group_range and CAP_NET_RAW.

Re:List of Unix binaries that can be used to bypass local se... by westurner on Saturday July 08, 2023 @05:23PM (#36648921)
"How can I identify if a binary file is set-user-ID?" https://unix.stackexchange.com/questions/192588/how-can-i-id...

    test -u "$(type -p ping)" && echo "the suid bit on ping is set"
    ls -l "$(type ping)"
Re:List of Unix binaries that can be used to bypass local se... by drbawb on Friday July 07, 2023 @05:54PM (#36638803)
On my system the root account is primarily for upgrades, but also storage administration! ZFS snapshots protects me against silly mistakes like strange permutations of `rm -rf ~/` in day to day operations. Not having root all the time protects me against `zfs destroy -r nagato/data/home/drbawb` which will nuke my home folder, 144 frequent snapshots (15 minute intervals per 36 hours), 14 daily snapshots, 4 weekly snapshots, and 3 monthly snapshots. That would suck. A lot. (I have a file called "RIP", where a drive image used to be mounted, because I got a little too over-zealous with the recursive option on some ZFS commands on a file that had `copies=1`. _RAID is not a backup, snapshots are not a backup, etc._)

This also means that theoretically ransomware (running without root) could encrypt my home directory, but apart from doubling the number of blocks used on disk it would have no real impact on my data. (If someone writes a virus that can encrypt the blocks inside a ZFS partition, without mangling ZFS data structures beyond repair, then I'll be more impressed than angry. Not even the ZFS devs can rewrite block pointers on a running filesystem.[1])

That being said ZFS has an awesome feature called delegation which lets you run a subset of commands without root permissions. I use it sparingly, mostly to allow unprivileged backups. (Each host gets a login on my backup server, and can only create/destroy datasets that are children of a host-specific dataset. So `nagato` can `zfs destroy -r backup/hosts/nagato` but not `zfs destroy -r backup/hosts` or `zfs destroy -r backup/hosts/someone-else`.)

[1]: https://www.youtube.com/watch?v=G2vIdPmsnTI#t=44m53s

Re:List of Unix binaries that can be used to bypass local se... by mike_hock on Friday July 07, 2023 @07:10AM (#36629991)
They don't rely on sudo. The sudo tag merely indicates that if sudo is configured to allow "your" (the pwned) user account to run them, they can also be used for privileged operations that might not have been intended by whoever configured sudo that way.

"Never allow root SSH" together with the strong implication that it should be used in conjunction with sudo, has always had a very weak rationale behind it, since as soon as you actually ever make use of sudo to elevate your privileges, for an attacker there is almost no meaningful distinction between your user account and plain root.

Looking at the historic reality, the weak rationale more than evaporates completely. Due to various CVEs, sudo has, in retrospect, been a trojan horse for most of its existence that allowed privilege escalation from any user account regardless of its configuration. The period for which sudo has had these vulnerabilities overlaps rather well with the period for which it has been championed as "best practice" along with the tenuous justifications based on security by obscurity and to avoid "user mistakes."

In that light, your setup seems perfectly sane to me, however I don't believe sudo is relevant as a backdoor anymore in 2023 and the focus has most likely shifted to something else.

Re:List of Unix binaries that can be used to bypass local se... by voxadam on Friday July 07, 2023 @06:52AM (#36629848)
Do you also disallow su on your system or is it just sudo that's been banished?

Edit: I'm curious because if you still allow su on the system there seems to be little to no reason to set PermitRootLogin in sshd_config regardless of auth mechanism (password, cert, token, etc.).

Re:List of Unix binaries that can be used to bypass local se... by fuzztester on Friday July 07, 2023 @07:27AM (#36630106)
Yes, good question.

Because su was there in Unix before sudo, IIRC. And sudo means "su do", meaning do (something) as su, which in turn meant "super user" or "substitute user" according to Wikipedia, since it can also be used to login as other users than root , e.g.:

su - tom

https://en.m.wikipedia.org/wiki/Su_(Unix)

Re:List of Unix binaries that can be used to bypass local se... by tureu92 on Friday July 07, 2023 @07:16AM (#36630034)
I think at this point you are solving a wrong problem. Getting root access through X zero days exploits is not so hard. And if you uninstall `sudo` and `su`, and only login as root on dedicated TTY, you have very similar security.

I use Qubes OS for stuff like this. Way better security, no need to juggle tokens, dedicated lans and so on. Only real problem is no graphical acceleration in browser (Google Earth...)

Re:List of Unix binaries that can be used to bypass local se... by chaxor on Friday July 07, 2023 @07:34AM (#36630160)
Doesn't Qubes require like 32GB of RAM just to run?

I would love to use it, but most of the use cases I would like to try it for are much more in the realm of SBCs with 2-8GB of RAM for running services locally. It would be great to have that extra security, but the cost is really really high.

Re:List of Unix binaries that can be used to bypass local se... by tureu92 on Friday July 07, 2023 @07:42AM (#36630224)
systemd-nspawn...
Re:List of Unix binaries that can be used to bypass local se... by colejohnson66 on Friday July 07, 2023 @09:15AM (#36631262)
> Doesn't Qubes require like 32GB of RAM just to run?

32 GB minimum, but 16 GB recommended.[0] I think that's backwards, so I'd say it's actually 16, not 32 required. But yes, that's more than a typical SBC will have. The Pi 4, for example, has a maximum configuration of 8 GB, but some have modded it to have 16 GB.[1]

[0]: https://www.qubes-os.org/doc/system-requirements/

[1]: https://www.techradar.com/news/a-raspberry-pi-4-with-16gb-it...

Re:List of Unix binaries that can be used to bypass local se... by idkyall on Friday July 07, 2023 @10:10AM (#36632036)
> 32 GB minimum, but 16 GB recommended.[0].

I see Memory: 6 GB RAM under Minimum

Re:List of Unix binaries that can be used to bypass local se... by colejohnson66 on Saturday July 08, 2023 @09:18AM (#36644106)
I'm dumb. I read the 32 GB minimum from the "storage" line. Yes, 6 GB RAM is the minimum.
Re:List of Unix binaries that can be used to bypass local se... by bazodedo on Saturday July 08, 2023 @06:31PM (#36649422)
I was curios about that 16GB pi. (I want to have one myself :) Unfortunately, it looks like soldering the 16gb ram chip onto the pi did not increase the usable memory due to other hardware limitations. [1] https://forums.raspberrypi.com/viewtopic.php?t=350514
Re:List of Unix binaries that can be used to bypass local se... by gsich on Friday July 07, 2023 @08:37AM (#36630762)
>The downside is that I allow "root SSH", contrarily to every single best practice out there. The upside... Well. Is that there's no "sudo" installed on my workstation.

Allowing root login is fine. The best practice is not to allow passwords for root login.

Re:List of Unix binaries that can be used to bypass local se... by johnklos on Friday July 07, 2023 @12:23PM (#36634084)
The even better than "best" practice is to not allow passwords for any login. Keys really aren't that hard.
Re:List of Unix binaries that can be used to bypass local se... by TacticalCoder on Friday July 07, 2023 @12:47PM (#36634491)
> The best practice is not to allow passwords for root login.

My sshd is configured to not allow passwords logins at all: it's U2F/Yubikey only.

Re:List of Unix binaries that can be used to bypass local se... by gsich on Friday July 07, 2023 @05:09PM (#36638328)
I somewhat like smartcards more. Takes use of the slot, not wasting rare USB ports on notebooks. I don't why there are so few USB ports, but that's another discussion.
Re:List of Unix binaries that can be used to bypass local se... by chasil on Friday July 07, 2023 @10:09AM (#36632020)
Did you remove all of these?

  $ cd /usr/bin
  $ for x in ./*; do [ -u "$x" ] && printf "$x\\n"; done
  ./at
  ./atq
  ./atrm
  ./chage
  ./chfn
  ./chsh
  ./crontab
  ./fusermount
  ./fusermount3
  ./gpasswd
  ./mount
  ./newgrp
  ./passwd
  ./pkexec
  ./sg
  ./staprun
  ./su
  ./sudo
  ./sudoedit
  ./umount
  ./vmware-user
  ./vmware-user-suid-wrapper
  $ cat /etc/redhat-release 
  Red Hat Enterprise Linux release 8.8 (Ootpa)
I notice that chsh is not on the list of the parent article.
Re:List of Unix binaries that can be used to bypass local se... by TacticalCoder on Friday July 07, 2023 @01:02PM (#36634763)
> Did you remove all of these?

So if you can't protect versus all the threats, you may as well not do anything?

Re:List of Unix binaries that can be used to bypass local se... by chasil on Friday July 07, 2023 @04:46PM (#36638072)
Perhaps a more reasoned approach would be to rewrite them in rust, or some other hardened language for greater security.
Re:List of Unix binaries that can be used to bypass local se... by sigotirandolas on Friday July 07, 2023 @04:06PM (#36637609)
What really matters is not whether you have sudo (or su, pkexec, etc.) installed, but rather that you never, ever escalate privileges from a less trustworthy user to a more privileged one, since at a conceptual level this combines the low trustworthiness with the high privileged-ness.

Instead, when you want to elevate privileges, you should do so by using a mechanism that takes the control of the machine away from less trustworthy user - such as a Secure Attention Key or similar mechanism.

Re:List of Unix binaries that can be used to bypass local se... by chasil on Friday July 07, 2023 @04:45PM (#36638059)
But all of these programs escalate privileges from less trustworthy to more.

  $ ls -l /usr/bin/passwd
  -rwsr-xr-x. 1 root root 33424 Apr  1  2022 /usr/bin/passwd
The "s" above indicates that the program is allowed to call the setuid() family of functions to alter the real, effective, and/or saved user id.

You would not be able to change your password without the functionality.

Re:List of Unix binaries that can be used to bypass local se... by sigotirandolas on Saturday July 08, 2023 @05:39AM (#36642860)
Yeah, they do, but (in theory) they should either only allow you to do some very restricted commands (e.g. chsh, chpasswd), or require you to authenticate to run arbitrary commands (e.g. su, sudo).

The former are fine since they don’t allow arbitrary commands/escalation, and the latter (IMO) you should not use because it’s impossible to use them safely as you can’t trust the environment (the display server, terminal emulator, shell, etc.) to do what you say if it is compromised.

In practice, some of them will have bugs (and the kernel also has privilege escalation bugs frequently) so I don’t consider the user/root separation a particularly strong security boundary. For me it’s more of an additional layer against not very sophisticated attacks.

Re:List of Unix binaries that can be used to bypass local se... by chasil on Saturday July 08, 2023 @10:15AM (#36644638)
Yes, your position is more nuanced than I first surmised, not "never, ever."
Re:List of Unix binaries that can be used to bypass local se... by jonas-w on Friday July 07, 2023 @12:07PM (#36633817)
None of them rely on sudo. https://gtfobins.github.io/gtfobins/sudo/ -> Is a 404
Re:List of Unix binaries that can be used to bypass local se... by johnklos on Friday July 07, 2023 @12:37PM (#36634325)
Yeah - the whole "sudo" category just seems superfluous since the issue is with sudo, not with the individual tools.

OTOH, if people are expecting literally every program to open file handles / network sockets, then drop privileges to something else, that's a weird expectation.

I'm in the no sudo camp myself.

Re:List of Unix binaries that can be used to bypass local se... by simonblack on Friday July 07, 2023 @07:46PM (#36639762)
I've got a system without sudo

Yes, I hate sudo's unwieldiness too. The very first thing I do after installing one of those distros that default to no-root-login (Ubuntu, Mint, etc) is to give root a password.

The downside is that I allow "root SSH", contrarily to every single best practice out there.

Why can't you log in via SSH as a 'normal' user, and then "su -" to become root? I use that method, and it obviates both the use of sudo and the allowance of "root SSH".

Re:List of Unix binaries that can be used to bypass local se... by tiffanyh on Friday July 07, 2023 @08:28PM (#36640036)
OpenBSD sudo replacement, “doas”, plus them reworking the need for root to run services - address above.

https://man.openbsd.org/doas

Re:List of Unix binaries that can be used to bypass local se... by GuB-42 on Monday July 10, 2023 @05:50AM (#36664063)
These bypasses are typically not for when are the only user and also the administrator. Sudo here is not really for securing your machine: as others have said, if an attacker gets to your personal account, it is game other. It is mostly a tool for you to avoid fucking up your system by mistake.

These bypasses are useful if you want to get root access on a machine you are given some, but not all administrative rights, like a shell and a few sudo commands, for example to restart a service.