Detect ClickOnce in Google Chronicle
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.
MITRE ATT&CK
- Tactic
- Defense Evasion
- Sub-technique
- T1127.002 ClickOnce
- Canonical reference
- https://attack.mitre.org/techniques/T1127/002/
YARA-L Detection Query
rule clickonce_dfsvc_abuse_t1127002 {
meta:
author = "Argus Detection Engineering"
description = "Detects ClickOnce (T1127.002) abuse: DFSVC.EXE spawning LOLBin children, rundll32 loading dfshim.dll, DFSVC.EXE outbound network, and .appref-ms persistence"
mitre_attack_tactic = "Defense Evasion"
mitre_attack_technique = "T1127.002"
severity = "HIGH"
confidence = "HIGH"
events:
(
/* Branch 1: DFSVC.EXE spawning suspicious child processes */
(
$e.metadata.event_type = "PROCESS_LAUNCH"
and re.regex($e.principal.process.file.full_path, `(?i)dfsvc\.exe$`)
and re.regex($e.target.process.file.full_path,
`(?i)(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)$`)
)
or
/* Branch 2: rundll32.exe invoking dfshim.dll ShOpenVerbApplication */
(
$e.metadata.event_type = "PROCESS_LAUNCH"
and re.regex($e.target.process.file.full_path, `(?i)rundll32\.exe$`)
and (
re.regex($e.target.process.command_line, `(?i)dfshim`) or
re.regex($e.target.process.command_line, `(?i)ShOpenVerbApplication`)
)
)
or
/* Branch 3: DFSVC.EXE making outbound network connections to public IPs */
(
$e.metadata.event_type = "NETWORK_CONNECTION"
and re.regex($e.principal.process.file.full_path, `(?i)dfsvc\.exe$`)
and not net.ip_in_range_cidr($e.target.ip, "10.0.0.0/8")
and not net.ip_in_range_cidr($e.target.ip, "172.16.0.0/12")
and not net.ip_in_range_cidr($e.target.ip, "192.168.0.0/16")
and not net.ip_in_range_cidr($e.target.ip, "127.0.0.0/8")
)
or
/* Branch 4: .appref-ms or .application files written to startup/temp */
(
$e.metadata.event_type = "FILE_CREATION"
and (
re.regex($e.target.file.full_path, `(?i)\.appref-ms$`) or
re.regex($e.target.file.full_path, `(?i)\.application$`)
)
and (
re.regex($e.target.file.full_path, `(?i)startup`) or
re.regex($e.target.file.full_path, `(?i)\\temp\\`) or
re.regex($e.target.file.full_path, `(?i)\\tmp\\`) or
re.regex($e.target.file.full_path, `(?i)\\downloads\\'`)
)
)
)
condition:
$e
} Chronicle YARA-L 2.0 rule detecting ClickOnce (T1127.002) proxy execution and persistence via four behavioral branches: DFSVC.EXE spawning LOLBin child processes, rundll32.exe loading dfshim.dll via ShOpenVerbApplication, DFSVC.EXE initiating outbound connections to non-RFC1918 addresses, and .appref-ms/.application files created in startup folders or temp/download paths.
Data Sources
Required Tables
False Positives & Tuning
- Enterprise-managed ClickOnce application deployments where DFSVC.EXE legitimately spawns PowerShell for custom post-install hooks defined by the application vendor
- Software packaging or repackaging tools that invoke rundll32.exe with dfshim.dll to convert or validate ClickOnce manifests in a development or QA environment
- SaaS applications distributed as ClickOnce packages that create .appref-ms files in the Downloads folder as part of a first-run user experience flow
Other platforms for T1127.002
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 1ClickOnce LOLBAS via Rundll32 dfshim.dll
Expected signal: Sysmon Event ID 1: Process Create with Image=rundll32.exe, CommandLine containing 'dfshim.dll,ShOpenVerbApplication1'. Sysmon Event ID 1: Child process DFSVC.EXE spawned by rundll32.exe. Sysmon Event ID 3: Network connection attempt from DFSVC.EXE to 127.0.0.1:8080. Security Event ID 4688 (if command line auditing enabled) for both rundll32.exe and dfsvc.exe.
- Test 2DFSVC.EXE Direct Invocation with Remote Manifest
Expected signal: Sysmon Event ID 1: Process Create for dfsvc.exe with command line containing the manifest URL. Sysmon Event ID 3: Outbound TCP connection attempt from dfsvc.exe to 127.0.0.1:8080. Windows Event Log Microsoft-Windows-ClickOnce/Operational: deployment activation event with the source URL.
- Test 3Malicious .appref-ms Placed in Startup Folder
Expected signal: Sysmon Event ID 11: File Create event with TargetFilename containing 'Startup\evil.appref-ms'. Sysmon Event ID 1: PowerShell process creating the file. The startup folder path will be: %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup\evil.appref-ms.
- Test 4ClickOnce Cache Enumeration Simulating Post-Install Reconnaissance
Expected signal: Sysmon Event ID 1: PowerShell process with command line showing ClickOnce cache enumeration. Sysmon Event ID 11: File creation of clickonce_enum.txt in %TEMP%. Multiple Sysmon Event ID 10 (Process Access) events as PowerShell reads binaries in the cache directory.
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.