T1548.001

Setuid and Setgid

Adversaries abuse the setuid (SUID) and setgid (SGID) permission bits on Linux and macOS to execute code in another user's context, typically root. When a file with SUID is executed, it runs as the file owner rather than the executing user. Adversaries can set SUID on their malware to enable future privilege escalation, or exploit existing SUID binaries listed on GTFOBins. Keydnap malware added setuid to binaries; Exaramel for Linux used a setuid binary for privilege escalation. The find command is commonly used by attackers to discover exploitable SUID/SGID binaries.

Microsoft Sentinel / Defender
kusto
// T1548.001 — Setuid/Setgid abuse detection on Linux/macOS endpoints
// Requires Linux or macOS endpoints enrolled in Defender for Endpoint
// Part 1: Detect chmod setting SUID/SGID bits
let ChmodSUID = DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName in~ ("chmod")
| where ProcessCommandLine has_any ("4777", "4755", "4711", "u+s", "+s",
                                    "2777", "2755", "g+s", "6777", "6755")
| extend SetUID = ProcessCommandLine has_any ("4777", "4755", "4711", "u+s")
| extend SetGID = ProcessCommandLine has_any ("2777", "2755", "g+s")
| extend DetectionType = "Chmod_SUID_SGID_Set"
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
          InitiatingProcessFileName, InitiatingProcessCommandLine,
          SetUID, SetGID, DetectionType;
// Part 2: Detect find commands searching for SUID/SGID binaries (attacker recon)
let FindSUID = DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName =~ "find"
| where ProcessCommandLine has_any ("-perm +4000", "-perm -4000", "-perm /4000",
                                    "-perm +2000", "-perm -2000", "-perm /2000",
                                    "-perm +6000", "setuid", "setgid")
| extend DetectionType = "Find_SUID_SGID_Discovery"
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
          InitiatingProcessFileName, InitiatingProcessCommandLine, DetectionType;
// Part 3: Detect unexpected SUID binaries executing as root from non-standard paths
let SUIDBinaryExec = DeviceProcessEvents
| where Timestamp > ago(24h)
| where AccountName =~ "root"
| where FolderPath has_any ("/tmp/", "/var/tmp/", "/dev/shm/", "/home/")
| extend DetectionType = "Root_Exec_From_User_Path"
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
          InitiatingProcessFileName, InitiatingProcessCommandLine, FolderPath, DetectionType;
union ChmodSUID, FindSUID, SUIDBinaryExec
| sort by Timestamp desc
high severity medium confidence

Data Sources

Process: Process Creation File: File Metadata Microsoft Defender for Endpoint (Linux/macOS)

Required Tables

DeviceProcessEvents

False Positives

  • System administrators legitimately setting SUID on binaries that require it (e.g., ping, passwd, sudo itself)
  • Package manager installations (apt, yum, dnf) that set appropriate SUID bits on system utilities
  • Security auditors running find commands to enumerate SUID binaries during authorized security assessments
  • Software build systems that set SUID bits on installed binaries as part of the build process

Unlock Pro Content

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

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections