Windows DLL Search Order Hijacking Hunt

Original Source: [splunk source]
Name:Windows DLL Search Order Hijacking Hunt
id:79c7d0fc-60c7-41be-a616-ccda752efe89
version:4
date:2024-10-17
author:Michael Haag, Splunk
status:deprecated
type:Hunting
Description:The following hunting analytic is an experimental query built against a accidental feature using the latest Sysmon TA 3.0 (https://splunkbase.splunk.com/app/5709/) which maps the module load (ImageLoaded) to process_name. This analytic will deprecate once this is fixed. This hunting analytic identifies known libraries in Windows that may be used in a DLL search order hijack or DLL Sideloading setting. This may require recompiling the DLL, moving the DLL or moving the vulnerable process. The query looks for any running out of system32 or syswow64. Some libraries natively run out of other application paths and will need to be added to the exclusion as needed. The lookup is comprised of Microsoft native libraries identified within the Hijacklibs.net project.
Data_source:
  • -Sysmon EventID 1
  • -Windows Event Log Security 4688
  • -CrowdStrike ProcessRollup2
  • -Windows Event Log Security 4688
search:| tstats `security_content_summariesonly` count min(_time) as firstTime max(_time) as lastTime values(Processes.process_name) as process_name from datamodel=Endpoint.Processes where Processes.dest!=unknown Processes.user!=unknown NOT (Processes.process_path IN ("*\\system32\\*", "*\\syswow64\\*","*\\winsxs\\*","*\\wbem\\*")) by Processes.dest Processes.user Processes.parent_process_name Processes.process_name Processes.process_path
| `security_content_ctime(firstTime)`
| `security_content_ctime(lastTime)`
| `drop_dm_object_name(Processes)`
| lookup hijacklibs library AS process_name OUTPUT islibrary
| search islibrary = True
| rename parent_process_name as process_name , process_name AS ImageLoaded, process_path AS Module_Path
| `windows_dll_search_order_hijacking_hunt_filter`


how_to_implement:The detection is based on data that originates from Endpoint Detection and Response (EDR) agents. These agents are designed to provide security-related telemetry from the endpoints where the agent is installed. To implement this search, you must ingest logs that contain the process GUID, process name, and parent process. Additionally, you must ingest complete command-line executions. These logs must be processed using the appropriate Splunk Technology Add-ons that are specific to the EDR product. The logs must also be mapped to the `Processes` node of the `Endpoint` data model. Use the Splunk Common Information Model (CIM) to normalize the field names and speed up the data modeling process.
known_false_positives:False positives will be present based on paths. Filter or add other paths to the exclusion as needed.
References:
  -https://hijacklibs.net
drilldown_searches:
  :
tags:
  analytic_story:
    - 'Living Off The Land'
    - 'Windows Defense Evasion Tactics'
  asset_type:Endpoint
  confidence:10
  impact:10
  message:Potential Windows DLL Search Order Hijacking detected on $dest$
  mitre_attack_id:
    - 'T1574.001'
    - 'T1574'
  observable:
    name:'user'
    type:'User'
    - role:
      - 'Victim'
    name:'dest'
    type:'Hostname'
    - role:
      - 'Victim'
  product:
    - 'Splunk Enterprise'
    - 'Splunk Enterprise Security'
    - 'Splunk Cloud'
  required_fields:
    - '_time'
    - 'Processes.dest'
    - 'Processes.user'
    - 'Processes.parent_process_name'
    - 'Processes.process_name'
    - 'Processes.process_path'
  risk_score:1
  security_domain:endpoint

tests:
name:'True Positive Test'
 attack_data:
  data: https://media.githubusercontent.com/media/splunk/attack_data/master/datasets/attack_techniques/T1574.001/atomic_red_team/windows-sysmon.log
  source: XmlWinEventLog:Microsoft-Windows-Sysmon/Operational
  sourcetype: XmlWinEventLog
  update_timestamp: True
manual_test:None