Privilege Escalation Using Token Impersonation Windows
A walkthrough shows that after gaining an initial foothold on a Windows host, a user holding SeImpersonatePrivilege and SeDebugPrivilege can use the Meterpreter incognito module to list and impersonate other users' access tokens, including the built-in Administrators group. This lets the attacker take on higher privileges and migrate into a privileged process such as services.exe.
Windows uses the access tokento represent the security context of a user or process. The security context can be defined as the permissions and privileges a user or a process has to access resources on the system.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the compromised account was granted powerful token-related privileges (SeImpersonatePrivilege and SeDebugPrivilege), which allow a process to impersonate other users' tokens and escalate to administrator.
Impact
An attacker with an initial foothold could escalate to administrator-level privileges on the host by impersonating a privileged token.
What the attacker needed
Initial foothold on the host; SeImpersonatePrivilege enabled; SeDebugPrivilege enabled
The fix
Accounts and services should not be granted SeImpersonatePrivilege or SeDebugPrivilege unless strictly required, and service accounts should run with the least privilege possible.
How it was found
- Check the current user's privileges with whoami /priv.
- Load the incognito module in the Meterpreter shell.
- List available tokens with list_tokens -g.
- Impersonate the BUILTIN\Administrators token.
- List processes with ps.
- Migrate into the services.exe process.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Windows gives every logged-in user a kind of digital pass called an access token, which lists what that user is allowed to do. Some special permissions let a program borrow, or impersonate, another user's pass. If an attacker already has a foothold and one of those permissions, they can borrow a more powerful user's pass and act as that user.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.