Kerberos Double Hop Problem

Double Hop Problem with WinRM/Powershell:
Double Hop problem commonly occurs when using WinRM and PowerShell.
Default WinRM authentication provides access only to specific resources, leading to access issues for lateral movement or accessing file shares from a remote shell.
User accounts may have rights to perform actions but are denied access due to authentication limitations.
Shells can be obtained by attacking applications on the target host or using credentials and tools like PSExec.
Initial authentication is often performed over SMB or LDAP, leading to the storage of NTLM Hash in memory.
WinRM is a preferred method for authentication in some cases.
Credential Caching Issue:
The core problem is that WinRM does not cache the user's password when authenticating over multiple connections.
When using Mimikatz to examine the session, all credentials appear blank.
With Kerberos-based remote sessions, password authentication is not used.
In scenarios like PSExec, where password authentication is used, the NTLM hash is stored in the session's memory.
This stored hash allows the machine to authenticate the user when accessing another resource.
In the simplest terms, in this situation, when we try to issue a multi-server command, our credentials will not be sent from the first machine to the second.

When connecting to a remote system like DEV01 using a tool such as evil-winrm, network authentication is used, and user credentials are not stored in memory on the remote system.
The absence of stored credentials means that there are no credentials available to authenticate to other resources on behalf of the user.
When using tools like PowerView to query Active Directory, Kerberos does not recognize the user's ability to access domain resources because the user's Kerberos Ticket Granting Ticket (TGT) is not sent to the remote session.
This absence of the TGT ticket means that the user cannot prove their identity when trying to access resources, resulting in commands no longer running in the user's context.
Specifically, during authentication to the target host, the user's Ticket Granting Service (TGS) ticket is sent to the remote service, enabling command execution. However, the user's TGT ticket is not sent.
When attempting to access additional resources within the domain, the user's TGT is not included in the request, causing the remote service to be unable to validate the authentication attempt. As a result, access to the remote service is denied.
In essence, the absence of the TGT ticket in the remote session prevents the user from proving their identity when accessing domain resources, leading to access denial.
If unconstrained delegation is enabled on a server, it is likely we won't face the "Double Hop" problem. In this scenario, when a user sends their TGS ticket to access the target server, their TGT ticket will be sent along with the request. The target server now has the user's TGT ticket in memory and can use it to request a TGS ticket on their behalf on the next host they are attempting to access. In other words, the account's TGS Ticket is cached, which has the ability to sign TGTs and grant remote access.
Generally speaking, if you land on a box with unconstrained delegation, you already won and aren't worrying about this anyways.
Workarounds
Workaround #1: PSCredential Object
We can also connect to the remote host via host A and set up a PSCredential object to pass our credentials again. Let's see that in action.
After connecting to a remote host with domain credentials, we import PowerView and then try to run a command. As seen below, we get an error because we cannot pass our authentication on to the Domain Controller to query for the SPN accounts.
Let's set up a PSCredential object and try again. First, we set up our authentication.
Now we can try to query the SPN accounts using PowerView and are successful because we passed our credentials along with the command.
If we RDP to the same host, open a CMD prompt, and type klist, we'll see that we have the necessary tickets cached to interact directly with the Domain Controller, and we don't need to worry about the double hop problem. This is because our password is stored in memory, so it can be sent along with every request we make.
Workaround #2: Register PSSession Configuration
One trick we can use here is registering a new session configuration using the Register-PSSessionConfiguration cmdlet.
Once this is done, we need to restart the WinRM service by typing Restart-Service WinRM in our current PSSession. This will kick us out, so we'll start a new PSSession using the named registered session we set up previously.
After we start the session, we can see that the double hop problem has been eliminated, and if we type klist, we'll have the cached tickets necessary to reach the Domain Controller. This works because our local machine will now impersonate the remote machine in the context of the backupadm user and all requests from our local machine will be sent directly to the Domain Controller.
We can now run tools such as PowerView without having to create a new PSCredential object.
Note: We cannot use Register-PSSessionConfiguration from an evil-winrm shell because we won't be able to get the credentials popup. Furthermore, if we try to run this by first setting up a PSCredential object and then attempting to run the command by passing credentials like -RunAsCredential $Cred, we will get an error because we can only use RunAs from an elevated PowerShell terminal.
Therefore, this method will not work via an evil-winrm session as it requires GUI access and a proper PowerShell console. Furthermore, in our testing, we could not get this method to work from PowerShell on a Parrot or Ubuntu attack host due to certain limitations on how PowerShell on Linux works with Kerberos credentials. This method is still highly effective if we are testing from a Windows attack host and have a set of credentials or compromise a host and can connect via RDP to use it as a "jump host" to mount further attacks against hosts in the environment. .
Last updated