Diverse Double-Compiling (DDC) is a countermeasure to the covert compiler malware known as the trusting trust attack, which can hide itself inside self-hosting compilers. This thesis aims to explore and implement DDC for the Java compiler javac, and lays the groundwork for the defense against this class of attacks in the Java ecosystem. Diverse Double-Compilation is designed and implemented for Java, and detailed investigations are made to ensure the design is correct. Additionally, the issue of a diverse set of grandparent compilers, necessary for accurate DDC results, is explored, and a bootstrapped Java compiler is employed to increase said diversity. The function of DDC for Java is tested and verified with a proof-of-concept trusting trust attack; DDC is also used to verify the nonexistence of an attack in Temurin 21.0.5, an industry distribution of the Java Development Kit (JDK). This thesis finds that the DDC process designed in this thesis can be used to feasibly and effectively detect trusting trust attacks, even in a production-grade build pipeline; it also finds that the checked Temurin release is not very likely to be hiding a trusting trust attack.
Diversifierad dubbelkompilering (DDC) är ett sätt att upptäcka och förhindra självreproducerande datorvirus som gömmer sig i kompilatorer. Detta kandidatarbete ämnar att utforska och implementera DDC för Javas kompilator javac och lägger grunden för försvar mot denna sorts attacker i Javas ekosystem. Diversifierad dubbelkompilering designas och implementeras för Java och en noggrann undersökning av Javas byggsystem görs för att säkerställa korrekt design. Utöver detta undersöks mångfalden bland tillgängliga kompilatorer för Java och då denna finnes vara undermålig skapas och undersöks en från grunden kompilerad kompilator som tillför mångfald och används i implementationen av DDC. Vidare testas implementationen med en prototyp av ett gömt självreproducerande datorvirus. Slutligen genomförs DDC på den populära distributionen av Java vid namn Temurin, version 21.0.5. Arbetet finner att den skapade DDC-processen är effektiv för att detektera självreproducerande gömda virus, även i produktionsklara datormiljöer, samt att Temurin sannolikt inte gömmer några självreproducerande virus.