Live data from Hacker News

tmux Privilege Escalation

markdownbin.com

31–40 of 40 posts

Re: tmux Privilege Escalation

#31
post #29
post #23

Earlier quoted context omitted.

That threat model essentially prohibits "tmux attach", which allows an attacker running as your user to connect to your terminal session, so I don't think it's a particularly useful threat model here. That's basically exactly what we signed up for by using tmux.

This is definitely a useful threat model because people are running tmux on servers and almost certainly do not realize that this can happen. You do appear to be correct that it's exploitable via other, also trivial, means. That does not make the situation any less bad.

Running on a server doesn't change anything, you'd need to be running on a server where you routinely give people who shouldn't have root access, access to an account with sudo privileges with a password. And be relying on your attacker to not say, simply put aliases into your shell, replace your shell, modify your path, add an LD_PRELOAD, ptrace your processes, etc.

That should be absolutely no one.

Re: tmux Privilege Escalation

#33
post #10

Do we consider it a vulnerability to put "alias sudo=sudo rm -rf /" in your shell config too? How about ptrace(), depending on how your system is configured, an attacker running under your own user account could do similar damage to any process you run , make your browser display fake login forms, steal saved application passwords, etc. Once someone has access to your the user account of someone with sudo it's game o…

I mean we do consider ptrace a vulnerability which is why there's a kernel switch to turn the ability off.

> there's just too many ways to elevate

That's a problem that a lot of different people are trying to tackle because there's a lot of holes to plug.

* Wayland is plugging the Xorg hole where an app can listen or send keystrokes to other applications.

* sudo plugs this hole (by default) by requiring your password and binding your ticket to a single tty.

* Polkit plugs this hole (with Wayland's help) by having privileged dialogs and authenticating individual applications (i.e. dbus clients) instead of the user as a whole.

* The kernel switch plugs the ptrace hole.

* Flatpak and other namespacing frontends are working on the filesystem/network holes by keeping apps in their own little world unless allowed out.

* SELinux also lives in this space but it's a step removed preventing compromised apps the ability to use various escalation tricks in the first place.

We're closer than we've ever been. Now is pretty much the worst time to throw up our hands and say it can't be done.

Re: tmux Privilege Escalation

#34
post #33
post #10

Do we consider it a vulnerability to put "alias sudo=sudo rm -rf /" in your shell config too? How about ptrace(), depending on how your system is configured, an attacker running under your own user account could do similar damage to any process you run , make your browser display fake login forms, steal saved application passwords, etc. Once someone has access to your the user account of someone with sudo it's game o…

I mean we do consider ptrace a vulnerability which is why there's a kernel switch to turn the ability off. > there's just too many ways to elevate That's a problem that a lot of different people are trying to tackle because there's a lot of holes to plug. * Wayland is plugging the Xorg hole where an app can listen or send keystrokes to other applications. * sudo plugs this hole (by default) by requiring your password…

No, we aren't, there's still so so many more!

- Even if you use the kernel switch you can still ptrace an application on startup, do you read the code for every .desktop composing your launchers?

- You can trivial add say, a modified web browser or terminal emulator to a user's PATH.

- You can add aliases to a user's shell configuration

- You can change a user's entire shell to a shim designed to fool them into thinking things are normal

- You can replace that desktop update notifier with a tweaked one that logs that root password first

- Wayland too will fall when you replace a user's compositor with a customized one, must of Wayland's security improvements have actually just been moving things from display server to compositor. Simply re-configuring the user's session choice will likely be enough to do this. Just like changing your shell.

- The PolKit "hole plugging" you suggest only works if there's no way to recreate a dialog which would look exactly the same, so I'm not sure how it has any relevance here

- SELinux more prevents problems between user accounts, as the isolation is designed to work, not within them and not for authorized escalation tools like sudo

- In the case of desktop systems it's also important to remember that most if not all of the important data will be in the user's home directory. https://xkcd.com/1200/

This will not be possible, as long as the same user controls their own configurations for core stuff like shell and launchers. User accounts weren't designed for this level of isolation. Make a separate user if that's what you want. This is why most distros run all servers under different user accounts out of the box. If you're concerned about the security of say, your browser, you should probably consider adding user account isolation to it too, on Android every single app gets it's own account.

If your threat model involves giving untrusted users access to a sudoer, you're not going to have a good time. User accounts are still the primary form of isolation on Linux, it's not a sandboxed mobile OS, maybe Flatpak will change that someday, but for now we have barely even started on this sort of switch to an entirely different security model.

Re: tmux Privilege Escalation

#35
post #34
post #33

Earlier quoted context omitted.

I mean we do consider ptrace a vulnerability which is why there's a kernel switch to turn the ability off. > there's just too many ways to elevate That's a problem that a lot of different people are trying to tackle because there's a lot of holes to plug. * Wayland is plugging the Xorg hole where an app can listen or send keystrokes to other applications. * sudo plugs this hole (by default) by requiring your password…

No, we aren't, there's still so so many more! - Even if you use the kernel switch you can still ptrace an application on startup, do you read the code for every .desktop composing your launchers? - You can trivial add say, a modified web browser or terminal emulator to a user's PATH. - You can add aliases to a user's shell configuration - You can change a user's entire shell to a shim designed to fool them into think…

> you can still ptrace an application on startup

You can only ptrace an application when you are its parent. Modifying system-wide desktop files is a privileged operation and flatpak's filesystem namespacing prevents applications from messing with the launchers in your home directory.

> Messing with environments variables and shell files.

Not when you don't have access to their home directory and all your file accesses are via XDG portals.

> You can change a user's entire shell

There are a number of access controls preventing this. First, modifying a users passwd entry is a privileged operation and using `chsh` requires the user's password.

> replace a user's compositor with a customized one

The compositor is the security boundary. Of course if you replace it the model is broken but if you have a POC where a program running as the user can change a users entire compositor to a malicious one I would love to see it.

GDM launches your session and is outside your control as an unprivileged user and if the compositor dies so does your session. You can't 'swap' it and your malicious compositor can never be shown as a choice in GDM since those preferences require root to modify.

> SELinux...

SELinux isn't designed to stop you from calling sudo. But it does make sure that the scope of a what compromised application running as your user is limited. It's not directly related but MAC is a piece of the puzzle.

> if not all of the important data will be in the user's home directory

Yep, which is why apps won't have access to it except for the files the users chooses to give the application via a system dialog.

Re: tmux Privilege Escalation

#36
Not a vuln. If someone pwns the session you use to run stuff as admin, she's admin, period.

For completeness, the same can be done with screen:

screen -S session_name -p window_number -X stuff "whoami^M"

Re: tmux Privilege Escalation

#37
post #35
post #34

Earlier quoted context omitted.

No, we aren't, there's still so so many more! - Even if you use the kernel switch you can still ptrace an application on startup, do you read the code for every .desktop composing your launchers? - You can trivial add say, a modified web browser or terminal emulator to a user's PATH. - You can add aliases to a user's shell configuration - You can change a user's entire shell to a shim designed to fool them into think…

> you can still ptrace an application on startup You can only ptrace an application when you are its parent . Modifying system-wide desktop files is a privileged operation and flatpak's filesystem namespacing prevents applications from messing with the launchers in your home directory. > Messing with environments variables and shell files. Not when you don't have access to their home directory and all your file acces…

[deleted]

Re: tmux Privilege Escalation

#38
post #35
post #34

Earlier quoted context omitted.

No, we aren't, there's still so so many more! - Even if you use the kernel switch you can still ptrace an application on startup, do you read the code for every .desktop composing your launchers? - You can trivial add say, a modified web browser or terminal emulator to a user's PATH. - You can add aliases to a user's shell configuration - You can change a user's entire shell to a shim designed to fool them into think…

> you can still ptrace an application on startup You can only ptrace an application when you are its parent . Modifying system-wide desktop files is a privileged operation and flatpak's filesystem namespacing prevents applications from messing with the launchers in your home directory. > Messing with environments variables and shell files. Not when you don't have access to their home directory and all your file acces…

> Not when you don't have access to their home directory and all your file accesses are via XDG portals.

> Modifying system-wide desktop files is a privileged operation and flatpak's filesystem namespacing prevents applications from messing with the launchers in your home directory.

Okay, but let's jump over to reality for a second, no one uses Flatpak and your desktop shortcuts are on your desktop, not the system one, so are your other commonly invoked applications, due to the unnecessary complexity Flatpak introduces I feel it's unlikely to see widespread adoption in the near future.

> GDM launches your session and is outside your control as an unprivileged user and if the compositor dies so does your session. You can't 'swap' it and your malicious compositor can never be shown as a choice in GDM since those preferences require root to modify.

Did they change it so GDM no longer prefers your ~/.xinitrc if available?

You may also be able to LD_PRELOAD the compositor from your ~/.xprofile, but I haven't done any experiments there.

> Yep, which is why apps won't have access to it except for the files the users chooses to give the application via a system dialog.

This entire concept is nothing more than an annoying joke not widely deployed on any desktop system today.

Consider also that such an extreme level of sandboxing could also prevent malicious access to your tmux session and prevent this issue entirely in such a case, so why would this even be considered a problem if you're talking about that level of sandboxing?

Perhaps I was a too dismissive of it - but in any case it's a complete change of security model and its not clear that tmux is what would be at fault under such a model or if something else would be expected to protect it's session from access. Maybe some magic Flatpak garbage should be blocking access or something. Just slap more layers on it, I'm sure that'll fix it and not annoy the hell out of anyone.

Re: tmux Privilege Escalation

#39
post #19

Earlier quoted context omitted.

> Do you mean this https://github.com/tmux/tmux ? That is the source for the portable version of tmux, wrapping the native kqueue version developed for OpenBSD with libevent. Tmux is part of the OpenBSD base system. Tmux is not an officially developed program by the OpenBSD community. It was imported June 1 2009. Here is Theo de Raadt's post: > By Theo de Raadt () on 2009-07-07 04:37 > The most impressive thing about…

As best I can tell, tmux is developed primarily by Nicholas Marriott for OpenBSD and made portable with libevent. The original paper uses OpenBSD, and here[1] he says: “I preferred to work on it in base: I felt tmux would be improved by being part of OpenBSD.” [1] https://www.undeadly.org/cgi?action=article&sid=200907121904...

The author developed tmux on OpenBSD because that is what he used, but it was never part of the OpenBSD Project. It was a port prior to being included in the base install. This is no different that how FreeBSD includes software in its base install, yet this doesn't make the code part of the FreeBSD Project.

The tmux GitHub repo is the reference implementation. As an example, OpenSSH is developed internally to OpenBSD and the project creates a separate portable version. tmux is the opposite, it is developed independently of OpenBSD and the project maintains its own implementation.

Re: tmux Privilege Escalation

#40
post #39

Earlier quoted context omitted.

As best I can tell, tmux is developed primarily by Nicholas Marriott for OpenBSD and made portable with libevent. The original paper uses OpenBSD, and here[1] he says: “I preferred to work on it in base: I felt tmux would be improved by being part of OpenBSD.” [1] https://www.undeadly.org/cgi?action=article&sid=200907121904...

The author developed tmux on OpenBSD because that is what he used, but it was never part of the OpenBSD Project. It was a port prior to being included in the base install. This is no different that how FreeBSD includes software in its base install, yet this doesn't make the code part of the FreeBSD Project. The tmux GitHub repo is the reference implementation. As an example, OpenSSH is developed internally to OpenBSD…

You are incorrect, tmux is part of OpenBSD and the OpenBSD CVS tree is the main repository.

Edit: because there is occasionally confusion on this point I recently documented it here: https://github.com/tmux/tmux/wiki/Contributing

Post reply on HN