Contrary to popular opinion, cloud-based productivity suites like Microsoft Office 365 are not entirely safe from ransomware. That's because Office 365 does not exist entirely in the cloud, so PC-based malware threats like ransomware can not only affect the local components of your Office 365 data, they can (and DO) slip into your cloud-based data, too.
Ransomware is a breed of malware that (among other things) encrypts some or all of the data on your local hard drive, and then demands you pay a ransom to have your data decrypted. As even the most typical encryption is practically uncrackable, the only way to recover your encrypted data is to either pay the ransom (and there's no guarantee the attacker will live up their end of that bargain) or to recover the lost files from a backup.
While virtually all of your Office 365 data is synced to the cloud -- particularly if you use OneDrive as your primary or even exclusive file storage -- it often retains local analogues on your PC. That means if the PC version of your Office 365 data is encrypted, that malicious encryption will be synced to the cloud-based version and thereby costing you access to any and every copy of your files.
Microsoft has a step-by-step guide for dealing with a malware infection, but it boils down to this: backups are your only hope.
If you catch the malware fast enough, and luck is on your side, you can disable ActiveSync and OneDrive for Business Sync to prevent contagion of the ransomware encryption to your Office 365 cloud data. Most of us are not so fortunate to detect malware in the small window between local infection and the spread of that infection to the cloud.
Once you've halted the infection and cleaned the malware off your PCs, you can roll back to a previous file version for everything stored in OneDrive. Unfortunately, you'll have to do this one file at a time, which can prove maddeningly tedious. OneDrive file-versioning is intended for saving individual files that were uniquely corrupted (or to simply to fall back to a previous draft of an Excel spreadsheet or PowerPoint deck that you liked better). It wasn't really meant for bulk, machine-wide (or company-wide) restorations of Office 365 data.
That's where a third-party backup and restore solution for Office 365 comes in. Backupify's Office 365 Backup regularly, automatically creates safe, ransomware-free versions of your data that can be restored en masse with both speed and ease. If recovering from a ransomware attack quickly is high on your priority list, a solution like Backupify is the only sensible backup plan.