CertPotato – Using ADCS to privesc from virtual and network service accounts to local system
A web shell running as an IIS virtual account can obtain a Kerberos ticket for the machine account and use it to request a certificate from ADCS, then authenticate with that certificate to obtain the machine account's NT hash. With that hash, an attacker can forge a Silver ticket and gain SYSTEM privileges on the server.
Published on sensepost.com
The goal of this blog post is to present a privilege escalation I found while working on ADCS. We will see how it is possible to elevate our privileges to NT AUTHORITY\SYSTEM from virtual and network service accounts of a domain-joined machine (for example from a webshell on a Windows server) using ADCS.
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 design of virtual service accounts, which fall back to the machine account for domain authentication, combined with ADCS allowing machine accounts to enrol in certificate templates that permit PKINIT authentication.
Impact
An attacker with a web shell as a virtual or network service account could escalate to local SYSTEM on the compromised machine and potentially move laterally within the domain.
What the attacker needed
Web shell as virtual/network service account; domain-joined machine; ADCS with default Machine template; ability to run tools like Rubeus
The fix
The initial access vulnerability should be fixed, and for sensitive servers, group-managed or standalone managed service accounts with restrictive Active Directory permissions should be used instead of virtual accounts.
How it was found
- Obtain a web shell on the IIS server running as the default application pool identity.
- Use the TGT delegation trick (e.g., Rubeus tgtdeleg) to get a usable TGT for the machine account.
- Convert the TGT to ccache format and load it.
- Use certipy with the TGT to request a certificate from the default Machine template.
- Use PKINIT authentication with the certificate to obtain the machine account's NT hash.
- Forge a Silver ticket for the CIFS service using the machine account hash and use it to authenticate as SYSTEM.
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 a web server runs under a virtual service account, any network authentication it performs uses the computer's own domain account (the machine account). The author shows that from a web shell you can get a Kerberos ticket for that machine account, use it to request a certificate from Active Directory Certificate Services, and then use that certificate to obtain the machine account's password hash. With that hash, you can forge a ticket that grants full SYSTEM access on the server.
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.