Thread Local Storage
Adversaries may inject malicious code into processes via thread local storage (TLS) callbacks in order to evade process-based defenses as well as possibly elevate privileges. TLS callback injection involves manipulating pointers inside a portable executable (PE) to redirect a process to malicious code before reaching the code's legitimate entry point. TLS callbacks are normally used by the OS to setup and/or cleanup data used by threads. Manipulating TLS callbacks may be performed by allocating and writing to specific offsets within a process' memory space using other Process Injection techniques such as Process Hollowing.
// Detect TLS callback abuse indicators
// TLS callbacks execute before the main entry point - look for suspicious process behavior
// immediately after creation (network connections, file writes before expected initialization)
DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName in~ ("svchost.exe", "rundll32.exe", "regsvr32.exe", "dllhost.exe", "explorer.exe")
| where InitiatingProcessFileName !in~ ("services.exe", "svchost.exe", "explorer.exe", "winlogon.exe")
| join kind=inner (
DeviceNetworkEvents
| where Timestamp > ago(24h)
| where RemoteIPType == "Public"
| project NetTime=Timestamp, DeviceName, InitiatingProcessId, RemoteIP, RemotePort, RemoteUrl
) on DeviceName, $left.ProcessId == $right.InitiatingProcessId
| where datetime_diff('second', NetTime, Timestamp) between (0 .. 5)
| project Timestamp, NetTime, DeviceName, AccountName, InitiatingProcessFileName, FileName, RemoteIP, RemotePort, RemoteUrl
| sort by Timestamp desc Data Sources
Required Tables
False Positives
- Legitimate software with TLS callbacks for license verification or telemetry on startup
- Auto-update mechanisms that check for updates immediately on process start
- Browser processes establishing connections to configured home pages immediately on launch
- Cloud-connected applications that authenticate on startup
References (4)
- https://attack.mitre.org/techniques/T1055/005/
- https://www.fireeye.com/blog/threat-research/2017/11/ursnif-variant-malicious-tls-callback-technique.html
- https://www.endgame.com/blog/technical-blog/ten-process-injection-techniques-technical-survey-common-and-trending-process
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1055.005/T1055.005.md
Unlock Pro Content
Get the full detection package for T1055.005 including response playbook, investigation guide, and atomic red team tests.