> there's no way to guarantee that your application code can't be exploited in some novel way
As a thought experiment if this hypothetical application code were written in something resembling haskell I suspect it would actually prove fairly difficult if not impossible to find novel ways to exploit it. I think at that point an attackers only options are logical inconsistencies in the underlying business logic (see that one NASA rocket) or bugs in the compiler and runtime.