T1564.014

Extended Attributes

Adversaries may abuse extended attributes (xattrs) on macOS and Linux to hide malicious data and evade detection. Extended attributes are key-value pairs of metadata attached to files and directories that are invisible to standard tools like ls, cat, and Finder. They require dedicated utilities — xattr on macOS, or getfattr/setfattr on Linux — for inspection. An adversary embeds a Base64-encoded second-stage payload into an xattr of a legitimate file (using xattr -w on macOS or setfattr on Linux), then a loader script retrieves the attribute value, decodes it, and pipes it to a scripting interpreter (bash, python, etc.) for execution. Because the primary file content and cryptographic hash remain unchanged, file integrity monitoring and hash-based detection will not flag the carrier file. This technique has been observed in Lazarus Group (APT38) campaigns where custom xattr names mimicking system attributes were used to store encrypted shellcode.

Microsoft Sentinel / Defender
kusto
DeviceProcessEvents
| where Timestamp > ago(24h)
| where DeviceOSPlatform in~ ("macOS", "Linux")
| where (
    // macOS: xattr write (embedding payload)
    (FileName =~ "xattr" and ProcessCommandLine has_any ("-w ", "--set ", "-wx ")) or
    // Linux: setfattr (embedding payload into user. namespace)
    (FileName =~ "setfattr" and ProcessCommandLine has "-n ") or
    // Linux: getfattr extraction — especially --only-values used by loaders
    (FileName =~ "getfattr" and ProcessCommandLine has_any ("--only-values", "-e ")) or
    // macOS: xattr read (retrieving payload)
    (FileName =~ "xattr" and ProcessCommandLine has_any ("-p ", "--print ")) or
    // Shell/interpreter invoked with parent chain showing xattr read
    (FileName in~ ("bash", "sh", "zsh", "python", "python3", "perl", "ruby") and
     InitiatingProcessFileName in~ ("xattr", "getfattr", "bash", "sh", "zsh") and
     InitiatingProcessCommandLine has_any ("xattr -p", "getfattr --only-values", "base64 -d", "base64 --decode"))
)
// Enrich with suspicious indicators
| extend HasBase64Pattern = ProcessCommandLine has_any ("base64", "base64 -d", "--decode", "frombase64", "b64decode")
| extend HasExecutionPipe = ProcessCommandLine has_any ("|bash", "| bash", "|sh", "| sh", "|python", "| python", "|perl", "| perl", "exec(", "eval(")
| extend WritingAttribute = (FileName in~ ("xattr", "setfattr")) and ProcessCommandLine has_any ("-w ", "--set ", "-n ")
| extend ReadingAttribute = (FileName =~ "xattr" and ProcessCommandLine has_any ("-p ", "--print ")) or (FileName =~ "getfattr" and ProcessCommandLine has "--only-values")
| extend NonStandardNamespace = ProcessCommandLine has_any ("user.", "trusted.", "security.") and not ProcessCommandLine has_any ("com.apple.quarantine", "com.apple.metadata", "com.apple.FinderInfo", "com.apple.lastuseddate", "com.apple.ResourceFork")
| extend SuspicionScore = toint(HasBase64Pattern) + toint(HasExecutionPipe) + toint(NonStandardNamespace) + toint(WritingAttribute) + toint(ReadingAttribute)
| project Timestamp, DeviceName, DeviceOSPlatform, AccountName, FileName, ProcessCommandLine,
         InitiatingProcessFileName, InitiatingProcessCommandLine,
         WritingAttribute, ReadingAttribute, HasBase64Pattern, HasExecutionPipe, NonStandardNamespace, SuspicionScore
| sort by Timestamp desc
high severity medium confidence

Data Sources

Process: Process Creation Command: Command Execution Microsoft Defender for Endpoint (macOS agent) Microsoft Defender for Endpoint (Linux agent)

Required Tables

DeviceProcessEvents

False Positives

  • macOS Gatekeeper and Spotlight legitimately use com.apple.quarantine, com.apple.metadata:*, and com.apple.FinderInfo attributes — excluded by the NonStandardNamespace filter
  • Backup and archiving tools (rsync --xattrs, tar --xattrs, macOS Time Machine) regularly read and write extended attributes during scheduled backup operations
  • File tagging applications and Digital Asset Management (DAM) software write custom xattrs for organizational metadata and workflow state
  • Container runtimes (Docker overlay2, Podman) and package managers use trusted. namespace attributes on Linux for filesystem layer tracking
  • Security baseline scanning tools (AIDE, Tripwire) reading all file metadata including xattrs during scheduled integrity baseline runs

Unlock Pro Content

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

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections