It is a well known vulnerability that a properly altered compiler binary can transfer itself to new binaries of the compiler, and still be entirely absent from the source code.

But how real is this possibility? Has there been any attempt to audit binaries in available compilers (gcc for instance) to detect such self-replicating vulnerabilities?

  • One way to carry out such an audit would be to compile the same source with multiple different compilers (e.g. compile gcc with gcc and Intel's icc) then run static analysis tools on the resulting binaries to see where (if ever) their logic differs.
    – Michael
    Aug 5, 2013 at 17:39

1 Answer 1


It is not actually "well known". The story comes from a classic must-read article from Ken Thompson. Though it was implemented at that time as a demonstration, it would be challenging to do it on a larger scale.

The main problem here is about software updates. For the malicious binary chunk to be reinjected in the compiler, should the compiler be recompiled with itself, that code must know where, precisely, it should hook itself. And this may change between versions of the compiler. When a GCC developer makes some changes in the source code, he may unwillingly break the hooking mechanism of the hypothetical replicating virus, and he would not know it. But future changes by developers cannot be predicted, let alone be accounted for in a virus which must then work in an autonomous manner.

Or, said otherwise, succeeding at writing a piece of (malicious) code which resists more than 20 years of updates and overhauling of a software as complex as GCC, would be a remarkable engineering feat, and I doubt mankind as a whole knows enough about computers to achieve that. Yet.

In the old Thompson situation, the C compiler software was not changed, only recompiled, and that made the whole thing easy (a fun and philosophically challenging eye-opener, but still technically easy).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .