-
Notifications
You must be signed in to change notification settings - Fork 161
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
Ambient Capabilities #219
Comments
https://github.com/rfjakob/earlyoom/blob/master/kill.c#L93
https://github.com/rfjakob/earlyoom/blob/master/main.c#L315
|
My concern is not what capabilities the program needs. Its why ambient? The ambient capabilities are for inheritance to child processes. If you spawn helper processes that need CAP_KILL and CAP_IPC_LOCK, fine. I am not seeing where they are spawned. If you need capabilities for immediate use, then you would ask for effective and permitted capabilities, but not inheritable or ambient. The issue is if an attacker can exploit the program, then any shell they can pop will have the capabilities. |
https://www.freedesktop.org/software/systemd/man/systemd.exec.html#AmbientCapabilities=
Actualy ambient capabilities may by used by parent process. Using ambient capabilities was recommended by Lennart for earlyoom:
|
OK, I dug into his recommendation. What is happening is that a privileged parent can select capabilities and they are passed on at fork. However, if your uid is not 0, then all capabilities are reset during execve. So, the only way to offer capabilities to scripts and things that do not want to deal with capabilities is by using ambient capabilities. This allows them to be passed on. Unfortunately, they can be passed on infinitely. But, there is a simple fix. I spent some time running some experiments today to see what's the best solution. I think that just doing this: prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_CLEAR_ALL, 0, 0, 0); fixes the issue of leaky capabilities. You would do that in main first thing in case there is any issue with command line options. I am writing up my experiments for a blog so that other's can understand the evolution of ambient capabilities under various attempts to stop the spread. With the prctl solution, you do not need to link to any extra libraries and that makes it simplest. |
Would you like to create a pull request for this? It looks very good. |
OK, opened pull request #228. |
Patch was merged, Thanks! Closing. |
I was scanning my system and found that earlyoom has ambient capabilities. I grepped the symbol table and can't find any execve, popen, or system function calls. Why does it need ambient capabilities?
The text was updated successfully, but these errors were encountered: