Detect Code Signing in Elastic Security
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/
Elastic Detection Query
sequence by host.name with maxspan=5m
[process where event.type == "start" and
(process.name : "signtool.exe" or process.name : "certutil.exe") and
(
(process.name : "signtool.exe" and process.args : ("/sign", "-sign", "/f", "-f", "/p", "-p", "/fd", "-fd", "/tr", "-tr", "sha256", "sha1")) or
(process.name : "certutil.exe" and process.args : ("-addstore", "-addcert", "-importpfx", "-p12", "MY", "Root", "TrustedPublisher"))
)
] by process.pid
| where process.parent.name : ("cmd.exe", "powershell.exe", "pwsh.exe", "wscript.exe", "cscript.exe", "mshta.exe", "rundll32.exe", "explorer.exe")
any where event.category == "file" and
file.extension : ("pfx", "p12", "cer", "crt") and
file.path : ("*\\Temp\\*", "*\\Downloads\\*", "*\\AppData\\Local\\*", "*\\AppData\\Roaming\\*", "*\\Users\\Public\\*", "*\\ProgramData\\*")
any where event.category == "registry" and
event.type == "change" and
registry.path : (
"*\\ROOT\\Certificates\\*",
"*\\TrustedPublisher\\Certificates\\*",
"*\\AuthRoot\\Certificates\\*",
"HKLM\\SOFTWARE\\Microsoft\\SystemCertificates\\ROOT\\*",
"HKLM\\SOFTWARE\\Microsoft\\SystemCertificates\\TrustedPublisher\\*"
) and
not process.name : ("certutil.exe", "mmc.exe", "wuauclt.exe", "TrustedInstaller.exe", "svchost.exe") Detects T1553.002 Code Signing abuse via signtool.exe or certutil.exe invocations from suspicious parent processes, certificate file creation in temp/user-writable paths, and unauthorized modifications to trusted certificate stores. Covers all four detection pillars: process execution, cert file drops, and registry-based cert store tampering.
Data Sources
Required Tables
False Positives & Tuning
- Legitimate software developers using signtool.exe to sign internal binaries during build pipelines — especially if the parent process is a CI/CD agent like jenkins.exe or msbuild.exe
- IT administrators importing enterprise CA certificates into trusted stores using certutil.exe as part of MDM or Group Policy certificate deployment
- Antivirus or endpoint security tools that create .pfx or .cer files during certificate pinning or local proxy inspection setup
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.