T1546.017 Microsoft Sentinel · KQL

Detect Udev Rules in Microsoft Sentinel

Adversaries may establish persistence by executing malicious content triggered by udev (userspace /dev) rules. Udev is the Linux kernel device manager that handles device events and dynamic file system creation in /dev. Udev rules files (stored at /etc/udev/rules.d/ and /lib/udev/rules.d/) define actions to execute when devices are connected or disconnected, or when other hardware events occur. Adversaries can create malicious udev rules that execute arbitrary commands — potentially as root — when specific device events occur. Since udev runs as root, any RUN directive in a udev rule executes with root privileges, providing both persistence and privilege escalation.

MITRE ATT&CK

Tactic
Persistence Privilege Escalation
Technique
T1546 Event Triggered Execution
Sub-technique
T1546.017 Udev Rules
Canonical reference
https://attack.mitre.org/techniques/T1546/017/

KQL Detection Query

Microsoft Sentinel (KQL)
kusto
DeviceFileEvents
| where Timestamp > ago(24h)
| where (
    FolderPath has "/etc/udev/rules.d/"
    or FolderPath has "/lib/udev/rules.d/"
    or FolderPath has "/usr/lib/udev/rules.d/"
    or FolderPath has "/run/udev/rules.d/"
  )
| where ActionType in ("FileCreated", "FileModified")
| extend FileName_lc = tolower(FileName)
| extend IsRulesFile = FileName endswith ".rules"
| extend IsEtcRules = FolderPath has "/etc/udev/rules.d/"
| extend SuspiciousWriter = InitiatingProcessFileName !in~ (
    "apt", "dpkg", "rpm", "yum", "dnf", "zypper",
    "ansible", "puppet", "chef", "salt-minion"
  )
| project Timestamp, DeviceName, AccountName, ActionType, FileName, FolderPath,
         IsRulesFile, IsEtcRules, SuspiciousWriter,
         InitiatingProcessFileName, InitiatingProcessCommandLine
| where IsRulesFile
| sort by Timestamp desc
high severity medium confidence

Detects udev rules file creation and modification in standard udev rules directories (/etc/udev/rules.d/, /lib/udev/rules.d/, /usr/lib/udev/rules.d/, /run/udev/rules.d/). Monitors for .rules files created or modified by non-package-manager processes. Since udev rules can execute arbitrary commands as root (via RUN directive), any unexpected modification to udev rules directories is a persistence indicator. Files in /etc/udev/rules.d/ are highest priority as they take precedence over system-provided rules.

Data Sources

File: File CreationFile: File ModificationMicrosoft Defender for Endpoint

Required Tables

DeviceFileEvents

False Positives & Tuning

  • Linux package installations (apt, dpkg, rpm, yum) that install device management rules as part of hardware driver or udev rule packages
  • Configuration management tools (Ansible, Puppet, Chef, Salt) that deploy custom udev rules for device configuration as part of system baseline enforcement
  • Hardware vendor software that installs udev rules to configure specific hardware devices (e.g., USB security keys, printers, network interfaces)
  • System administrators manually creating udev rules to manage device permissions or automate device-triggered workflows
Download portable Sigma rule (.yml)

Other platforms for T1546.017


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 Udev Rule for USB Device Persistence

    Expected signal: File creation event for /etc/udev/rules.d/99-argus-test.rules. Process creation for tee and udevadm. Auditd records for file creation in /etc/udev/rules.d/. When a USB device is inserted, udevd spawns bash to execute the RUN directive — child process of udevd.

  2. Test 2Create Udev Rule Triggered by Network Interface

    Expected signal: File creation event for 99-argus-net-test.rules in /etc/udev/rules.d/. The rule fires when a network interface is added — logger is spawned by udevd as a child process, creating a syslog entry. Systemd journal shows udevd running the RUN directive.

  3. Test 3Enumerate All Custom Udev Rules

    Expected signal: Process creation for grep, ls with udev directory arguments. Read-only — no modifications. The output reveals all custom rules and their RUN directives.

Unlock Pro Content

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

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections