Atlantiraptor Docs

Cloud.M365.MassDownload

Type: Server

Hunts the SharePoint and OneDrive audit log for data theft: accounts that downloaded or synced an unusual number of files within an hour. Attackers who take over an account, and staff on their way out, often pull whole document libraries.

Reads the unified audit log (7 days). Needs the Office 365 Management APIs ActivityFeed.Read permission.

Parameters

Name Type Default Description
M365Secret string Name of the “Microsoft 365 Creds” secret for the tenant.
LookbackHours int 168 At most 168 (the API keeps 7 days).
FilesPerHour int 300 Report an account that downloaded at least this many files in one hour.
Operations regex ^(FileDownloaded\|FileSyncDownloadedFull\|FileSyncDownloadedPartial\|FileCopied)$

Source

Defined in artifacts/definitions/Cloud/M365/MassDownload.yaml.

name: Cloud.M365.MassDownload
description: |
  Hunts the SharePoint and OneDrive audit log for data theft: accounts
  that downloaded or synced an unusual number of files within an hour.
  Attackers who take over an account, and staff on their way out,
  often pull whole document libraries.

  Reads the unified audit log (7 days). Needs the Office 365 Management
  APIs `ActivityFeed.Read` permission.

type: SERVER

parameters:
  - name: M365Secret
    description: Name of the "Microsoft 365 Creds" secret for the tenant.
  - name: LookbackHours
    type: int
    default: 168
    description: At most 168 (the API keeps 7 days).
  - name: FilesPerHour
    type: int
    default: 300
    description: Report an account that downloaded at least this many files in one hour.
  - name: Operations
    type: regex
    default: "^(FileDownloaded|FileSyncDownloadedFull|FileSyncDownloadedPartial|FileCopied)$"

sources:
  - query: |
      LET WindowStart <= now() - LookbackHours * 3600

      LET Downloads = SELECT timestamp(string=CreationTime).Unix AS Epoch,
             UserId AS User, ClientIP AS IPAddress, SiteUrl, SourceFileName, UserAgent
      FROM m365_audit(secret=M365Secret, content_type="Audit.SharePoint",
                      start=timestamp(epoch=WindowStart))
      WHERE Operation =~ Operations

      LET PerHour = SELECT User, int(int=Epoch / 3600) AS Hour, count() AS Files,
             enumerate(items=SiteUrl) AS Sites, enumerate(items=IPAddress) AS IPs,
             enumerate(items=SourceFileName) AS Names, UserAgent, min(item=Epoch) AS First
      FROM Downloads
      GROUP BY User, Hour

      SELECT timestamp(epoch=First) AS Time,
             if(condition=Files >= FilesPerHour * 3, then="high", else="medium") AS Severity,
             "Mass file download" AS Detection,
             User, IPs[0] AS IPAddress, "" AS Location, "" AS Device,
             dict(FilesInHour=Files,
                  Sites=items(item=to_dict(item={SELECT _value AS _key, 1 AS _value FROM foreach(row=Sites)}))._key,
                  Addresses=items(item=to_dict(item={SELECT _value AS _key, 1 AS _value FROM foreach(row=IPs)}))._key,
                  SampleFiles=Names[:20], UserAgent=UserAgent) AS Details
      FROM PerHour
      WHERE Files >= FilesPerHour

Edit this page on GitHub

© 2026 Atlant Security EOOD. Atlantiraptor is free software under the GNU Affero General Public License v3. It is based on Velociraptor by Velocidex, and keeps its copyright notices. Velociraptor is a trademark of its owner; Atlantiraptor is not affiliated with or endorsed by it.