-
Notifications
You must be signed in to change notification settings - Fork 355
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
Seal /proc/self/exe to protect against CVE-2019-5736 #343
Conversation
First of all, thank you for bring this to our attention. Can I ask you to demonstrate that Youki has the same issue? I asked because from the reading, |
The vulnerability is that you can modify the entrypoint file, which can be the actual youki executable. From there you can infect youki executable and when the host machine executes it again (for example by creating a new container) it will run the malicious code on the host machine. Yesterday, I tested the first PoC, but I needed some modification to make it work. I will give you step-by-step demonstration the following days. |
Great. I tried the first PoC mentioned and I got:
Not clear if the exploit was successful or not. The docker container returns:
|
In your case the vulnerability was not triggered. Maybe you forgot the These are my changes on cve-2019-5736-poc: diff --git a/Dockerfile b/Dockerfile
index e703898..c866bac 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,9 +1,11 @@
-FROM ubuntu:18.04
+FROM ubuntu:21.04
+
+ARG DEBIAN_FRONTEND=noninteractive
RUN set -e -x ;\
sed -i 's,# deb-src,deb-src,' /etc/apt/sources.list ;\
apt -y update ;\
- apt-get -y install build-essential ;\
+ apt-get -y install build-essential libdbus-1-3 ;\
cd /root ;\
apt-get -y build-dep libseccomp ;\
apt-get source libseccomp
@@ -11,7 +13,7 @@ RUN set -e -x ;\
ADD stage1.c /root/stage1.c
RUN set -e -x ;\
- cd /root/libseccomp-2.3.1 ;\
+ cd /root/libseccomp-2.5.1 ;\
cat /root/stage1.c >> src/api.c ;\
DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -b -uc -us ;\
dpkg -i /root/*.deb Then I run dockerd with:
And this is how I trigger it:
|
In runc, this is the part of the process, right? runc handles it in @yihuaf Can I trust you to handle this problem? |
@utam0k Sealing is enforced by copying the runc binary in an anonymous file descriptor that exists only in memory and re-executing that fd. So this needs to happen at the entry point of the execution. In case of runc, they run it from |
In case you are trying to figure out how this works:
Note that SELinux can mitigate this attack, so disable it when you are trying the PoC. |
Understood. Thank you for the explanation and I verified your steps. Can I ask you to add an error context for error handling, as well as a bit more explanation in the comments for context. Also add the two commits for reference:
Many thanks :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Just add a bit more comments for context and error handling context.
I added more comments. I hope they are good. |
youki is vulnerable to CVE-2019-5736, this can be fixed by sealing
/proc/self/exe
.pentacle crate implements the same technique that runc implemented to fix this vulnerability.
For more information about the vulnerability check the following links:
Some PoCs: