Apple has released iOS 4.0.2 to fix a flaw that allowed malware to jailbreak an iPhone without the user’s knowledge.