Cloud & Identity

Ransomware in Microsoft 365: Recovering OneDrive, SharePoint and Accounts

Ransomware Reverse Editorial TeamLast technical review: 8 min read

In Microsoft 365, ransomware usually does not encrypt files in the cloud itself but on an infected computer, from which the sync client uploads the encrypted files to OneDrive or SharePoint. Microsoft provides restore features covering the last 30 days, and administrators can additionally request a restore of SharePoint content from support within 14 days of actual deletion. Cleaning up compromised accounts, tokens and mailbox rules is just as important, because the customer remains responsible for data and identities.

Key takeaways

  • Stop OneDrive sync and isolate the infected device first, otherwise freshly restored files will be encrypted again.
  • Record the last known clean point in time and the affected site collection URLs, because Microsoft Support will need this information too.
  • Changing the password alone is not enough: disable compromised accounts, revoke sessions and tokens, and renew app passwords.
  • Review MFA methods, app consents, admin roles, forwarding and hidden inbox rules through which attackers can keep reading along.
  • Keep versioning enabled and plan an additional backup in case the built-in recovery windows of 30 and 14 days are not sufficient.

How ransomware gets into Microsoft 365

Many organizations assume that files in OneDrive and SharePoint are safe from ransomware because they live "in the cloud". That is only partly true. Microsoft describes the typical sequence: the ransomware runs locally on an infected computer and manipulates files through a mapped drive to a SharePoint library or through a OneDrive connection. The sync client or WebDAV then uploads the modified files to the cloud.[1]

According to Microsoft, those modifications can include encryption, appending an unknown file extension and deleting existing files. The malware also drops files with payment instructions into every directory.[1]

There is a second attack path that initially has nothing to do with encryption: account takeover. Whoever controls a Microsoft Entra ID account gains access to the associated mailbox, SharePoint folders and OneDrive files.[7] In ransomware incidents this is often used to steal data before encryption or to spread phishing.

How to recognize encrypted SharePoint and OneDrive content

Microsoft lists the following signs that a library has been hit by ransomware:[1]

  • Most files show the same Modified By timestamp.
  • Files won't open and are reported as possibly corrupted.
  • Every folder contains files with names such as HELP_DECRYPT or HELP_Recover that hold payment instructions.
  • Files have been renamed or have an extra extension appended.

Token theft leaves traces too. Microsoft's token theft playbook lists, among other things, mass file downloads, unusual downloads, newly added MFA or passwordless credentials, and mailbox forwarding rules that were added or edited.[6]

First response in the first hours

  • Stop syncing: Microsoft advises stopping OneDrive sync immediately or disconnecting mapped drives to SharePoint libraries.[1]
  • Isolate affected devices: The infected computer is the source of the encryption. Take it off the network – and into the investigation.[6]
  • Block affected accounts: Microsoft recommends disabling a compromised account during the investigation. If that is not possible, resetting the password is the next best step.[7]
  • Revoke sessions: Revoke the user's active sessions and refresh tokens, for example with Revoke-MgUserSignInSession.[7]
  • Delete nothing, note the time: Record the last known clean time and the affected site collection URLs. Microsoft Support will need these details as well.[1]
  • Preserve logs: Review Entra sign-in logs, audit logs and message trace from the start of the suspicious activity.[7]

Recovery: OneDrive, SharePoint, version history

Microsoft 365 offers several built-in ways back. The time windows matter – and so does the order: stop the source of the encryption first, then restore, or freshly restored files will be encrypted again.

Restore windows in OneDrive and SharePointSelf-service restore – up to 30 days back: Restore your OneDrive, users, whole OneDrive to a point in time; Restore a library, site admins only, whole library. Single files: version history – only if versioning is enabled. After final deletion (SharePoint): Restore via Microsoft support, admins provide site collection URL and point in time (+14 days). Self-service restore only works within 30 days. Stop syncing and clean affected devices first, otherwise files are encrypted again. Self-service restore – up to 30 days back30 days agotodayRestore your OneDriveusers, whole OneDrive to a point in timeRestore a librarysite admins only, whole librarySingle files: version history – only if versioning is enabled.After final deletion (SharePoint)permanently deleted+14 daysRestore via Microsoft supportadmins provide site collection URL and point in time © 2026 ransomware-reverse.de
Restore windows in OneDrive and SharePointSelf-service restore – up to 30 days back: Restore your OneDrive, users, whole OneDrive to a point in time; Restore a library, site admins only, whole library. Single files: version history – only if versioning is enabled. After final deletion (SharePoint): Restore via Microsoft support, admins provide site collection URL and point in time (+14 days). Self-service restore only works within 30 days. Stop syncing and clean affected devices first, otherwise files are encrypted again. Self-service restore – up to 30 days back30 days agotodayRestore your OneDriveusers, whole OneDrive to a point in timeRestore a librarysite admins only, whole librarySingle files: version history – only if versioning isenabled.After final deletion (SharePoint)permanently deleted+14 daysRestore via Microsoftsupportadmins provide site collectionURL and point in time © 2026 ransomware-reverse.de
Restore windows in OneDrive and SharePoint. Self-service restore only works within 30 days. Stop syncing and clean affected devices first, otherwise files are encrypted again.

Restore your OneDrive

The Restore your OneDrive feature lets Microsoft 365 subscribers undo all actions on files and folders within the last 30 days. If files were deleted, overwritten, corrupted or infected by malware, the entire OneDrive can be rolled back to a previous time. After automatic ransomware detection, OneDrive pre-fills a suggested restore date. With a work or school account, the feature is under Settings > Restore OneDrive.[2]

Restore a SharePoint library

Shared libraries have a comparable feature, also covering the last 30 days. Only site admins can start it. The library is restored to its state before the first selected activity, and all later activities are undone automatically. A restore can itself be undone.[3]

Version history for individual files

Individual files have version history. When you restore an earlier version, SharePoint does not remove that earlier version; it creates a copy of it and makes it the latest version.[4] This requires the library to track versions; with version history turned off, files cannot be restored to a previous version.[3][4]

When the built-in features are not enough

According to Microsoft, SharePoint retains backups of all content for 14 additional days beyond actual deletion. If content cannot be restored by self-service, an administrator can contact Microsoft Support to request a restore within that 14-day window.[1] Microsoft also points to Microsoft 365 Backup, which offers a longer protection period.[1]

OptionWhoWindow per MicrosoftNote
Restore your OneDriveUser (Microsoft 365 subscription)last 30 days[2]Entire OneDrive to one point in time
Restore a librarySite adminslast 30 days[3]Entire library, can be undone
Version historyUsers with permissionas long as versions existOnly with versioning enabled[4]
Restore via Microsoft SupportAdministrators14 days after deletion[1]Provide site collection URLs and time
Microsoft 365 Backup or external backupAdministratorsdepends on configurationLonger protection period[1]

Entra ID: winning back accounts and tokens

A password change alone does not end account misuse. Microsoft explains that access tokens issued by Entra ID last one hour by default, and applications can keep working with them until they expire. Entra ID cannot directly revoke session cookies issued by applications.[5] Microsoft describes token theft as an attack in which threat actors compromise and replay tokens issued to a user – even if that user has satisfied multifactor authentication.[6]

Steps to clean up an account

Based on Microsoft's guidance for compromised accounts and token theft:[5][6][7]

  1. Disable the account and revoke sessions (Entra admin center or Microsoft Graph PowerShell).
  2. Reset the password. For accounts synced from on-premises AD, reset it there twice – according to Microsoft to mitigate pass-the-hash, especially if on-premises password replication is delayed.[5]
  3. Do not send the new password by email, since the attacker may have access to the mailbox.[7]
  4. Renew app passwords: they are not revoked automatically when the password is reset.[7]
  5. Review registered MFA methods and devices and remove unknown ones.[7]
  6. Review applications with user consent and revoke unwanted permissions.[7]
  7. Review administrative roles and remove any that should not be there.[7]
  8. Roll back changes made by compromised privileged accounts.[6]

Microsoft also recommends Continuous Access Evaluation (CAE), which lets admins revoke session and access tokens promptly for applications that support it.[5]

Exchange Online: mailboxes as an attacker tool

Mailboxes are rarely encrypted in ransomware incidents, but they are often abused. Microsoft lists typical signs of a compromised mailbox, including:[7]

  • inbox rules that automatically forward email to unknown addresses,
  • rules that move messages to the Notes, Junk Email or RSS Subscriptions folders,
  • suspicious messages in Sent Items or Deleted Items,
  • recently added external forwarding,
  • frequent password changes or unexplained account lockouts.

Microsoft recommends checking forwarding with Get-Mailbox and inbox rules, including hidden ones, with Get-InboxRule -IncludeHidden.[7] Such rules are a classic way for attackers to keep reading mail even after a password change.

Shared responsibility: what Microsoft covers – and what it doesn't

A common misconception: "Microsoft backs up our data anyway." Under the shared responsibility model, customer data, configurations and settings, and identities and users remain the customer's responsibility for SaaS services such as Microsoft 365. Microsoft is responsible for things like physical datacenters, the network, hosts and operating systems.[8]

AreaResponsibility for SaaS per Microsoft
Customer dataCustomer
Configurations and settingsCustomer
Identities and usersCustomer
Client devicesShared
ApplicationsShared
Network, operating system, physical infrastructureMicrosoft

Microsoft sums it up: for all cloud deployment types, you own your data and identities and are responsible for protecting them.[8] For ransomware this means that retention periods, versioning, additional backups, MFA and access control are yours to plan. The strategic view is on the cyber resilience page.

Prevention: making Microsoft 365 more resilient

The key levers follow from the Microsoft guidance cited above:

  • Keep versioning enabled: without version history there is no way back to earlier file states.[3][4]
  • MFA for all accounts, phishing-resistant MFA for admins: Microsoft calls MFA essential, especially for accounts with admin privileges.[7]
  • Use Continuous Access Evaluation so tokens can be revoked promptly for supported applications.[5]
  • Feed sign-in and audit logs into a SIEM and configure alerts for risky sign-ins.[6]
  • Control external forwarding and review inbox rules regularly.[7]
  • Plan additional backups, for example Microsoft 365 Backup or an independent solution, if 30 or 14 days are not enough.[1]

Which route fits your situation?

Conclusion

Ransomware in Microsoft 365 usually starts on an infected endpoint and is carried into the cloud by synchronization. The built-in restore features are effective but time-limited: 30 days for OneDrive and libraries, plus, for SharePoint, a 14-day window after deletion for support requests. Stopping sync quickly, documenting the last clean point in time and restoring promptly gives you good odds.

The identity side matters just as much: block accounts, revoke tokens, clean up MFA methods, app consents and mailbox rules. In the cloud, too, the customer is responsible for data and identities. If the incident goes beyond a single account or device, it belongs with professional incident response – the process is described in The ransomware incident response process.

Frequently asked questions

Can ransomware encrypt files in OneDrive or SharePoint?

Yes, usually indirectly. According to Microsoft, the ransomware runs locally on an infected computer and manipulates files through a OneDrive connection or a mapped drive. The sync client or WebDAV then uploads the encrypted files to the cloud.

What is the first step when OneDrive files are being encrypted?

Stop syncing immediately or disconnect the mapped drive, and isolate the affected computer from the network. That prevents further encrypted versions from being uploaded. Investigate the account and device before starting the restore.

How far back can I restore OneDrive?

According to Microsoft, the Restore your OneDrive feature lets Microsoft 365 subscribers undo all actions on files and folders within the last 30 days. If ransomware was detected automatically, OneDrive suggests a restore date. For older states you need a separate backup.

What if SharePoint content cannot be restored by self-service?

Microsoft states that SharePoint retains backups of all content for 14 additional days beyond actual deletion. If content cannot be restored by self-service, an administrator can ask Microsoft Support for a restore within that window. Note the affected site collection URLs and the last known time the files were not modified by the ransomware.

Is changing the password of a compromised account enough?

No. Access tokens that have already been issued stay valid until they expire, one hour by default. You also need to revoke sessions, remove unknown MFA methods and devices, renew app passwords and check forwarding and inbox rules. For synced accounts, Microsoft recommends resetting the password twice in on-premises AD.

Is Microsoft responsible for recovering my data?

Only in part. Microsoft runs the infrastructure and platform, but under the shared responsibility model, data, configurations and identities remain the customer's responsibility even for SaaS services such as Microsoft 365. If you need longer retention or independent copies, you have to plan for them yourself.

What does token theft have to do with ransomware?

Stolen tokens give attackers access to mailboxes, OneDrive and SharePoint even when the user has already satisfied MFA. Attackers can use that access to exfiltrate data, spread phishing internally or set up forwarding. In any ransomware incident, check whether cloud identities are affected as well.

Read next

Sources and further reading

  1. [1]Microsoft Learn – Handling ransomware in SharePoint Online learn.microsoft.com
  2. [2]Microsoft Support – Restore your OneDrive support.microsoft.com
  3. [3]Microsoft Support – Restore a shared library support.microsoft.com
  4. [4]Microsoft Support – Restore a previous version of an item or file in SharePoint support.microsoft.com
  5. [5]Microsoft Learn – Revoke user access in an emergency in Microsoft Entra ID learn.microsoft.com
  6. [6]Microsoft Learn – Token theft playbook learn.microsoft.com
  7. [7]Microsoft Learn – Respond to a compromised email account in Microsoft 365 learn.microsoft.com
  8. [8]Microsoft Learn – Shared responsibility in the cloud learn.microsoft.com