How can I check if iPhone has been manipulated or compromised firmware? I would like to buy a secondhand or refurbished iPhone 7 or newer. Since I am not watching anything regarding the hacker's scene, I am not up-to-date. Is any newer version of the iPhone hacked? Is it possible to manipulate iPhone firmware?
Typically these modifications are not sustained beyond reboot. The ones that were are called ‘untethered’ and the last one im aware of that was 9.3.4. If the iOS version is beyond that it would almost certainly have to be of the ‘tethered’ variety and simply rebooting the phone should disable any such modifications

Additionally if there is a newer iOS version available to update, doing so will break any access to the files required to remodify the phone in the future and new files will be required to redo the process at that point.