Overview
The Token Privileges check enumerates the privileges assigned to the current process token and identifies dangerous privileges that can be abused for privilege escalation. Even if these privileges are in a “disabled” state, they can often be enabled programmatically and exploited.Token privileges are powerful Windows security features that allow specific operations. When improperly assigned, they create serious privilege escalation opportunities.
How It Works
SharpUp queries the current process token and checks for these dangerous privileges: Dangerous Privileges:SeSecurityPrivilege- Manage auditing and security logSeTakeOwnershipPrivilege- Take ownership of files/objectsSeLoadDriverPrivilege- Load and unload device driversSeBackupPrivilege- Backup files (bypass ACLs for read)SeRestorePrivilege- Restore files (bypass ACLs for write)SeDebugPrivilege- Debug programs (access any process memory)SeSystemEnvironmentPrivilege- Modify firmware environment valuesSeImpersonatePrivilege- Impersonate authenticated usersSeTcbPrivilege- Act as part of the operating system
Example Output
- SeImpersonatePrivilege is currently enabled - can be abused immediately
- SeDebugPrivilege is enabled and is in the default set
- SeBackupPrivilege is disabled but can be enabled programmatically
Exploitation
SeImpersonatePrivilege - Potato Exploits
SeDebugPrivilege - Process Injection
SeBackupPrivilege - Copy Protected Files
SeRestorePrivilege - Modify Protected Files
SeLoadDriverPrivilege - Load Malicious Driver
SeTakeOwnershipPrivilege - Take File Ownership
Remediation
1
Review Token Privileges
2
Remove Unnecessary Privileges
Open Local Security Policy or Group Policy:
- Computer Configuration → Windows Settings → Security Settings → Local Policies → User Rights Assignment
- Remove users/groups from:
- Debug programs (SeDebugPrivilege)
- Impersonate a client after authentication (SeImpersonatePrivilege)
- Load and unload device drivers (SeLoadDriverPrivilege)
- Take ownership of files (SeTakeOwnershipPrivilege)
- Back up files and directories (SeBackupPrivilege)
- Restore files and directories (SeRestorePrivilege)
3
Use Managed Service Accounts
4
Minimize LocalSystem Services
Detection
Defensive Monitoring
Detection Strategies
- Privilege Usage Monitoring
- Process Monitoring
- File System Monitoring
- Driver Loading
- Monitor Event ID 4672 for privilege assignments
- Alert on dangerous privileges assigned to non-admin users
- Track privilege elevation events
- Detect privilege abuse patterns
Real-World Scenarios
Scenario 1: IIS Application Pool Identity
Scenario 1: IIS Application Pool Identity
Context: IIS application pool running with default identity (ApplicationPoolIdentity) has SeImpersonatePrivilege.Attack Path:
- Compromise web application (SQL injection, file upload, etc.)
- Execute code in context of application pool
- Use Juicy Potato to escalate to SYSTEM
- Complete server compromise
- Use least privileged application pool identities
- Implement application whitelisting
- Network segmentation
- Monitor for Potato exploits
Scenario 2: SQL Server Service Account
Scenario 2: SQL Server Service Account
Context: SQL Server running as domain account with SeImpersonatePrivilege and SeDebugPrivilege.Impact:
- xp_cmdshell execution leads to privilege escalation
- Can impersonate any authenticated user
- Can access any process memory (including LSASS)
- Domain credential theft possible
- Use gMSA for SQL Server
- Disable xp_cmdshell
- Remove unnecessary privileges
- Implement least privilege
Scenario 3: Backup Operator Group Member
Scenario 3: Backup Operator Group Member
Context: User is member of Backup Operators group, granting SeBackupPrivilege and SeRestorePrivilege.Attack Path:
- User with backup privileges logs on
- Uses privileges to copy NTDS.dit and SYSTEM hive
- Extracts all domain password hashes offline
- Complete domain compromise
- Strictly limit Backup Operators membership
- Monitor file access by backup operators
- Implement Just-In-Time access
- Use LAPS for privilege escalation auditing
Prevention Best Practices
Principle of Least Privilege
Only assign necessary privileges. Most accounts don’t need any special privileges.
Use Managed Service Accounts
gMSA and sMSA automatically manage privileges appropriately.
Avoid LocalSystem
Run services with minimal required accounts, not LocalSystem.
Regular Audits
Periodically review which accounts have dangerous privileges.
Common Privilege Abuse Tools
- Juicy Potato - SeImpersonatePrivilege exploitation (Windows Server 2016 and earlier)
- Rogue Potato - SeImpersonatePrivilege exploitation (Windows Server 2019+)
- PrintSpoofer - SeImpersonatePrivilege exploitation via Print Spooler
- Mimikatz - Uses SeDebugPrivilege to dump credentials from LSASS
- Process Hacker - Uses SeDebugPrivilege for process manipulation
- Capcom.sys - Vulnerable driver loaded via SeLoadDriverPrivilege
Related Checks
Modifiable Services
Services that can be reconfigured
Registry AutoLogons
Plaintext credentials in registry
AlwaysInstallElevated
MSI installation with elevated privileges
Remediation Guide
Comprehensive remediation guidance