socstories.blog

Detections, KQL & More

Lessons learned from a SharePoint incident

Introduction

Sometimes strange activity shows up in logs without any clear link to a known attack vector or vulnerability. That was the case with the recent SharePoint zero-day. Unusual behavior was observed before the zero-day vulnerability was disclosed, and at the time it was not clear what was happening. What initially seemed like an odd detection soon pointed toward something much larger.

As the incident escalated over the weekend, I do want to give a shout out to the quick and adequate response of my colleagues, allowing for a swift investigation and containment of the issue. When the official advisories and patches arrived, the broader picture came into focus.

The case reinforced how valuable it is to capture lessons learned after the fact. This short write-up reflects on the key takeaways.

The Vulnerability

In late July 2025, Microsoft confirmed active attacks against on-premises SharePoint Servers that exploited two zero-day vulnerabilities: a spoofing issue (CVE-2025-53771) and a deserialization bug (CVE-2025-53770). Together, they enabled unauthenticated remote code execution, theft of machine keys, and persistent access.

Incident Timeline

  • July 18, 2025 – Exploitation was observed in the wild, with dozens of compromised internet-facing SharePoint servers reported by incident responders.
  • July 19, 2025 – Microsoft published customer guidance confirming active attacks and detailed mitigations, including rotating ASP.NET machine keys.
  • July 21, 2025 – Security vendors shared technical write-ups, noting the deserialization path and a distinctive process chain where w3wp.exe spawned child processes.
  • July 22, 2025 and after – Microsoft Threat Intelligence attributed activity to multiple China-based actors and released more IoCs, post-exploitation guidance, and emergency updates for SharePoint Subscription Edition, 2019, and 2016.

Potential Impact

Attackers were able to access vulnerable SharePoint servers and deploy ASPX web shells, allowing them to execute code remotely and steal machine keys.

In practice, this meant attackers had full control of affected servers. They could create or delete files, install malicious tools, exfiltrate data, and potentially use the compromised system as a stepping stone to move deeper into the network. Attackers were later observed (trying) to deploy ransomware using this attack chain.

Detected IoCs

Over the weekend of the disclosure and the following week, multiple IoCs were shared that helped validate if a SharePoint server was targeted and/or compromised:

  • Dropped web shells
    • C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\LAYOUTS\spinstall0.aspx
    • Variants such as spinstall.aspx, spinstall1.aspx, or info3.aspx were (later, this is important) also observed on compromised servers.
  • Unusual HTTP patterns
    • POST requests to _layouts/15/ToolPane.aspx with a referer to _layouts/SignOut.aspx.
  • Process behavior
    • w3wp.exe (the IIS worker process) spawning cmd.exe, which spawns powershell.exe with the -EncodedCommand flag

Together, these IoCs provide valuable hunting possibilities. But as the next section highlights, focusing only on file names or paths risks missing the bigger picture: attackers adapt quickly. Abnormal process behavior often remains the more reliable signal.

Lessons learned

Based on this incident, the response, and public information available, there are some lessons learned that need to be highlighted.

Lesson 1: Assume a breach will happen

By the time the SharePoint zero-day was disclosed, exploitation had already been underway for several days. Attackers had dropped web shells and established persistence, while defenders were still trying to understand what was going on.

This makes one point very clear: no matter how strong your defenses are, you cannot stop everything. Zero-days give attackers a head start, and it is not realistic to expect prevention to cover all scenarios.

The real preparation lies in assuming that breaches will happen. Prepare your responses as such and train them often enough.

Lesson 2: Focus on behavior, not simple IoCs.

This lesson demands a mandatory reference to the Pyramid of Pain, describing an increased level of difficulty for attackers as defenders move from detecting simple indicators like file hashes (or file names) toward detecting behaviors and techniques. The higher up the pyramid you operate, the more costly it becomes for an attacker to adapt.

When Microsoft first published detection guidance, it focused on the known web shell filename spinstall0.aspx. That type of detection is fragile because attackers can easily change file names, which is exactly what happened in this case. Attackers have been seen using variations of this filename, which would bypass this detection method.

DeviceFileEvents
| where FolderPath has_any (@'microsoft shared\Web Server Extensions\16\TEMPLATE\LAYOUTS', @'microsoft shared\Web Server Extensions\15\TEMPLATE\LAYOUTS')
| where FileName has "spinstall0"
| project Timestamp, DeviceName, InitiatingProcessFileName, InitiatingProcessCommandLine, FileName, FolderPath, ReportId, ActionType, SHA256
| order by Timestamp desc

A more effective approach is to look for the creation of any .aspx files, scoped to the TEMPLATE\LAYOUTS directory. This broader detection method increases the chance of catching attacker deviations and reduces the risk of missing activity just because the filename was changed.

Microsoft also published a second detection method focused on abnormal process behavior. It flagged cases where w3wp.exe spawned cmd.exe, which then launched powershell with an encoded command. However, the suggested query still relied on filters for specific command-line arguments and hard-coded references to the spinstall0 filename or the TEMPLATE\LAYOUTS folder.

DeviceProcessEvents
| where InitiatingProcessFileName has "w3wp.exe"
 and InitiatingProcessCommandLine !has "DefaultAppPool"
 and FileName =~ "cmd.exe"
 and ProcessCommandLine has_all ("cmd.exe", "powershell")
 and ProcessCommandLine has_any ("EncodedCommand", "-ec")
| extend CommandArguments = split(ProcessCommandLine, " ")
| mv-expand CommandArguments to typeof(string)
| where CommandArguments matches regex "^[A-Za-z0-9+/=]{15,}$"
| extend B64Decode = replace("\\x00", "", base64_decodestring(tostring(CommandArguments)))  
| where B64Decode has_any ("spinstall0", @'C:\PROGRA~1\COMMON~1\MICROS~1\WEBSER~1\15\TEMPLATE\LAYOUTS', @'C:\PROGRA~1\COMMON~1\MICROS~1\WEBSER~1\16\TEMPLATE\LAYOUTS')

Looking at abnormal processes is a strong approach for detecting the initial exploit, because at that stage the processes themselves cannot yet be tampered with. However, relying on hard-coded filenames or folder paths weakens the detection. A better method is to alert on any instance of cmd.exe being spawned by w3wp.exe and then tune the query to filter out known false positives.

Lesson 3: Scoping and root cause analysis

This is a lesson that is often emphasized when discussing the incident response cycle at SANS: scoping and root cause analysis are central to handling incidents effectively.

When vendors updated their signatures and began alerting on exploit behavior, it was tempting to jump straight into investigation, containment, and remediation. The security software had raised the alarm and removed the malicious file, so everything should be fine, right?

Not quite. Alerts started appearing over the weekend, but checking the creation time of the malicious file showed it had been placed days earlier. That meant the compromise was real and the web shell had been active the entire time. Realizing this changes the entire investigation and forces a broader timeframe for analysis. It also changed the narrative from ‘attempted but blocked exploit’ to ‘confirmed compromise and activate incident response procedures’.

Lesson 4: Incidents always happen on weekends

There is an unwritten rule in incident response: if something is going to happen, it will happen on a weekend. The SharePoint case followed that rule perfectly, with alerts and escalations landing when many people were away.

On a lighter note, it is almost a cliché at this point, but it carries a serious reminder. Incident response does not follow office hours. Having playbooks ready, on-call coverage in place, and clear escalation paths can make the difference between a quick containment and a drawn-out compromise.

While the timing is frustrating, planning for weekend incidents has to be part of the job.

Conclusion

The SharePoint zero-day showed once again that incidents never arrive at a convenient time, and often prefer weekends. It also highlighted a few important lessons. Breaches will happen, so preparation matters. Hunting for behaviors is more effective than chasing fragile IoCs. Proper scoping and root cause analysis prevent responders from missing the bigger picture. And finally, we should expect that incidents will happen outside office hours and plan accordingly.

Each of these points may sound simple, but they are the foundation of strong incident response. Every case like this one is a chance to practice, reflect, and walk away better prepared for the next time.

Author: