If your on-premises SharePoint server is compromised, immediate containment and remediation are critical to limit data loss, restore integrity, and prevent further breach spread. This guide walks you through a structured incident response tailored to SharePoint environments—starting with isolation, moving through evidence preservation, eradication, recovery, and hardening—while emphasizing practical, actionable steps grounded in real-world security practices.
What You'll Need
- Access to the SharePoint server (physical or remote admin)
- Domain administrator or SharePoint farm administrator credentials
- Backup media or verified backup system (SQL backups, SharePoint farm backup)
- Security tools: network traffic analyzer (e.g., Wireshark), endpoint detection and response (EDR) agent, or log review tools (e.g., LogParser, ELK stack)
- Incident response playbook or checklist (predefined if possible)
- Staging environment (isolated, non-production) for testing restoration
- Communication plan (internal stakeholders, legal, PR, law enforcement if needed)
Step-by-Step
- Confirm and Assess the Compromise
Review logs in ULS logs (C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\LOGS), IIS logs (C:\inetpub\logs\LogFiles), Windows Event Viewer (Security, System, Application), and SQL Server logs. Look for unusual activity: repeated failed logins, unexpected SQL queries, abnormal file modifications (especially in C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\BIN or web.config), or unknown PowerShell scripts running. Use `Get-SPLogEvent` in PowerShell to filter for errors or warnings around the suspected time. Also check for suspicious outbound network connections via netstat -ano or firewall logs. - Isolate the Compromised Server
Do not power off immediately unless active exfiltration is occurring (e.g., large data transfer to unknown IPs). Instead, disable the server’s network interface: run `Disable-NetAdapter -Name "Ethernet" -Confirm:$false` in PowerShell, or unplug the network cable physically if remote access is compromised. Then, remove the server from DNS and update firewall rules to block its IP entirely. If farm-wide compromise is suspected, isolate all SharePoint servers and the SQL Server cluster. Ensure your isolation doesn’t break critical backups or monitoring—use out-of-band management (iLO, iDRAC) if needed. - Preserve Evidence
Before making changes, create forensic images of the compromised server(s): use `dd` (Linux), FTK Imager, or vendor EDR tools to capture memory and disk. Export logs to a secure, write-once location (e.g., encrypted USB or SIEM). Save ULS logs, IIS logs, SQL traces, registry hives (especially HKLM\SYSTEM, HKLM\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions), and any custom scripts or web parts deployed. Document timestamps, process IDs, and user accounts involved. Never rely solely on in-memory data—store evidence off-server. - Identify the Attack Vector and Scope
Determine how the attacker entered: common SharePoint entry points include vulnerable web parts, outdated patches (especially for CVEs like ProxyLogon/ProxyShell), weak credentials (brute-force via /_layouts/authenticate), or compromised service accounts. Use `Get-SPWebApplication | Get-SPSite | Get-SPWeb` in PowerShell to audit customizations and permissions. Check for backdoors: look for unknown entries in web.config (e.g., `` or ` ` additions), unexpected ASPX files in _layouts or SiteAssets, or malicious timer jobs (`Get-SPTimerJob | Where-Object {$_.Title -like "*"}`). Also verify if other servers (e.g., domain controllers, Exchange, SQL) were compromised via lateral movement—check event ID 4624 (logon) for anomalous source IPs or logon types (e.g., 3 for network logons from internal IPs). - Eradicate the Threat
On isolated servers, run full antivirus/EDR scans and manual checks. Delete malicious files (e.g., suspicious .aspx, .ashx, or .svc files), remove unauthorized entries in web.config, and reset all SharePoint-related service accounts and passwords. Revoke and regenerate any leaked API keys, SharePoint app passwords, or certificate private keys. Patch known vulnerabilities: apply the latest cumulative update (CU) or security update for your SharePoint version (e.g., April 2024 CU for SharePoint 2016/2019). If the database server is compromised, rebuild or restore its OS and SQL Server from clean backups after patching. - Restore from Clean Backups
Use your most recent known-clean backup. For SharePoint, this means both farm configuration (via `Backup-SPFarm`) and content databases (via SQL Server backup). Restore to a staging environment first for validation: ensure no malicious code persists in stored procedures or database-trusted assemblies. Once validated, restore to production during maintenance windows. After restoration, run `Test-SPContentDatabase` and `Upgrade-SPContentDatabase` to detect corruption or schema issues. Never restore directly to production without testing—corrupted backups can reintroduce malware. - Reconnect and Monitor
Re-enable network access only after all servers pass security scans and patches are applied. Gradually bring services online: start with SQL, then WFEs, then app servers. Monitor closely for 72+ hours using ULS, EDR, and network traffic tools. Set alerts for high-volume outbound traffic, anomalous ULS errors (e.g., "Access Denied" followed by successful admin logins), or unexpected PowerShell cmdlets like `Invoke-Expression`. Use SharePoint Health Analyzer to run all rules post-recovery. - Harden the Environment
Implement least-privilege: ensure no service accounts have local admin rights on WFEs or app servers. Disable unused web applications and site collections. Restrict file upload types (e.g., block .aspx, .svc in document libraries via web app policy). Enable Azure AD Conditional Access if hybrid, and enforce MFA for all SharePoint admin accounts. Audit permissions quarterly using `Get-SPUser -Web https://site -Limit ALL | Select LoginName, DisplayName, IsSiteAdmin`. Update SSL/TLS to TLS 1.2+, disable SSLv3 and TLS 1.0/1.1.
Common Mistakes
- Rebooting the server before preserving memory dumps—this loses volatile evidence like running processes or decryption keys.
- Restoring from backups that include the compromise (e.g., backups taken after initial breach but before detection).
- Resetting only user passwords but leaving service accounts unchanged—attackers often pivot via service accounts.
- Overlooking third-party solutions: if you use custom web parts, InfoPath forms, or third-party add-ons, they may harbor backdoors and must be vetted or replaced.
- Not isolating the SQL Server: SharePoint relies heavily on SQL, and attackers may have planted persistent scripts in stored procedures.
Tips
- Run `Get-SPProduct -Local` daily in PowerShell to audit installed updates; automate this in a scheduled task.
- Use SharePoint’s built-in audit logs (Site Settings > Site Settings > Site collection audit settings) to track critical actions—enable all events during an incident.
- Keep a separate, air-gapped backup: if possible, use tape or cloud-based immutable storage (e.g., Azure Blob Storage with legal hold) for farm backups.
- Document every action taken—this aids post-incident reviews and may be required for compliance (e.g., GDPR, HIPAA).
- Test recovery procedures quarterly: run a tabletop exercise simulating a compromise to validate your backup and restore steps.
Troubleshooting
If the server won’t start after restoration: check if SQL Server is reachable and the SharePoint configuration database is intact—run `Test-SPDatabase` and verify the farm configuration database name matches. If ULS logs show "The server was not found or was not accessible," confirm SQL Browser service is running and firewall rules allow port 1433. If web apps fail with 500 errors, inspect web.config for malformed entries (e.g., unmatched XML tags) and restore from a known-clean copy. If malware persists post-eradication, assume full disk compromise: rebuild the OS from scratch using a trusted image, then reinstall SharePoint with patched binaries only. If lateral movement is suspected, isolate all servers and reset domain admin passwords before restoring anything.
Frequently Asked Questions
How long does SharePoint recovery usually take?
Typically 24–72 hours for a contained incident, but full forensic analysis and hardening may extend this. Recovery time depends on backup freshness, attack scope, and team readiness.
Can I restore just one site collection after compromise?
Not reliably—malware often spreads across databases or shares. Full farm restoration from clean backups is strongly recommended over partial recovery.
Do I need to notify regulators?
Yes, if sensitive data (e.g., PII, health records) was exposed. GDPR, HIPAA, or local laws may require reporting within 72 hours—consult legal counsel immediately.
What if the attacker modified the SQL Server?
Rebuild the SQL instance from scratch. Restore databases only from backups taken before the compromise date. Audit stored procedures, triggers, and permissions manually.
Should I disconnect from domain controllers?
Yes, temporarily—especially if domain admin credentials may be compromised. Rejoin servers to the domain only after resetting all service account passwords and verifying DC integrity.
Is there a way to detect compromise in real time?
Enable SharePoint audit logging and forward ULS logs to a SIEM with rules for abnormal patterns (e.g., bulk downloads, admin logins at odd hours). Also, deploy EDR on all SharePoint servers.