Detect Code Signing in IBM QRadar
Adversaries may create, acquire, or steal code signing materials to sign their malware or tools. Code signing provides a level of authenticity on a binary from the developer and a guarantee that the binary has not been tampered with. Valid signatures can bypass security policies requiring signed code to execute, making this technique effective for defense evasion. Threat actors including FIN7, Scattered Spider, Kimsuky, and Patchwork have all leveraged purchased, stolen, or self-signed certificates to make malicious binaries appear legitimate.
MITRE ATT&CK
- Tactic
- Defense Evasion
- Technique
- T1553 Subvert Trust Controls
- Sub-technique
- T1553.002 Code Signing
- Canonical reference
- https://attack.mitre.org/techniques/T1553/002/
QRadar Detection Query
SELECT
DATEFORMAT(devicetime, 'yyyy-MM-dd HH:mm:ss') AS event_time,
logsourcename(logsourceid) AS log_source,
CATEGORYNAME(category) AS event_category,
username,
sourceip,
"Process Name",
"Command Line",
"Parent Process Name",
CASE
WHEN LOWER("Process Name") LIKE '%signtool.exe%'
AND (LOWER("Command Line") LIKE '% /sign%' OR LOWER("Command Line") LIKE '% -sign%'
OR LOWER("Command Line") LIKE '% /f %' OR LOWER("Command Line") LIKE '% /tr %'
OR LOWER("Command Line") LIKE '%sha256%')
THEN 'SigntoolSigning'
WHEN LOWER("Process Name") LIKE '%certutil.exe%'
AND (LOWER("Command Line") LIKE '%-addstore%' OR LOWER("Command Line") LIKE '%-addcert%'
OR LOWER("Command Line") LIKE '%-importpfx%' OR LOWER("Command Line") LIKE '%-p12%')
THEN 'CertutilImport'
WHEN (LOWER("File Path") LIKE '%.pfx' OR LOWER("File Path") LIKE '%.p12' OR LOWER("File Path") LIKE '%.cer')
AND (LOWER("File Path") LIKE '%\\temp\\%' OR LOWER("File Path") LIKE '%\\downloads\\%' OR LOWER("File Path") LIKE '%appdata%')
THEN 'SuspiciousCertFileCreation'
WHEN LOWER("Registry Key") LIKE '%\\root\\certificates%'
OR LOWER("Registry Key") LIKE '%\\trustedpublisher\\certificates%'
OR LOWER("Registry Key") LIKE '%systemcertificates\\root%'
THEN 'CertStoreRegistryMod'
ELSE 'Unknown'
END AS detection_type,
CASE
WHEN LOWER("Parent Process Name") IN ('cmd.exe','powershell.exe','pwsh.exe','wscript.exe','cscript.exe','mshta.exe','rundll32.exe','explorer.exe')
THEN 1 ELSE 0
END AS suspicious_parent,
CASE
WHEN LOWER("Command Line") LIKE '%.pfx%' OR LOWER("Command Line") LIKE '%.p12%'
THEN 1 ELSE 0
END AS has_pfx,
CASE
WHEN LOWER("Process Name") LIKE '%signtool.exe%'
AND LOWER("Command Line") NOT LIKE '%/tr%' AND LOWER("Command Line") NOT LIKE '%-tr%'
THEN 1 ELSE 0
END AS self_signed
FROM events
WHERE
devicetime > (NOW() - 86400000)
AND (
(LOWER("Process Name") LIKE '%signtool.exe%' AND
(LOWER("Command Line") LIKE '% /sign%' OR LOWER("Command Line") LIKE '% -sign%'
OR LOWER("Command Line") LIKE '%sha256%' OR LOWER("Command Line") LIKE '%/tr%'))
OR
(LOWER("Process Name") LIKE '%certutil.exe%' AND
(LOWER("Command Line") LIKE '%-addstore%' OR LOWER("Command Line") LIKE '%-addcert%'
OR LOWER("Command Line") LIKE '%-importpfx%' OR LOWER("Command Line") LIKE '%trustedpublisher%'
OR LOWER("Command Line") LIKE '%-p12%'))
OR
((LOWER("File Path") LIKE '%.pfx' OR LOWER("File Path") LIKE '%.p12' OR LOWER("File Path") LIKE '%.cer')
AND (LOWER("File Path") LIKE '%\\temp\\%' OR LOWER("File Path") LIKE '%\\downloads\\%'
OR LOWER("File Path") LIKE '%appdata%' OR LOWER("File Path") LIKE '%\\public\\%'))
OR
(LOWER("Registry Key") LIKE '%root\\certificates%'
OR LOWER("Registry Key") LIKE '%trustedpublisher\\certificates%'
OR LOWER("Registry Key") LIKE '%authroot\\certificates%')
)
ORDER BY devicetime DESC
LIMIT 1000 AQL detection for T1553.002 Code Signing abuse covering signtool.exe signing invocations, certutil.exe certificate imports into trusted stores, suspicious certificate file creation in user-writable paths, and registry modifications to Windows certificate trust stores. Uses QRadar custom event properties for process and command line fields.
Data Sources
Required Tables
False Positives & Tuning
- Enterprise software packaging teams running signtool.exe as part of automated build and release pipelines, especially from build servers where explorer.exe or cmd.exe may be the parent
- Certificate Lifecycle Management (CLM) tools such as Venafi or DigiCert KeyLocker that programmatically import PFX bundles into the Windows certificate store
- Windows Update (wuauclt.exe) and WSUS deployments that occasionally write to the AuthRoot and ROOT certificate stores as part of scheduled root certificate updates
Other platforms for T1553.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 1Create and Use a Self-Signed Code Signing Certificate
Expected signal: Sysmon Event ID 1: Process Create for powershell.exe with New-SelfSignedCertificate in command line. Sysmon Event ID 1: Process Create for signtool.exe with command line containing '/sign', '/f', '.pfx', '/fd sha256', and the target binary path. Sysmon Event ID 11: File creation events for df00tech-codesign.pfx and df00tech-test.exe in %TEMP%. PowerShell ScriptBlock Log Event ID 4104 with the New-SelfSignedCertificate and Export-PfxCertificate commands.
- Test 2Import Self-Signed Certificate into Trusted Publishers Store
Expected signal: Sysmon Event ID 1: Process Create for certutil.exe with CommandLine containing '-addstore TrustedPublisher'. Sysmon Event ID 11: File creation for df00tech-publisher.cer in %TEMP%. Sysmon Event ID 13 (Registry Value Set): new value under HKLM\SOFTWARE\Microsoft\SystemCertificates\TrustedPublisher\Certificates\ keyed by the certificate thumbprint. PowerShell ScriptBlock Log Event ID 4104 for the New-SelfSignedCertificate commands.
- Test 3Verify Signed Binary Execution Trust (Authenticode Check Bypass Simulation)
Expected signal: Sysmon Event ID 1: Process Create for certutil.exe with '-addstore -user TrustedPublisher'. Sysmon Event ID 11: File creation events for df00tech-sign-test.cer and df00tech-payload.ps1 in %TEMP%. Sysmon Event ID 13: Registry modification under HKCU\SOFTWARE\Microsoft\SystemCertificates\TrustedPublisher\Certificates (user-store variant). PowerShell ScriptBlock Log Event ID 4104 for Set-AuthenticodeSignature cmdlet execution.
- Test 4macOS Ad-Hoc Code Signing
Expected signal: macOS Unified Log: codesign process execution with '--sign -' arguments visible in process audit logs. Endpoint Security Framework events for ES_EVENT_TYPE_NOTIFY_EXEC when codesign runs. Security.framework log entries in /var/log/system.log for code signing operations. If EDR is present (CrowdStrike, SentinelOne): process creation event for codesign with suspicious ad-hoc signing arguments. spctl execution generates Gatekeeper assessment log entries in /var/log/system.log.
References (11)
- https://attack.mitre.org/techniques/T1553/002/
- https://eclecticlight.co/2020/11/16/checks-on-executable-code-in-catalina-and-big-sur-a-first-draft/
- https://securelist.com/why-you-shouldnt-completely-trust-files-signed-with-digital-certificates/68593/
- http://www.symantec.com/connect/blogs/how-attackers-steal-private-keys-digital-certificates
- https://en.wikipedia.org/wiki/Code_signing
- https://learn.microsoft.com/en-us/windows/win32/seccrypto/signtool
- https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/certutil
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1553.002/T1553.002.md
- https://blog.talosintelligence.com/2020/09/cobalt-strike-paper.html
- https://www.crowdstrike.com/blog/scattered-spider-byovd-exploits/
- https://unit42.paloaltonetworks.com/backconfig-malware-targeting-government-military/
Unlock Pro Content
Get the full detection package for T1553.002 including response playbook, investigation guide, and atomic red team tests.