Pass the Cookie and Pivot to the Clouds

by Johann Rehberger

Web applications and services use cookies to authenticate sessions and users.

An adversary can pivot from a compromised host to web applications and Internet services by stealing authentication cookies from browsers and related processes.  At the same time this technique bypasses most multi-factor authentication protocols.

The reason for this is that the final authentication token that the attacker steals is issued after all factors have been validated.  Many users persist cookies that are valid for an extended period of time, even if the web application is not actively used.  Cookies can be found on disk and also in process memory.  Additionally, other applications on the target's machine might store sensitive authentication tokens in memory (e.g. apps which authenticate to cloud services).  This pivoting technique can be extended to bearer tokens, JSON Web Token (JWT), and the likes.

Pass the Cookie is a post-exploitation technique to perform session hijacking.

So, let's Pass the Cookie and Pivot to the Clouds.

Attack Chain

Disclaimer:  Always make sure you have proper authorization before pen-testing.

Pass the Cookie is done via the following steps (variations exist):

The following is a graphical representation during a typical red team operation, highlighting the steps:

Considering that cloud service providers for many companies are like a virtual data center, the cookie is comparable to the main entry key to the virtual facility.  Pass the Cookie also works on other online services like mail, social media, etc.

Mitigations

To protect oneself from these attacks, it's important to stay up to date with security patches, etc. to ensure your host does not get compromised.  As seasoned security engineer, you assume the worst.  Here are some ideas on how to mitigate implications of an attack:

Detections

When it comes to detections, a few things come to mind:

Acquiring Cookies - Tools and Techniques

In case you don't won't to write your own toolset, there are a couple of options available to gain access to cookies:

There are also good articles online describing how to access and decrypt the cookies in the SQLLite databases, as well if you'd like to dig into more under the covers.

Conclusion

Pass the Cookie is a powerful post-exploitation technique to pivot from on-premise machines to cloud assets.  It can be leveraged to bypass Multi-Factor Authentication (MFA) techniques, as the cookie is - in the end - still a single factor.

Hopefully this was helpful, so you can build better detections, improvements and tests into your infrastructure to catch malicious activity.

Return to $2600 Index