Now, the question is can we make some kind of formal verification language that forces checks everything and doesn't allow bugs? Maybe?
But that's assuming the underlying hardware and firmware doesn't have flaws that can break those assumptions too.
This is the general trade off for being correct. Being mostly right is easy, but leads to complex security issues later. Being correct is very hard, but should reduce the number of flaws to a manageable level.
I think Lean or Ada would be examples of different types of correctness contracts.
But even that isn't a foolproof winning strategy. When you start digging deeply you realize we exist in the allegory of platos cave. The reality we experience is an emergent phenomenon related to the scale at which humans operate. Things that operate at a much smaller scale experience a completely different reality than you do. For example gravity becomes so insignificant it's like it doesn't even exist when you're small enough. At least for me it's not hard to imagine nano machines that infect the substrate of a CPU and farm all your secrets out on side channels, or any number of other things that are pure sci-fi at the moment.
With complex systems there are too many failure modes, and with "vibe coding" institutional negligence it is simply degenerative.
There are theoretical workarounds to LLM brute force scans, but they are not free to build. =3
Think "this is not a vulnerability, as no security boundary is being unexpectedly crossed" except the way the security boundaries are laid down is utterly stupid and hilatiously nonsensical. Same for non-security related defects ("working as expected, wontfix" -> "the way it works is dogshit, and so your expectations are idiotic too").
Now, since these things are supposed to align with human sensibilities and are supposed to capture the human semantic understanding of our world, theoretically, this should still leave us in a pretty good spot. But not a guaranteed good spot, as that is not actually tractable, ever, and fundamentally so.
You could just implement a virus perfectly and the wrong bussines process.