Detect Code Signing in Splunk
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/
SPL Detection Query
index=wineventlog (
(sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=1)
OR (sourcetype="WinEventLog:Security" EventCode=4688)
)
| eval Process=coalesce(Image, NewProcessName)
| eval CommandLine=coalesce(CommandLine, ProcessCommandLine)
| eval ParentProcess=coalesce(ParentImage, ParentProcessName)
| eval LowerCmdLine=lower(CommandLine)
| eval LowerProcess=lower(Process)
(
[
search sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=1
| eval LowerProcess=lower(Image)
| where match(LowerProcess, "(signtool\.exe|certutil\.exe)")
]
OR
[
search sourcetype="WinEventLog:Security" EventCode=4688
| eval LowerProcess=lower(NewProcessName)
| where match(LowerProcess, "(signtool\.exe|certutil\.exe)")
]
)
| eval IsSigntool=if(match(LowerProcess, "signtool\.exe"), 1, 0)
| eval IsCertutil=if(match(LowerProcess, "certutil\.exe"), 1, 0)
| eval SigntoolSignCmd=if(IsSigntool=1 AND match(LowerCmdLine, "(\\-sign|/sign)"), 1, 0)
| eval CertImport=if(IsCertutil=1 AND match(LowerCmdLine, "(\-addstore|\-addcert|\-importpfx|\-p12)"), 1, 0)
| eval TrustedStoreTarget=if(IsCertutil=1 AND match(LowerCmdLine, "(root|trustedpublisher|authroot)"), 1, 0)
| eval HasPFX=if(match(LowerCmdLine, "(\.pfx|\.p12)"), 1, 0)
| eval SelfSigned=if(IsSigntool=1 AND NOT match(LowerCmdLine, "(\-tr|/tr)"), 1, 0)
| eval SuspiciousParent=if(match(lower(ParentProcess), "(cmd\.exe|powershell\.exe|pwsh\.exe|wscript\.exe|cscript\.exe|mshta\.exe|rundll32\.exe|explorer\.exe)"), 1, 0)
| eval RiskScore=SigntoolSignCmd + CertImport + TrustedStoreTarget + HasPFX + SelfSigned + SuspiciousParent
| where RiskScore > 0
| eval User=coalesce(User, SubjectUserName)
| table _time, host, User, Process, CommandLine, ParentProcess,
IsSigntool, IsCertutil, SigntoolSignCmd, CertImport, TrustedStoreTarget,
HasPFX, SelfSigned, SuspiciousParent, RiskScore
| sort - _time
| appendcols
[search index=wineventlog sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=11
(TargetFilename="*.pfx" OR TargetFilename="*.p12" OR TargetFilename="*.cer")
(TargetFilename="*\\Temp\\*" OR TargetFilename="*\\Downloads\\*" OR TargetFilename="*AppData*" OR TargetFilename="*\\Public\\*")
| eval DetectionType="SuspiciousCertFileCreation"
| table _time, host, User, Image, TargetFilename, DetectionType
| rename Image as Process, TargetFilename as CommandLine] Detects code signing certificate abuse using Sysmon Event ID 1 (Process Create) and Windows Security Event ID 4688 for signtool.exe and certutil.exe invocations related to signing operations, certificate imports, and trusted store modifications. Assigns a cumulative risk score based on multiple indicators: signing command, certificate import flags, trusted store targeting, PFX file references, self-signing patterns, and suspicious parent processes. Also appends Sysmon Event ID 11 (File Create) results for certificate files created in suspicious user-writable directories.
Data Sources
Required Sourcetypes
False Positives & Tuning
- Developer build pipelines invoking signtool.exe from PowerShell or cmd.exe as part of automated release processes on build agents
- Enterprise PKI administrators importing intermediate CA or root certificates via certutil.exe for corporate certificate hierarchy management
- Software vendor installers that embed and register product-specific certificates during installation sequences
- Windows Update and WSUS processes that silently update the trusted root CA store via svchost.exe — this should be excluded by the SuspiciousParent filter but may require tuning
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.