BOSTON (AP) - Apple released a critical software patch to fix a security vulnerability that researchers said could allow hackers to directly infect iPhones and other Apple devices without any user action.

Researchers at the University of Toronto's Citizen Lab said the security issue was exploited to plant spyware on a Saudi activist's iPhone. They said they had high confidence that the world's most infamous hacker-for-hire firm, Israel's NSO Group, was behind that attack.

The previously unknown vulnerability affected all major Apple devices - iPhones, Macs and Apple Watches, the researchers said. NSO Group responded with a one-sentence statement saying it will continue providing tools for fighting “terror and crime.”

It was the first time a so-called “zero-click” exploit - one that doesn't require users to click on suspect links or open infected files - has been caught and analyzed, the researchers said. They found the malicious code on Sept. 7 and immediately alerted Apple. The targeted activist asked to remain anonymous, they said.

“We're not necessarily attributing this attack to the Saudi government,” said researcher Bill Marczak.

Citizen Lab previously found evidence of zero-click exploits being used to hack into the phones of al-Jazeera journalists and other targets, but hasn't previously seen the malicious code itself.

Although security experts say that average iPhone, iPad and Mac user generally need not worry - such attacks tend to be limited to specific targets - the discovery still alarmed security professionals.

Malicious image files were transmitted to the activist's phone via the iMessage instant-messaging app before it was hacked with NSO's Pegasus spyware, which opens a phone to eavesdropping and remote data theft, Marczak said. It was discovered during a second examination of the phone, which forensics showed had been infected in March. He said the malicious file causes devices to crash.

Citizen Lab says the case reveals, once again, that NSO Group is allowing its spyware to be used against ordinary civilians.

In a blog post, Apple said it was issuing a security update for iPhones and iPads because a “maliciously crafted” PDF file could lead to them being hacked. It said it was aware that the issue may have been exploited and cited Citizen Lab.

In a subsequent statement, Apple security chief Ivan Krstić commended Citizen Lab and said such exploits “are not a threat to the overwhelming majority of our users.” He noted, as he has in the past, that such exploits typically cost millions of dollars to develop and often have a short shelf life. Apple didn't respond to questions regarding whether this was the first time it had patched a zero-click vulnerability.

Users should get alerts on their iPhones prompting them to update the phone's iOS software. Those who want to jump the gun can go into the phone settings, click “General” then “Software Update,” and trigger the patch update directly.

Citizen Lab called the iMessage exploit FORCEDENTRY and said it was effective against Apple iOS, MacOS and WatchOS devices. It urged people to immediately install security updates.

Researcher John Scott-Railton said the news highlights the importance of securing popular messaging apps against such attacks. “Chat apps are increasingly becoming a major way that nation-states and mercenary hackers are gaining access to phones,” he said. “And it's why it's so important that companies focus on making sure that they are as locked down as possible.”

The researchers said it also undermines NSO Group's claims that it only sells its spyware to law enforcement officials for use against criminals and terrorists and audits its customers to ensure it's not abused.

“If Pegasus was only being used against criminals and terrorists, we never would have found this stuff,” said Marczak.

Facebook's WhatsApp was also allegedly targeted by an NSO zero-click exploit. In October 2019, Facebook sued NSO in U.S. federal court for allegedly targeting some 1,400 users of the encrypted messaging service with spyware.

In July, a global media consortium published a damning report on how clients of NSO Group have been spying for years on journalists, human rights activists, political dissidents, and people close to them, with the hacker-for-hire group directly involved in the targeting. Amnesty International said it confirmed 37 successful Pegasus infections based on a leaked targeting list whose origin was not disclosed.

One case involved the fiancee of Washington Post journalist Jamal Khashoggi just four days after he was killed in the Saudi Consulate in Istanbul in 2018. The CIA attributed the murder to the Saudi government.

The recent revelations also prompted calls for an investigation into whether Hungary's right-wing government used Pegasus to secretly monitor critical journalists, lawyers and business figures. India's parliament also erupted in protests as opposition lawmakers accused Prime Minister Narendra Modi's government of using NSO Groups' product to spy on political opponents and others.

France is also trying to get to the bottom of allegations that President Emmanuel Macron and members of his government may have been targeted in 2019 by an unidentified Moroccan security service using Pegasus. Morocco, a key French ally, denied those reports and is taking legal action to counter allegations implicating the North African kingdom in the spyware scandal.