With the help of security researchers, Apple over the weekend quickly blocked a cyberattack aimed at infecting Mac users with file-encrypting malware known as ransomware.

The incident is believed to be the first Apple-focused attack using ransomware, which typically targets computers running Windows.

Victims of ransomware are asked to pay a fee, usually in bitcoin, to get access to the decryption key to recover their files.

Security company Palo Alto Networks wrote on Sunday that it found the “KeRanger” ransomware wrapped into Transmission, which is a free Mac BitTorrent client.

Transmission warned on its website that people who downloaded the 2.90 version of the client “should immediately upgrade to 2.92.”

Sneaking past the Gatekeeper

It was unclear how the attackers managed to upload a tampered version of Transmission to the application’s website. But compromising legitimate applications is a commonly used method.

“It’s possible that Transmission’s official website was compromised and the files were replaced by re-compiled malicious versions, but we can’t confirm how this infection occurred,” Palo Alto wrote on its blog.

The tainted Transmission version was signed with a legitimate Apple developer’s certificate. If a Mac user’s security settings are set to allow downloads from identified Apple developers, the person may not see a warning from Apple’s Gatekeeper that the application could be dangerous. Security researcher Patrick Wardle of Synack has previously disclosed flaws in Gatekeeper that can lead to malicious code being installed from seemingly legitimate sources.

Apple revoked the certificate after being notified on Friday, Palo Alto wrote. The company has also updated its XProtect antivirus engine.

After it is installed on a system, KeRanger waits three days before connecting to a remote command-and-control server using the Tor system. It is coded to encrypt more than 300 types of files.

The ransom is 1 bitcoin, or about $404.

Ransomware is hard to catch

There are few defenses against ransomware. Antivirus programs often do not catch it since the attackers frequently make modifications to fool security software. The best method is to ensure files are regularly backed up and that the backup system is isolated in a way to protect it from being infected as well.

Disturbingly, KeRanger appears to also try to encrypt files on Apple’s Time Machine, its consumer backup drive, Palo Alto wrote.

Ransomware schemes have been around for more than a decade, but over the last few years have spiked.

At first the attacks struck consumer computers, with the aim of extracting a few hundred dollars. But it appears attackers are targeting companies and organizations that may pay a much larger ransom to avoid disruption.

Last month, a Los Angeles hospital said it paid a $17,000 ransom after saying it was the quickest, most effective way to restore its systems. The ransomware had affected it electronic medical records.

Although Apple’s share of the desktop computing market is much lower than Windows, cyberattackers have been showing increasing interest in it. But so far, ransomware hasn’t been a problem, although some researchers have created proof-of-concept file-encrypting malware for Macs.

Last November, Brazilian security researcher Rafael Salema Marques published a video showing how he coded ransomware for Mac in a couple of a days. He didn’t release the source code.

Also, OS X security expert Pedro Vilaca posted proof-of-concept code on GitHub for Mac ransomware he wrote, another experiment showing how simple it would be for attackers to target the platform.