ClickOnce
Adversaries may use ClickOnce applications (.appref-ms and .application files) to proxy execution of malicious code through DFSVC.EXE, a trusted Windows utility responsible for installing, launching, and updating ClickOnce .NET applications. Because ClickOnce applications operate under limited permissions, they do not require administrative privileges to install, making them attractive for unprivileged execution. Abuse vectors include: luring users to install trojanized ClickOnce apps from malicious websites, invoking ClickOnce directly via rundll32.exe with dfshim.dll,ShOpenVerbApplication1, and placing .appref-ms files in startup folders for persistence.
// Branch 1: DFSVC.EXE spawning suspicious child processes
let SuspiciousChildren = dynamic([
"cmd.exe", "powershell.exe", "pwsh.exe", "mshta.exe", "wscript.exe",
"cscript.exe", "regsvr32.exe", "rundll32.exe", "certutil.exe",
"bitsadmin.exe", "msbuild.exe", "csc.exe", "installutil.exe"
]);
let ClickOnceExec = DeviceProcessEvents
| where Timestamp > ago(24h)
| where InitiatingProcessFileName =~ "dfsvc.exe"
| where FileName in~ (SuspiciousChildren)
| extend DetectionBranch = "DfsvcSuspiciousChild"
| extend RiskScore = 80;
// Branch 2: rundll32.exe invoking dfshim.dll ClickOnce loader
let DfshimAbuse = DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName =~ "rundll32.exe"
| where ProcessCommandLine has_any ("dfshim", "ShOpenVerbApplication")
| extend DetectionBranch = "RundllDfshimAbuse"
| extend RiskScore = 90;
// Branch 3: DFSVC.EXE making outbound network connections
let DfsvcNetwork = DeviceNetworkEvents
| where Timestamp > ago(24h)
| where InitiatingProcessFileName =~ "dfsvc.exe"
| where RemoteIPType == "Public"
| extend DetectionBranch = "DfsvcOutboundNetwork"
| extend RiskScore = 60
| project Timestamp, DeviceName, AccountName,
FileName = InitiatingProcessFileName,
ProcessCommandLine = InitiatingProcessCommandLine,
InitiatingProcessFileName = "",
InitiatingProcessCommandLine = "",
DetectionBranch, RiskScore,
RemoteUrl, RemoteIP, RemotePort;
// Branch 4: .appref-ms files written to startup or temp locations
let ApprefInStartup = DeviceFileEvents
| where Timestamp > ago(24h)
| where FileName endswith ".appref-ms" or FileName endswith ".application"
| where FolderPath has_any (
"\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup",
"\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\Startup",
"\\Temp\\", "\\tmp\\", "\\Downloads\\"
)
| extend DetectionBranch = "ApprefSuspiciousLocation"
| extend RiskScore = 70
| project Timestamp, DeviceName, AccountName = RequestAccountName,
FileName, ProcessCommandLine = InitiatingProcessCommandLine,
InitiatingProcessFileName, InitiatingProcessCommandLine,
DetectionBranch, RiskScore,
RemoteUrl = "", RemoteIP = "", RemotePort = int(null);
union kind=outer
(ClickOnceExec | project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine, InitiatingProcessFileName, InitiatingProcessCommandLine, DetectionBranch, RiskScore, RemoteUrl="", RemoteIP="", RemotePort=int(null)),
DfshimAbuse | project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine, InitiatingProcessFileName, InitiatingProcessCommandLine, DetectionBranch, RiskScore, RemoteUrl="", RemoteIP="", RemotePort=int(null),
DfsvcNetwork,
ApprefInStartup
| sort by Timestamp desc Data Sources
Required Tables
False Positives
- Legitimate enterprise ClickOnce applications (internal LOB apps deployed via SharePoint or intranet) where DFSVC.EXE spawns an expected child process
- Software update mechanisms that use ClickOnce for self-updating .NET desktop applications (e.g., Visual Studio extensions, internal tooling)
- Development environments where developers test ClickOnce packages locally, causing DFSVC.EXE network activity to localhost or internal servers
- IT deployment tools that distribute .appref-ms shortcuts to user desktops or startup folders as part of legitimate software rollout
References (7)
- https://attack.mitre.org/techniques/T1127/002/
- https://lolbas-project.github.io/lolbas/Binaries/Dfsvc/
- https://learn.microsoft.com/en-us/visualstudio/deployment/clickonce-security-and-deployment?view=vs-2022
- https://posts.specterops.io/less-smartscreen-more-caffeine-ab-using-clickonce-for-trusted-code-execution-1446ea8051c5
- https://www.netspi.com/blog/technical-blog/adversary-simulation/all-you-need-is-one-a-clickonce-love-story/
- https://i.blackhat.com/USA-19/Wednesday/us-19-Burke-ClickOnce-And-Youre-In-When-Appref-Ms-Abuse-Is-Operating-As-Intended-wp.pdf
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1127.002/T1127.002.md
Unlock Pro Content
Get the full detection package for T1127.002 including response playbook, investigation guide, and atomic red team tests.