Detection rules › Elastic

Potential Initial Access via DLL Search Order Hijacking

Source
github.com/elastic/protections-artifacts

Identifies attempts to create a DLL file to a known desktop application dependencies folder such as Slack, Teams or OneDrive and by an unusual process. This may indicate an attempt to load a malicious module via DLL search order hijacking.

MITRE ATT&CK coverage

Rule body

[rule]
description = """
Identifies attempts to create a DLL file to a known desktop application dependencies folder such as Slack, Teams or
OneDrive and by an unusual process. This may indicate an attempt to load a malicious module via DLL search order
hijacking.
"""
id = "ddc4fa22-4675-44c0-a813-e786e638d7e0"
license = "Elastic License v2"
name = "Potential Initial Access via DLL Search Order Hijacking"
os_list = ["windows"]
reference = [
    "https://posts.specterops.io/automating-dll-hijack-discovery-81c4295904b0",
    "https://www.elastic.co/security-labs/Hunting-for-Suspicious-Windows-Libraries-for-Execution-and-Evasion",
]
version = "1.0.32"

query = '''
file where event.action != "deletion" and
 file.extension : "dll" and
 file.path :
        ("?:\\Users\\*\\AppData\\*\\Microsoft\\OneDrive\\*.dll",
         "?:\\Users\\*\\AppData\\*\\Microsoft OneDrive\\*.dll",
         "?:\\Users\\*\\AppData\\*\\Microsoft\\Teams\\*.dll",
         "?:\\Users\\*\\AppData\\Local\\slack\\app-*\\*.dll",
         "?:\\Users\\*\\AppData\\Local\\Programs\\Microsoft VS Code\\*",
         "?:\\Users\\*\\AppData\\Local\\*\\Well Known Domains\\*\\well_known_domains.dll",
         "?:\\Users\\*\\AppData\\Local\\*\\Domain Actions\\*\\domain_actions.dll") and
 process.name : ("winword.exe", "excel.exe", "powerpnt.exe", "MSACCESS.EXE", "MSPUB.EXE", "fltldr.exe", "cmd.exe",
                 "certutil.exe", "mshta.exe", "cscript.exe", "wscript.exe", "curl.exe", "powershell.exe", "pwsh.exe",
                 "mstsc.exe", "explorer.exe", "dllhost.exe", "xcopy.exe", "expand.exe") and
 not file.path : ("?:\\Users\\*\\AppData\\Local\\Microsoft\\OneDrive\\*\\*.dll",
                  "?:\\Users\\*\\AppData\\Local\\Microsoft\\Teams\\current\\resources\\meeting-addin\\*",
                  "?:\\Users\\*\\Teams\\current\\*")
'''

min_endpoint_version = "7.15.0"
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0

[[optional_actions]]
action = "rollback"
field = "process.entity_id"
state = 0

[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1566"
name = "Phishing"
reference = "https://attack.mitre.org/techniques/T1566/"
[[threat.technique.subtechnique]]
id = "T1566.001"
name = "Spearphishing Attachment"
reference = "https://attack.mitre.org/techniques/T1566/001/"



[threat.tactic]
id = "TA0001"
name = "Initial Access"
reference = "https://attack.mitre.org/tactics/TA0001/"
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1574"
name = "Hijack Execution Flow"
reference = "https://attack.mitre.org/techniques/T1574/"
[[threat.technique.subtechnique]]
id = "T1574.001"
name = "DLL"
reference = "https://attack.mitre.org/techniques/T1574/001/"



[threat.tactic]
id = "TA0005"
name = "Defense Evasion"
reference = "https://attack.mitre.org/tactics/TA0005/"

[internal]
min_endpoint_version = "7.15.0"

Stages and Predicates

Stage 1: file

file where event.action != "deletion" and
 file.extension : "dll" and
 file.path :
        ("?:\\Users\\*\\AppData\\*\\Microsoft\\OneDrive\\*.dll",
         "?:\\Users\\*\\AppData\\*\\Microsoft OneDrive\\*.dll",
         "?:\\Users\\*\\AppData\\*\\Microsoft\\Teams\\*.dll",
         "?:\\Users\\*\\AppData\\Local\\slack\\app-*\\*.dll",
         "?:\\Users\\*\\AppData\\Local\\Programs\\Microsoft VS Code\\*",
         "?:\\Users\\*\\AppData\\Local\\*\\Well Known Domains\\*\\well_known_domains.dll",
         "?:\\Users\\*\\AppData\\Local\\*\\Domain Actions\\*\\domain_actions.dll") and
 process.name : ("winword.exe", "excel.exe", "powerpnt.exe", "MSACCESS.EXE", "MSPUB.EXE", "fltldr.exe", "cmd.exe",
                 "certutil.exe", "mshta.exe", "cscript.exe", "wscript.exe", "curl.exe", "powershell.exe", "pwsh.exe",
                 "mstsc.exe", "explorer.exe", "dllhost.exe", "xcopy.exe", "expand.exe") and
 not file.path : ("?:\\Users\\*\\AppData\\Local\\Microsoft\\OneDrive\\*\\*.dll",
                  "?:\\Users\\*\\AppData\\Local\\Microsoft\\Teams\\current\\resources\\meeting-addin\\*",
                  "?:\\Users\\*\\Teams\\current\\*")

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
file.pathwildcard?:\Users\*\AppData\Local\Microsoft\OneDrive\*\*.dll, ?:\Users\*\AppData\Local\Microsoft\Teams\current\resources\meeting-addin\*, ?:\Users\*\Teams\current\*excludes:file.path field:"file.path" value:"?:\Users\*\AppData\Local\Microsoft\OneDrive\*\*.dll" field:"file.path" value:"?:\Users\*\AppData\Local\Microsoft\Teams\current\resources\meeting-addin\*" field:"file.path" value:"?:\Users\*\Teams\current\*"

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
event.actionne
  • deletion corpus 86 (elastic 86)
field:"EventType" kind:ne value:"deletion"
file.extensionwildcard
  • dll corpus 33 (elastic 33)
field:"file.extension" kind:wildcard value:"dll"
file.pathwildcard
  • ?:\Users\*\AppData\*\Microsoft OneDrive\*.dll
  • ?:\Users\*\AppData\*\Microsoft\OneDrive\*.dll
  • ?:\Users\*\AppData\*\Microsoft\Teams\*.dll
  • ?:\Users\*\AppData\Local\*\Domain Actions\*\domain_actions.dll
  • ?:\Users\*\AppData\Local\*\Well Known Domains\*\well_known_domains.dll
  • ?:\Users\*\AppData\Local\Programs\Microsoft VS Code\*
  • ?:\Users\*\AppData\Local\slack\app-*\*.dll
field:"TargetFilename" kind:wildcard
process.namewildcard
  • MSACCESS.EXE corpus 19 (elastic 19)
  • MSPUB.EXE corpus 15 (elastic 15)
  • certutil.exe corpus 44 (elastic 38, splunk 6)
  • cmd.exe corpus 121 (elastic 92, splunk 29)
  • cscript.exe corpus 67 (elastic 65, splunk 2)
  • curl.exe corpus 34 (elastic 31, splunk 3)
  • dllhost.exe corpus 19 (elastic 17, splunk 2)
  • excel.exe corpus 34 (elastic 34)
  • expand.exe corpus 8 (elastic 7, splunk 1)
  • explorer.exe corpus 21 (elastic 19, splunk 2)
  • fltldr.exe corpus 8 (elastic 8)
  • mshta.exe corpus 84 (elastic 79, splunk 5)
  • mstsc.exe corpus 7 (elastic 5, splunk 2)
  • powerpnt.exe corpus 31 (elastic 31)
  • powershell.exe corpus 184 (elastic 140, splunk 44)
  • pwsh.exe corpus 77 (elastic 48, splunk 29)
  • winword.exe corpus 35 (elastic 35)
  • wscript.exe corpus 83 (elastic 82, splunk 1)
  • xcopy.exe corpus 10 (elastic 10)
field:"process_name" kind:wildcard