Skip to content
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

PID re-use vulnerability #2995

Closed
emersion opened this issue Jun 29, 2019 · 3 comments
Closed

PID re-use vulnerability #2995

emersion opened this issue Jun 29, 2019 · 3 comments
Labels

Comments

@emersion
Copy link
Contributor

Disclaimer: I haven't actually checked whether this is an actual vulnerability. Please consider this more like a question.

Is Flatpak vulnerable to PID re-use?

The principle of PID re-use is:

  1. Spawn a process and open a Unix socket in it
  2. Make the process exit
  3. Hope for the user to spawn a privileged process with the same PID
  4. Use the socket to impersonate the privileged process

Here is a rough, incomplete PoC: https://paste.sr.ht/%7Eemersion/58bd06c2f57e3c8dedb625af6719ce7b8149c0c7

In practice, a "privileged process" means a process outside of a Flatpak, or a Flatpak process with additional permissions. A malicious app could rely on luck or on social engineering for this to happen.

It seems to me that the PID is used in quite a few places to identify the process on the other end of the connection:

Thoughts?

@emersion
Copy link
Contributor Author

emersion commented Jun 29, 2019

Additional note: it seems that Flatpak uses Bubblewrap's --unshare-pid flag, creating a PID namespace.

When a process ID is passed over a UNIX domain socket to a process in a different PID namespace (see the description of SCM_CREDENTIALS in unix(7)), it is translated into the corresponding PID value in the receiving process's PID namespace.

While PID namespaces make it more difficult for a malicious app to perform PID re-use attacks, I still think it's possible (assuming the default max PID, estimating the number of dummy processes that we need to create, opening as many sockets as possible in the first child process to get multiple tries, doing a dry run to gather data, maybe D-Bus' GetConnectionUnixProcessID, etc).

@matthiasclasen
Copy link
Collaborator

I don't think it is worth to keep an issue open for this. Please reopen this if you do the research and find an actual vulnerability

@emersion
Copy link
Contributor Author

emersion commented Aug 3, 2020

Note to self: the X11 XRes extension is another way for a process to discover its PID outside of the namespace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants