T1547.013 Microsoft Sentinel · KQL

Detect XDG Autostart Entries in Microsoft Sentinel

Adversaries may add or modify XDG Autostart Entries to execute malicious programs or commands when a user's desktop environment is loaded at login. XDG Autostart entries are available for any XDG-compliant Linux system. XDG Autostart entries use Desktop Entry files (.desktop) to configure the user's desktop environment upon user login. These configuration files determine what applications launch upon user login, define associated applications to open specific file types, and define applications used to open removable media. Adversaries may abuse this feature to establish persistence by adding a path to a malicious binary or command to the Exec directive in the .desktop configuration file. System-wide Autostart entries are located in /etc/xdg/autostart while user entries are located in ~/.config/autostart.

MITRE ATT&CK

Tactic
Persistence Privilege Escalation
Technique
T1547 Boot or Logon Autostart Execution
Sub-technique
T1547.013 XDG Autostart Entries
Canonical reference
https://attack.mitre.org/techniques/T1547/013/

KQL Detection Query

Microsoft Sentinel (KQL)
kusto
let AutostartPaths = dynamic(["/etc/xdg/autostart/", "/.config/autostart/"]);
DeviceFileEvents
| where Timestamp > ago(24h)
| where ActionType in ("FileCreated", "FileModified")
| where FolderPath has_any (AutostartPaths)
| where FileName endswith ".desktop"
| project Timestamp, DeviceName, AccountName, ActionType, FileName, FolderPath, InitiatingProcessFileName, InitiatingProcessCommandLine, SHA256
| sort by Timestamp desc;
DeviceProcessEvents
| where Timestamp > ago(24h)
| where ProcessCommandLine has_any (".config/autostart", "/etc/xdg/autostart", "xdg-autostart")
| where ProcessCommandLine has_any ("cp ", "mv ", "tee ", "cat ", "echo ", "printf ", ">>")
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine, InitiatingProcessFileName, InitiatingProcessCommandLine
| sort by Timestamp desc
medium severity medium confidence

Detects XDG Autostart persistence via two signals: (1) File creation or modification of .desktop files in XDG Autostart directories (/etc/xdg/autostart/ for system-wide and ~/.config/autostart/ for user-level), and (2) process command lines that indicate writing to autostart directories using shell commands (cp, mv, tee, echo). Uses DeviceFileEvents and DeviceProcessEvents tables from MDE for Linux endpoints.

Data Sources

File: File CreationFile: File ModificationProcess: Process CreationCommand: Command ExecutionMicrosoft Defender for Endpoint (Linux)

Required Tables

DeviceFileEventsDeviceProcessEvents

False Positives & Tuning

  • Desktop environment package installations (GNOME, KDE, XFCE) that add .desktop autostart entries for system services like keyring agents, polkit, and accessibility tools
  • User-installed applications (Slack, Discord, Spotify, Steam) that create autostart entries during installation or when the user enables 'Start on login'
  • System administrators deploying autostart entries via configuration management tools (Ansible, Puppet, Chef) for monitoring agents or corporate tools
  • Package manager operations (apt, dnf, pacman) that install or update packages containing XDG autostart entries
Download portable Sigma rule (.yml)

Other platforms for T1547.013


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 1Create Malicious XDG Autostart Entry (User Level)

    Expected signal: Sysmon for Linux Event ID 11: FileCreate with TargetFilename=~/.config/autostart/df00tech-test.desktop. Audit log: SYSCALL event for openat/creat on the .desktop file path. DeviceFileEvents with ActionType=FileCreated.

  2. Test 2Create System-Wide XDG Autostart Entry

    Expected signal: Sysmon for Linux Event ID 11: FileCreate with TargetFilename=/etc/xdg/autostart/df00tech-sysupdate.desktop, Image=bash (running as root). Audit log: SYSCALL with auid showing the user who ran sudo. DeviceFileEvents with ActionType=FileCreated.

  3. Test 3XDG Autostart Entry via Echo (Inline Creation)

    Expected signal: Sysmon for Linux Event ID 1: Process Create for bash/echo with CommandLine containing autostart and .desktop. Sysmon Event ID 11: FileCreate for the .desktop file. DeviceProcessEvents with ProcessCommandLine containing the echo command.

Unlock Pro Content

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

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections