T1149 Google Chronicle · YARA-L

Detect LC_MAIN Hijacking in Google Chronicle

Adversaries may hijack the LC_MAIN Mach-O load command in macOS binaries to redirect initial execution flow to malicious code before returning control to the legitimate entry point. The LC_MAIN header, introduced in OS X 10.8, defines the entry point offset for a Mach-O executable. By patching this offset to point at an injected code section or cave, an attacker can execute arbitrary code under the identity of a trusted binary, bypassing application whitelisting controls that validate only the file path or name. This technique has been deprecated in the MITRE ATT&CK framework but remains relevant for forensic analysis of older macOS malware samples and legacy systems.

MITRE ATT&CK

Tactic
Defense Evasion
Canonical reference
https://attack.mitre.org/techniques/T1149/

YARA-L Detection Query

Google Chronicle (YARA-L)
yaral
rule lc_main_hijacking_macho_inspection {
  meta:
    author = "Argus Detection Engineering"
    description = "Detects Mach-O inspection tools invoked with LC_MAIN or load command flags against sensitive macOS system binary paths, indicating potential entry-point offset reconnaissance for T1149."
    severity = "HIGH"
    priority = "HIGH"
    mitre_attack_tactic = "Defense Evasion"
    mitre_attack_technique = "T1149"
    platform = "macOS"
    false_positives = "Developer toolchains, Homebrew, security research"
    version = "1.0"

  events:
    $e.metadata.event_type = "PROCESS_LAUNCH"
    $e.metadata.vendor_name = "Apple"
    (
      $e.principal.process.file.full_path = /\/(otool|jtool2?|vtool|install_name_tool|lipo)$/ or
      $e.target.process.file.full_path = /\/(otool|jtool2?|vtool|install_name_tool|lipo)$/
    )
    (
      $e.target.process.command_line = /(\s-l\s|--load-commands|LC_MAIN|LC_THREAD|LC_UNIXTHREAD|entryoff|stacksize)/i
    )
    (
      $e.target.process.command_line = /(\/Applications\/|\/usr\/(local\/)?bin\/|\/usr\/sbin\/|\/bin\/|\/sbin\/|\/opt\/)/
    )

  condition:
    $e
}
high severity medium confidence

Chronicle YARA-L 2.0 rule detecting macOS Mach-O binary inspection tool executions where load command enumeration flags (LC_MAIN, LC_THREAD, entryoff) are used against binaries in sensitive system directories. Uses UDM PROCESS_LAUNCH events from macOS endpoint telemetry.

Data Sources

Google Chronicle macOS UDM ingestionCrowdStrike Falcon Chronicle forwardingCarbon Black Chronicle integration

Required Tables

UDM PROCESS_LAUNCH events (metadata.event_type)

False Positives & Tuning

  • Apple Developer Tools post-install hooks use install_name_tool to rewrite embedded library paths for applications installed into /Applications
  • Xcode-integrated build systems invoke otool during linking to verify Mach-O headers and load command integrity for both /usr/bin and /usr/local/bin targets
  • macOS endpoint detection and response tools that call otool internally to parse binary metadata for file classification and behavioral analytics
Download portable Sigma rule (.yml)

Other platforms for T1149


Testing Methodology

Validate this detection against 5 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 1Inspect LC_MAIN Entry Point of a System Binary

    Expected signal: macOS Unified Log / ESF process event: process_name=otool, cmdline='otool -l /bin/ls', parent=bash/zsh. osquery process_open_files will show /bin/ls opened for reading by otool. No file modification events are generated by this read-only operation.

  2. Test 2Enumerate All Load Commands of a Sensitive Application Binary

    Expected signal: ESF/stream:process event: process_name=otool, cmdline targeting /Applications/Safari.app/Contents/MacOS/Safari with -l flag. macOS FSEvent: Safari binary opened for reading with otool PID. DeviceProcessEvents (MDE): FileName=otool, ProcessCommandLine contains '-l' and '/Applications/Safari.app/Contents/MacOS/Safari'.

  3. Test 3Verify Code Signature Validity of a Modified Binary

    Expected signal: ESF process event: process_name=codesign, cmdline contains '-v --deep --strict /bin/ls'. macOS Unified Log subsystem com.apple.security.codesigning records the verification result with target binary path and signing identity. If a binary were actually modified, this command would produce a 'code object is not signed at all' or 'a sealed resource is missing or invalid' error.

  4. Test 4Simulate Code Cave Discovery Using nm and size

    Expected signal: ESF process events for nm and size with respective command lines targeting /usr/bin/true. Both binaries are in /usr/bin/ (a monitored sensitive path). DeviceProcessEvents: FileName in ('nm', 'size'), ProcessCommandLine contains '/usr/bin/true'. These events fire consecutively and may indicate scripted reconnaissance.

  5. Test 5Write a Test File to an App Bundle MacOS Directory (Simulated Binary Drop)

    Expected signal: ESF/stream:file events: FileCreated for /tmp/TestApp.app/Contents/MacOS/TestApp and /tmp/TestApp.app/Contents/MacOS/TestApp.bak. DeviceFileEvents: ActionType=FileCreated, FolderPath contains '/MacOS/', InitiatingProcessFileName=bash/zsh. The /tmp/ path is not in the monitored sensitive paths by default — adjust the FolderPath filter to include /tmp/*.app/Contents/MacOS/ for this test to trigger the hunting query.

Unlock Pro Content

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

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections