Apple has released an urgent update to its desktop operating systems and the Safari web browser to block a hack that could have turned the machines into spying tools.

The security flaw affects the El Capitan and Yosemite Mac operating systems, and is the same that could have let hackers take complete control of iPhone devices, which Apple fixed with the iOS 9.3.5 update last week.

The Silicon Valley giant quietly released the update to the Mac software and Safari a week after its iPhone patch without addressing the delay.

Apple has urged customers with devices that are not running iOS 9.3.5, OS X 10.11.6 El Capitan and 10.10.5 Yosemite to update their software immediately to protect against potentially malicious hackers from spying on them.