T1548.003
Sudo and Sudo Caching
Adversaries abuse sudo and sudo caching on Linux and macOS to execute commands with elevated privileges. Techniques include: modifying /etc/sudoers to grant NOPASSWD access, exploiting the sudo timestamp cache (default 15-minute window) to run commands without re-authentication, using 'sudo -n' to check if cached credentials exist, and exploiting sudoedit or sudo bypass vulnerabilities (CVE-2021-3156 Baron Samedit). ProtonB malware and various Linux post-exploitation frameworks abuse sudo for privilege escalation.
Microsoft Sentinel / Defender
kusto
// T1548.003 — Sudo and Sudo Caching abuse detection
// Requires Linux/macOS endpoints in Defender for Endpoint
// Part 1: Detect sudoers file modification
let SudoersModify = DeviceFileEvents
| where Timestamp > ago(24h)
| where FileName in~ ("sudoers") or FolderPath has "/etc/sudoers.d/"
| where ActionType in ("FileCreated", "FileModified")
| extend DetectionType = "Sudoers_File_Modified"
| project Timestamp, DeviceName, AccountName, FileName, FolderPath,
InitiatingProcessFileName, InitiatingProcessCommandLine, DetectionType;
// Part 2: Detect sudo with NOPASSWD or ALL privilege grants
let SudoNOPASSWD = DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName in~ ("sudo", "visudo")
| where ProcessCommandLine has_any ("NOPASSWD", "ALL=(ALL", "ALL:ALL",
"!authenticate", "sudoedit")
| extend DetectionType = "Sudo_Privilege_Grant"
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
InitiatingProcessFileName, DetectionType;
// Part 3: Detect sudo timestamp cache abuse
let SudoCacheAbuse = DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName =~ "sudo"
| where ProcessCommandLine has_any ("-n", "--non-interactive", "-S", "--stdin")
and ProcessCommandLine !has "apt" and ProcessCommandLine !has "yum"
| extend DetectionType = "Sudo_Cache_NonInteractive"
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
InitiatingProcessFileName, InitiatingProcessCommandLine, DetectionType;
// Part 4: Detect unauthorized processes running as root via sudo
let SudoRootExec = DeviceProcessEvents
| where Timestamp > ago(24h)
| where AccountName =~ "root"
| where InitiatingProcessFileName =~ "sudo"
| where FileName in~ ("bash", "sh", "zsh", "python", "python3", "perl", "ruby")
| extend DetectionType = "Sudo_Shell_Escalation"
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
InitiatingProcessFileName, DetectionType;
union SudoersModify, SudoNOPASSWD, SudoCacheAbuse, SudoRootExec
| sort by Timestamp desc high severity
medium confidence
Data Sources
Process: Process Creation File: File Modification Microsoft Defender for Endpoint (Linux/macOS)
Required Tables
DeviceProcessEvents DeviceFileEvents
False Positives
- System administrators legitimately editing sudoers to grant specific users limited sudo access
- Package managers (apt, yum) using sudo -n or similar patterns during automated updates
- Ansible, Chef, Puppet automation using sudo for system configuration management
- CI/CD pipelines that use sudo for build/deployment tasks with documented NOPASSWD grants
Last updated: 2026-04-21 Research depth: deep
Unlock Pro Content
Get the full detection package for T1548.003 including response playbook, investigation guide, and atomic red team tests.
Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance