Detect Taint Shared Content in Microsoft Sentinel
Adversaries may deliver payloads to remote systems by adding content to shared storage locations, such as network drives or internal code repositories. Content stored on network drives or in other shared locations may be tainted by adding malicious programs, scripts, or exploit code to otherwise valid files. Once a user opens the shared tainted content, the malicious portion can be executed to run the adversary's code on a remote system. Variants include the directory share pivot (planting malicious .LNK files that masquerade as legitimate directories), binary infection (prepending or appending code to legitimate executables on shares), and Office document macro injection (as seen with Gamaredon Group). Threat actors including Conti, Ursnif, Ramsay, InvisiMole, and RedCurl have all leveraged this technique for lateral movement.
MITRE ATT&CK
- Tactic
- Lateral Movement
- Technique
- T1080 Taint Shared Content
- Canonical reference
- https://attack.mitre.org/techniques/T1080/
KQL Detection Query
let SuspiciousExtensions = dynamic([".exe", ".dll", ".scr", ".bat", ".cmd", ".vbs", ".js", ".hta", ".ps1", ".lnk"]);
let KnownSafeSources = dynamic(["MsMpEng.exe", "msiexec.exe", "TrustedInstaller.exe", "wuauclt.exe", "svchost.exe"]);
// Signal 1: Executable or script written to a UNC network path
let ExecOnShare = DeviceFileEvents
| where Timestamp > ago(24h)
| where ActionType in ("FileCreated", "FileModified", "FileRenamed")
| where FolderPath startswith @"\\\\"
| extend FileExt = tolower(tostring(split(FileName, ".")[-1]))
| where strcat(".", FileExt) in~ (SuspiciousExtensions)
| where InitiatingProcessFileName !in~ (KnownSafeSources)
| extend Signal = "ExecOnNetworkShare";
// Signal 2: LNK file creation on a mapped or UNC share path (directory share pivot)
let LnkOnShare = DeviceFileEvents
| where Timestamp > ago(24h)
| where ActionType in ("FileCreated", "FileModified")
| where FileName endswith ".lnk" or FileName endswith ".LNK"
| where FolderPath startswith @"\\\\" or FolderPath matches regex @"[A-Z]:\\.*\\(share|shares|public|users|common|docs|dept|data)"
| where InitiatingProcessFileName !in~ (KnownSafeSources)
| extend Signal = "LnkOnNetworkShare";
// Signal 3: Office document with macro-enabled extension written to a network share (Gamaredon pattern)
let OfficeOnShare = DeviceFileEvents
| where Timestamp > ago(24h)
| where ActionType in ("FileCreated", "FileModified")
| where FileName endswith ".docm" or FileName endswith ".xlsm" or FileName endswith ".pptm"
or FileName endswith ".doc" or FileName endswith ".xls"
| where FolderPath startswith @"\\\\"
| where InitiatingProcessFileName !in~ (KnownSafeSources)
| extend Signal = "MacroOfficeOnShare";
// Combine signals
union ExecOnShare, LnkOnShare, OfficeOnShare
| extend FileExt = tolower(tostring(split(FileName, ".")[-1]))
| project Timestamp, DeviceName, AccountName, FileName, FolderPath, FileExt, Signal,
InitiatingProcessFileName, InitiatingProcessCommandLine,
InitiatingProcessAccountName, InitiatingProcessId
| sort by Timestamp desc Detects three variants of T1080 Taint Shared Content using Microsoft Defender for Endpoint DeviceFileEvents. Signal 1 catches executable and script files written to UNC network paths (\\server\share), covering Conti/Ursnif binary spreading. Signal 2 catches .LNK files created on network shares, covering the RedCurl/directory-share-pivot pattern. Signal 3 catches macro-enabled Office documents written to shares, covering the Gamaredon macro injection pattern. Filters exclude well-known system processes (MsMpEng, msiexec, TrustedInstaller) to reduce noise from legitimate software deployments.
Data Sources
Required Tables
False Positives & Tuning
- Software deployment via SCCM or PDQ Deploy copying installation packages (.exe, .msi) to deployment shares
- Backup agents or robocopy jobs replicating executables to archive network shares
- IT administrators legitimately copying scripts (.ps1, .bat) to shared script repositories or SYSVOL for GPO deployment
- Antivirus or EDR updates propagating via network share to air-gapped or slow-update endpoints
- DFS replication (DFSR) synchronizing executables and documents across site shares
- Development teams pushing compiled binaries to network-accessible build output directories
Other platforms for T1080
Testing Methodology
Validate this detection against 4 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.
- Test 1Copy Malicious Executable to Network Share (Conti/Ursnif Pattern)
Expected signal: Sysmon Event ID 11: TargetFilename=\\localhost\C$\Users\Public\svchost_update.exe, Image=cmd.exe or robocopy.exe/xcopy.exe. Sysmon Event ID 3: Network connection to localhost:445 from cmd.exe. Security Event ID 5145 on the target host: RelativeTargetName=Users\Public\svchost_update.exe, AccessMask including write/create. Security Event ID 5140: share \\*\C$ accessed.
- Test 2Plant Malicious LNK File on Network Share (Directory Share Pivot)
Expected signal: Sysmon Event ID 11: TargetFilename=\\localhost\C$\Users\Public\Shared Documents.lnk, Image=powershell.exe. DeviceFileEvents: FileName=Shared Documents.lnk, FolderPath=\\localhost\C$\Users\Public\, ActionType=FileCreated. If a user clicks the .LNK: Sysmon Event ID 1 with Image=cmd.exe, CommandLine containing the embedded payload, ParentImage=explorer.exe.
- Test 3Inject Macro into Office Document on Network Share (Gamaredon Pattern)
Expected signal: Sysmon Event ID 11: TargetFilename=\\localhost\C$\Users\Public\Q1_Budget_Review.docm, Image=powershell.exe. DeviceFileEvents: FileName=Q1_Budget_Review.docm, FolderPath starts with \\, ActionType=FileCreated. Security Event 5145 with RelativeTargetName=Users\Public\Q1_Budget_Review.docm and write access.
- Test 4Bulk Executable Spreading Across Multiple Shares (Worm Propagation Simulation)
Expected signal: Two Sysmon Event ID 11 entries: both with Image=cmd.exe and TargetFilename pointing to separate UNC share paths. Two Security Event 5145 entries on localhost for write to .exe on each share. DeviceFileEvents: two FileCreated events with distinct FolderPath values (different share names) from the same InitiatingProcessFileName within seconds.
References (10)
- https://attack.mitre.org/techniques/T1080/
- https://rewtin.blogspot.ch/2017/11/abusing-user-shares-for-efficient.html
- https://www.group-ib.com/resources/threat-research/red-curl.html
- https://www.welivesecurity.com/2020/06/11/gamaredon-group-grows-its-game/
- https://www.welivesecurity.com/2020/05/13/ramsay-cyberespionage-toolkit-airgapped-networks/
- https://www.cybereason.com/blog/conti-ransomware
- https://www.secureworks.com/research/bronze-butler-targets-japanese-businesses
- https://docs.microsoft.com/en-us/windows/security/threat-protection/auditing/event-5145
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1080/T1080.md
- https://learn.microsoft.com/en-us/defender-endpoint/advanced-hunting-devicefileevents-table
Unlock Pro Content
Get the full detection package for T1080 including response playbook, investigation guide, and atomic red team tests.