The After-Hours Download Nobody Questioned
The login looked normal. The account was valid. MFA had already passed. No high-severity alert appeared.
But late at night, the same user account started downloading files from SharePoint and OneDrive. Not one file. Not two files. Dozens of files.
This Agent Foskett briefing shows how to use Microsoft Defender XDR and KQL to find after-hours file access patterns that may indicate data exposure, insider risk, compromised sessions or unusual user behaviour.
The goal is simple: stop treating “successful access” as automatically safe.
After-hours download summary
A practical Microsoft Defender investigation focused on SharePoint and OneDrive activity that looked legitimate until timing, volume and business context changed the story.
What we are looking for
Baseline query: after-hours SharePoint and OneDrive downloads
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
CloudAppEvents
| where Timestamp > ago(7d)
| where ActionType in ("FileDownloaded", "FileAccessed")
| where Application in ("Microsoft SharePoint Online", "Microsoft OneDrive for Business")
| extend HourOfDay = datetime_part("hour", Timestamp)
| where HourOfDay < 7 or HourOfDay > 18
| summarize
FileCount = count(),
UniqueFiles = dcount(ObjectName),
SitesAccessed = dcount(SiteUrl),
FirstSeen = min(Timestamp),
LastSeen = max(Timestamp)
by AccountDisplayName, AccountUpn, IPAddress, ActionType
| where FileCount > 25
| order by FileCount descWhat this activity can indicate
Query: investigate specific user behaviour
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
CloudAppEvents
| where Timestamp > ago(7d)
| where Application in ("Microsoft SharePoint Online", "Microsoft OneDrive for Business")
| where AccountUpn == "user@yourdomain.com"
| project
Timestamp,
AccountUpn,
ActionType,
ObjectName,
SiteUrl,
IPAddress
| order by Timestamp descQuery: correlate file activity with sign-ins
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
let SuspiciousUsers = CloudAppEvents | where Timestamp > ago(7d) | where ActionType == "FileDownloaded" | summarize FileCount = count() by AccountUpn | where FileCount > 25; SigninLogs | where Timestamp > ago(7d) | where UserPrincipalName in (SuspiciousUsers) | project Timestamp, UserPrincipalName, IPAddress, Location, AppDisplayName | order by Timestamp desc
Query: summary of unusual file access by site
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
CloudAppEvents
| where Timestamp > ago(14d)
| where ActionType in ("FileDownloaded", "FileAccessed")
| where Application in ("Microsoft SharePoint Online", "Microsoft OneDrive for Business")
| extend HourOfDay = datetime_part("hour", Timestamp)
| where HourOfDay < 7 or HourOfDay > 18
| summarize
Events = count(),
Users = dcount(AccountUpn),
Files = dcount(ObjectName)
by SiteUrl
| order by Events descContinue your investigation
Open guide →
View investigation →
Read more →
