Skip to content
Access control Write-up Intermediate

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.

Medusa Follow

Published on systemweakness.com

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.

Medusa, on systemweakness.com

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

  1. Check the current user's privileges with whoami /priv.
  2. Load the incognito module in the Meterpreter shell.
  3. List available tokens with list_tokens -g.
  4. Impersonate the BUILTIN\Administrators token.
  5. List processes with ps.
  6. 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.

More by Medusa

View all

10 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

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.