Detect ClickOnce in IBM QRadar
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/
QRadar Detection Query
SELECT
DATEFORMAT(starttime, 'yyyy-MM-dd HH:mm:ss') AS event_time,
logsourcename(logsourceid) AS log_source,
sourceip,
username,
"Image" AS process_image,
"CommandLine" AS command_line,
"ParentImage" AS parent_image,
"TargetFilename" AS target_filename,
"DestinationIp" AS destination_ip,
"DestinationPort" AS destination_port,
CASE
WHEN LOWER("ParentImage") LIKE '%dfsvc.exe%' AND
LOWER("Image") SIMILAR TO '%(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)%'
THEN 'DfsvcSuspiciousChild'
WHEN LOWER("Image") LIKE '%rundll32.exe%' AND
(LOWER("CommandLine") LIKE '%dfshim%' OR LOWER("CommandLine") LIKE '%shopenverbapplication%')
THEN 'RundllDfshimAbuse'
WHEN LOWER("Image") LIKE '%dfsvc.exe%' AND
"DestinationIp" IS NOT NULL AND
NOT ("DestinationIp" LIKE '10.%' OR
"DestinationIp" LIKE '192.168.%' OR
"DestinationIp" LIKE '127.%' OR
LONG(SPLIT("DestinationIp", '.', 1)) BETWEEN 172 AND 172 AND
LONG(SPLIT("DestinationIp", '.', 2)) BETWEEN 16 AND 31)
THEN 'DfsvcOutboundNetwork'
WHEN (LOWER("TargetFilename") LIKE '%.appref-ms%' OR LOWER("TargetFilename") LIKE '%.application%') AND
(LOWER("TargetFilename") LIKE '%startup%' OR
LOWER("TargetFilename") LIKE '%\\temp\\%' OR
LOWER("TargetFilename") LIKE '%\\tmp\\%' OR
LOWER("TargetFilename") LIKE '%\\downloads\\%')
THEN 'ApprefSuspiciousLocation'
ELSE 'Unknown'
END AS detection_branch
FROM events
WHERE
LOGSOURCETYPENAME(devicetype) LIKE '%Windows%'
AND starttime > NOW() - 86400000
AND (
/* Branch 1 */
(LOWER("ParentImage") LIKE '%dfsvc.exe%' AND
LOWER("Image") SIMILAR TO '%(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 */
(LOWER("Image") LIKE '%rundll32.exe%' AND
(LOWER("CommandLine") LIKE '%dfshim%' OR LOWER("CommandLine") LIKE '%shopenverbapplication%'))
OR
/* Branch 3 */
(LOWER("Image") LIKE '%dfsvc.exe%' AND
"DestinationIp" IS NOT NULL AND
NOT ("DestinationIp" LIKE '10.%' OR "DestinationIp" LIKE '192.168.%' OR "DestinationIp" LIKE '127.%'))
OR
/* Branch 4 */
((LOWER("TargetFilename") LIKE '%.appref-ms%' OR LOWER("TargetFilename") LIKE '%.application%') AND
(LOWER("TargetFilename") LIKE '%startup%' OR LOWER("TargetFilename") LIKE '%\\temp\\%' OR
LOWER("TargetFilename") LIKE '%\\tmp\\%' OR LOWER("TargetFilename") LIKE '%\\downloads\\%'))
)
ORDER BY starttime DESC QRadar AQL detection for ClickOnce (T1127.002) abuse covering: DFSVC.EXE spawning LOLBin children (RiskScore 80), rundll32.exe loading dfshim.dll (RiskScore 90), DFSVC.EXE outbound public network connections (RiskScore 60), and .appref-ms/.application files in startup or temp paths (RiskScore 70). Correlates Sysmon process create (Event 1), network (Event 3), and file create (Event 11) events.
Data Sources
Required Tables
False Positives & Tuning
- Enterprise software provisioning systems that deploy applications via ClickOnce and invoke post-install scripts through DFSVC.EXE
- Developer workstations where .NET developers frequently test ClickOnce-packaged applications and dfshim.dll invocations are routine
- Update mechanisms for legitimate ClickOnce-distributed business applications that connect outbound to vendor update servers
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.