• One of the seminal papers on this is Ken Thompson's "Reflections on Trusting Trust".  https://www.archive.ece.cmu.edu/~ganger/712.fall02/papers/p761-thompson.pdf
    It sends a shiver up my spine every time I read it, but there has been a lot of interesting stuff written about it in the past 34 years, so I recommend doing some Googling and reading!