Couldn't a compiler modify my Program by basically adding a piece of malware into your otherwise legit code. And how would I figure out if it does it?
Ken Thompson wrote a great article about this
To what extent should one trust a statement that a program is free of Trojan
horses? Perhaps it is more important to trust the people who wrote the
software.
He described how a trojan horse can be put into the C compiler and based on the fact that a new C compiler is compiled with the current C compiler ( chicken-egg)
- First, insert the trojan into C compiler code
- Compile it, now the new C compiler has the trojan that injects itself into every code it compiles.
- Rollback to the old C compiler code, and compile it with the new compiler.
- The C compiler source code doesn't have the trojan, but the compiler has it and carries it into every program it compiles even the future C compilers.
Well at some time this can be detected. The moral, however, is that
The moral is obvious. You can't trust code that you did not totally create yourself. (Especially code from companies that employ people like me.) No amount of
source-level verification or scrutiny will protect you
from using untrusted code. In demonstrating the possibility of this kind of attack, I picked on the C compiler.
I could have picked on any program-handling program
such as an assembler, a loader, or even hardware microcode. As the level of program gets lower, these bugs
will be harder and harder to detect. A well-installed
microcode bug will be almost impossible to detect
This is a trust issue. Until now, you trusted to your the compiler, your antivirus program, and your OS. Now your compiler and your antivirus are fighting. Couldn't be it the case that your antivirus has been corrupted? Couldn't be the case that your operating system is corrupted?
The best action is to turn off the PC and do an external analysis of the system.
Wait, will you trust the external analyzer?
And, will you trust your hardware?
This is a serious issue unfortunately poisoned by Bloomberg.
Note: Need an example for outsourcing then see the SolarWinds attack.