T1574.004 IBM QRadar · QRadar

Detect Dylib Hijacking in IBM QRadar

Adversaries on macOS may execute malicious payloads by placing a malicious dynamic library (dylib) in a path that a victim application searches at runtime. The macOS dynamic linker searches paths in order: @rpath (relative run-path), @loader_path, @executable_path, and standard system paths (/usr/lib, /System/Library). If an application references a dylib with a weak link (LC_LOAD_WEAK_DYLIB) and the dylib does not exist, an adversary can plant a malicious dylib with the correct name at the expected path. The Empire post-exploitation framework includes modules specifically for scanning and exploiting dylib hijacking vulnerabilities.

MITRE ATT&CK

Tactic
Persistence Privilege Escalation Defense Evasion
Technique
T1574 Hijack Execution Flow
Sub-technique
T1574.004 Dylib Hijacking
Canonical reference
https://attack.mitre.org/techniques/T1574/004/

QRadar Detection Query

IBM QRadar (QRadar)
sql
SELECT DATEFORMAT(devicetime, 'yyyy-MM-dd HH:mm:ss') AS event_time, sourceip, "username", "filename", "filepath", CATEGORYNAME(category) AS event_category, LOGSOURCENAME(logsourceid) AS log_source
FROM events
WHERE LOGSOURCETYPEID IN (73, 352)
  AND LOWER("filename") LIKE '%.dylib'
  AND (
    "filepath" LIKE '/tmp/%' OR
    "filepath" LIKE '/var/folders/%' OR
    "filepath" LIKE '/Users/%/Library/%' OR
    "filepath" LIKE '/private/tmp/%' OR
    "filepath" LIKE '/Users/%/Library/Application Support/%'
  )
  AND CATEGORYNAME(category) IN ('File Created', 'File Modified', 'File Written')
  AND devicetime > (CURRENT_TIMESTAMP - 86400000)
ORDER BY devicetime DESC
high severity medium confidence

Detects suspicious .dylib file creation or modification events in macOS paths commonly targeted in dylib hijacking attacks. Queries file integrity monitoring log sources for writes to @rpath-adjacent directories that an adversary could exploit via weak dylib references (LC_LOAD_WEAK_DYLIB).

Data Sources

macOS Unified Log (via QRadar DSM)Jamf Pro log sourceosquery file_events log source

Required Tables

events

False Positives & Tuning

  • Application auto-update mechanisms that unpack or rewrite dylibs to user-local Library paths
  • Xcode and development toolchains writing build artifacts to /var/folders/ DerivedData directories
  • Third-party security or MDM agents (Jamf, Carbon Black) installing macOS components to non-system library paths
Download portable Sigma rule (.yml)

Other platforms for T1574.004


Testing Methodology

Validate this detection against 3 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.

  1. Test 1List Vulnerable Applications Using otool

    Expected signal: Process creation event for otool. No file creation events generated. This is a read-only reconnaissance action. macOS audit logs (if enabled) would show the file read operations.

  2. Test 2Create Malicious Dylib in @rpath Location

    Expected signal: File creation event for .dylib file in user Library path. Process creation events for gcc (if installed). The dylib file will appear as unsigned in code signing checks (codesign -v ~/Library/test-hijack/libtest.dylib).

  3. Test 3Verify DYLD Environment Variable Propagation

    Expected signal: Process creation event for ls with DYLD_PRINT_LIBRARIES environment variable set. The output shows which dylibs ls loads. macOS SIP (System Integrity Protection) may suppress DYLD_* variables for protected binaries.

Unlock Pro Content

Get the full detection package for T1574.004 including response playbook, investigation guide, and atomic red team tests.

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections