r/Compilers • • 25d ago

potentially using the interpreter diversity of Python against attacks?

To detect, if a compiler is compromised, one takes multiple independent compilers to compile the compiler. Now you have multiple compilers - use them to compile a programm and check if the binaries match - if they don't, at least one compiler used to compile the compiler, that compiled the programm is either compromised or faulty. (that's a lot of compiler xD)

That is the standard approach.

But instead of that, why not just write one compiler in python, that can then compile your compiler? Like, there are so many different Python interpreters that you can use to check if your compiler is compromised. This makes a malicious attack from the used python compiler basically impossible, because it's unreasonable to assume that every python interpreter is compromised at once. Also, it would give nieche languages a way to check if their compiler is compromised.

Sadly, this also introduces the weakness of one point of failure. If the compiler written in Python is faulty, it can't be detected. Additionally, interpreters are REALLY slow. So - does the idea have merit, or should one just use the C compiler from that open source bootstrap chain and write their own compiler in C?

6 Upvotes

2 comments sorted by

4

u/CandyCorvid 25d ago

what you're suggesting sounds equivalent to ordinary diverse double-compiling, with the choice that each compiler-compiler happens to be a different flavour of python's compiler. i'd say that sounds as robust as ordinary DDC assuming that all these python interpreters and compilers are diverse and independent. and i don't know how to evaluate that

2

u/AustinVelonaut 25d ago

To really do it right, you have to go back to building a secure bootstrap chain from a 280 byte hex monitor.