This seems contrived. So you need to send someone "evil" code that they won't read, have them compile it as root, and then ship you the resulting binary. I wouldn't read too much into it "working" with some kind of compile/show service, as they could have been using non-persistent containers. Ultimately this seems like social engineering i.e. "Tricking privileged users into doing as root." Might have well ask them to…
#include
11–20 of 132 posts
Re: #include </etc/shadow>
#12Re: #include </etc/shadow>
#13Compiling untrusted code is already a dangerous affair. Compilers are not audited for security vulnerabilities, and many versions of popular compilers have contained memory corruption bugs or similar issues that could be leveraged to gain code execution. Many services that compile untrusted code will run the resulting binaries too, which definitely requires a sandbox or disposable VM - at which point you may as well…
My understanding is that Docker isn't something you use if you really want security.
Re: #include </etc/shadow>
#14Why is this surprising? Do programmers not read books anymore? Almost, any decent C programming book explains that #include reads the specified file and substitutes itself with the content of that file. Any Unix/Linux book explains that /dev/stdin is a special device file that represents the standard input.
Re: #include </etc/shadow>
#15Maybe these services run the compilation in a docker container? shadow and lsb-release exist in many images.
Re: #include </etc/shadow>
#16Compiling untrusted code is already a dangerous affair. Compilers are not audited for security vulnerabilities, and many versions of popular compilers have contained memory corruption bugs or similar issues that could be leveraged to gain code execution. Many services that compile untrusted code will run the resulting binaries too, which definitely requires a sandbox or disposable VM - at which point you may as well…
> I find it more likely that the "root" user mentioned in this post is the root user of some disposable Docker container, which would be the right way to run a compiler-as-a-service. My understanding is that Docker isn't something you use if you really want security.
At the minimum a disposable VM using something like KVM/QEMU/Firecracker would be a start. That way you have kernel isolation down to the hardware which is much less likely to be exploitable.
Re: #include </etc/shadow>
#17> Recently I saw a tweet where someone mentioned that you can include /dev/stdin in C code compiled with gcc. This is, to say the very least, surprising. Why is this surprising? Do programmers not read books anymore? Almost, any decent C programming book explains that #include reads the specified file and substitutes itself with the content of that file. Any Unix/Linux book explains that /dev/stdin is a special devic…
No need to be condescending. Three reasons:
1) A sophisticated compiler might read the length of a file before loading it, so that it can allocate a buffer of the right size. Doesn't work with /dev/stdin.
2) Alternatively, it might read the file via mmap(). Doesn't work with /dev/stdin.
3) Furthermore, it might check whether the file is a regular file. If not, it is almost certainly not what the programmer had in mind.
Re: #include </etc/shadow>
#18> Recently I saw a tweet where someone mentioned that you can include /dev/stdin in C code compiled with gcc. This is, to say the very least, surprising. Why is this surprising? Do programmers not read books anymore? Almost, any decent C programming book explains that #include reads the specified file and substitutes itself with the content of that file. Any Unix/Linux book explains that /dev/stdin is a special devic…
Of course, I know how the #include mechanism works, and what the special device files do, so I can anticipate the results of #include , but it is unusual enough that I had to write a small test program to see for myself.
Re: #include </etc/shadow>
#19Gentoo's build system is sandboxed by default: https://wiki.gentoo.org/wiki/Project:Sandbox
But an exploit using that would likely sooner just write something malicious in the Makefile if it wants to compromise the build machine. Targeting the compiler for such a goal seems like it would be harder.
Re: #include </etc/shadow>
#20This seems contrived. So you need to send someone "evil" code that they won't read, have them compile it as root, and then ship you the resulting binary. I wouldn't read too much into it "working" with some kind of compile/show service, as they could have been using non-persistent containers. Ultimately this seems like social engineering i.e. "Tricking privileged users into doing as root." Might have well ask them to…
Getting them to run make as root would be pretty easy. People are already conditioned to run “sudo make install”.
A good mitigation is to install software by user so root privileges aren’t needed at any step of the process.