Abusing Windows’ tokens to compromise Active Directory without touching LSASS
During an internal assessment, the author obtained local administrator access on a server where a domain administrator was logged on. Instead of dumping LSASS memory, they abused Windows access tokens to impersonate the domain administrator and create a new domain admin account, compromising the domain.
Published on sensepost.com
During an internal assessment, I performed an NTLM relay and ended up owning the NT AUTHORITY\SYSTEM account of the Windows server. Looking at the users connected on the same server, I knew that a domain administrator account was connected.
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
Windows stores access tokens for logged-on users in kernel memory, and any user with local administrator rights (specifically SeDebugPrivilege and SeImpersonatePrivilege) can duplicate and impersonate those tokens.
Impact
An attacker with local administrator access could impersonate a logged-on domain administrator and compromise the entire Active Directory domain, even with an EDR present, because LSASS is not touched.
What the attacker needed
Local administrator access on the server; a domain administrator logged on to the server; SeDebugPrivilege and SeImpersonatePrivilege
The fix
Restrict local administrator rights and limit the exposure of privileged domain accounts on servers, and monitor for token manipulation techniques.
How it was found
- Obtain local administrator access on a server where a domain administrator is logged on.
- Enable SeDebugPrivilege to open processes owned by other users.
- List all handles on the system and identify token handles.
- Duplicate the token of the domain administrator.
- Impersonate the domain administrator using the duplicated token.
- Create a new user on the domain and add it to the domain administrators group.
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.
When someone logs into Windows, the system creates a 'token' that describes their identity and permissions. These tokens are kept in memory and can be copied by an administrator. The author copied the token of a logged-in domain administrator and used it to act as that administrator, without needing their password.
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.