-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Wayland protocol security #3088
Conversation
What if the connection is just kept open by also passing the file descriptor to some other process, and then the PID reuse happens? |
The process which owns the file descriptor is responsible for keeping it safe. |
Ping |
I'm skeptical about FreeBSD. I'd like to see a libwayland patch first. |
I'm not sure how a libwayland patch would be possible. That link goes to my kernel patch that makes it actually store the PID. |
I don't mind if a kernel patch is necessary first. |
I don't think a kernel patch is necessary. Have you seen that |
Oh! Making libwayland explicitly send the credentials, that would work. (Though there are alternative Wayland implementations such as wayland-rs already, they have to be changed as well.) |
Turns out this approach is a bad idea. Not a very bad idea because it's hard to exploit (Flatpak is vulnerable because it's reading There are two mechanisms to check a peer's credentials: SO_PEERCRED and SCM_CRDENTIALS. These are Linux-specific but there are BSD counterparts. SO_PEERCRED is a way to get the PID/GID/UID when the socket is opened. I thought this was safe, because even if a PID has been re-used between
SCM_CREDENTIALS allows one process to send its PID/GID/UID to another via an ancillary message on a Unix socket. The kernel will check that the credentials are correct (or that the sending process has permission to fake them). Using this for this use-case is exploitable:
|
TBH I wonder if we should do protocol security at all. Does it even make sense to try to restrict access to some Wayland global when processes can set Without containers/jails/VMs/whatever, trying to restrict Wayland interfaces will not prevent anything bad. It can still be nice to have to prevent everybody from using all possible privileged protocols, but then this solution is good enough (by far). Though, we shouldn't lie to our users and say it's secure. The better solution would be to use a container software like e.g. Flatpak, implement container-specific access control interfaces (for Flatpak, it's an xdg-desktop-portal backend), and forbid apps running under containers from accessing our privileged globals. |
I've long suspected that pid-based security was a dead end. Why don't we return to working on ideas based on |
See my second post. |
Sorry, what part of it? |
I don't think implementing strong Wayland protocol security is useful for regular un-containerized clients. Those clients don't need Wayland interfaces to do evil things, and we're not the ones responsible for stopping them. |
A simple chroot should be sufficient to prevent many of those bad things. Still, how do you intend to determine if a process is containerized? How will you grant that process privileges if it ought to have some? |
Oh, like this:
Bleh. I'm not opposed to using this method to give flatpak processes et al their permissions, but I'm not convinced we can't also secure processes which are isolated more simply, e.g. chrooted. |
I don't think Even so, if the Wayland compositor exposes an interface that allows to start new processes, then it's easy to escape the chroot. |
Providing those things is easy, though. Mounting /dev into the chroot is trivial and required for many, many applications.
So... don't provide that? |
Well, you just said:
|
What part of that implies a protocol which lets clients escape a chroot by running arbitrary processes? |
I remember this was the result of last time's attempt at making the compositor launch processes: swaywm/wlr-protocols#27 |
That's unrelated to the present discussion. If it doesn't work we can just ditch that protocol and the rest is still secure (or I think it is, but we won't know if we never get back on topic instead of hemming and hawing about unrelated crap). |
Work based on the |
All right, fair enough. I'm not sure a lot of people will use this feature then, if it requires setting up per-app chroots. I guess this can just be closed. |
This is just a basic patch that filters globals on a per-client basis.
The
wl_client
→ command path conversion is done with the PID. I chose to do this because:(Also, it's not racy -- if the PID has been re-allocated for another process then the connection has been closed anyway)
More elaborate solutions like making the compositor start processes or making clients ask the compositor to do so can be added on top of this later.
TODO:
/proc/<pid>/root
/etc/wayland-security.d/
that would be installed with clients. Maybe this should be done after we've proved this system works.-Dinsecure