Pass the hash explained

In computer security, pass the hash is a hacking technique that allows an attacker to authenticate to a remote server or service by using the underlying NTLM or LanMan hash of a user's password, instead of requiring the associated plaintext password as is normally the case. It replaces the need for stealing the plaintext password to gain access with stealing the hash.

The attack exploits an implementation weakness in the authentication protocol, where password hashes remain static from session to session until the password is next changed.

This technique can be performed against any server or service accepting LM or NTLM authentication, whether it runs on a machine with Windows, Unix, or any other operating system.

Description

On systems or services using NTLM authentication, users' passwords are never sent in cleartext over the wire. Instead, they are provided to the requesting system, like a domain controller, as a hash in a response to a challenge–response authentication scheme.[1]

Native Windows applications ask users for the cleartext password, then call APIs like LsaLogonUser[2] that convert that password to one or two hash values (the LM or NT hashes) and then send that to the remote server during NTLM authentication.[3] [4]

If an attacker has the hashes of a user's password, they do not need the cleartext password; they can simply use the hash to authenticate with a server and impersonate that user.[5] [6] [7] In other words, from an attacker's perspective, hashes are functionally equivalent to the original passwords that they were generated from.

History

The pass the hash technique was originally published by Paul Ashton in 1997[7] and consisted of a modified Samba SMB client that accepted user password hashes instead of cleartext passwords. Later versions of Samba and other third-party implementations of the SMB and NTLM protocols also included the functionality.

This implementation of the technique was based on an SMB stack created by a third-party (e.g., Samba and others), and for this reason suffered from a series of limitations from a hacker's perspective, including limited or partial functionality: The SMB protocol has continued to evolve over the years, this means that third parties creating their own implementation of the SMB protocol need to implement changes and additions to the protocol after they are introduced by newer versions of Windows and SMB (historically by reverse engineering, which is very complex and time-consuming). This means that even after performing NTLM authentication successfully using the pass the hash technique, tools like Samba's SMB client might not have implemented the functionality the attacker might want to use. This meant that it was difficult to attack Windows programs that use DCOM or RPC.

Also, because attackers were restricted to using third-party clients when carrying out attacks, it was not possible to use built-in Windows applications, like Net.exe or the Active Directory Users and Computers tool amongst others, because they asked the attacker or user to enter the cleartext password to authenticate, and not the corresponding password hash value.

In 2008, Hernan Ochoa published a tool called the "Pass-the-Hash Toolkit"[8] that allowed 'pass the hash' to be performed natively on Windows. It allowed the user name, domain name, and password hashes cached in memory by the Local Security Authority to be changed at runtime after a user was authenticated — this made it possible to 'pass the hash' using standard Windows applications, and thereby to undermine fundamental authentication mechanisms built into the operating system.

The tool also introduced a new technique which allowed dumping password hashes cached in the memory of the lsass.exe process (not in persistent storage on disk), which quickly became widely used by penetration testers (and attackers). This hash harvesting technique is more advanced than previously used techniques (e.g. dumping the local Security Accounts Manager database (SAM) using pwdump and similar tools), mainly because hash values stored in memory could include credentials of domain users (and domain administrators) that logged into the machine. For example, the hashes of authenticated domain users that are not stored persistently in the local SAM can also be dumped. This makes it possible for a penetration tester (or attacker) to compromise a whole Windows domain after compromising a single machine that was a member of that domain. Furthermore, the attack can be implemented instantaneously and without any requirement for expensive computing resources to carry out a brute force attack.

This toolkit has subsequently been superseded by "Windows Credential Editor", which extends the original tool's functionality and operating system support.[9] [10] Some antivirus vendors classify the toolkit as malware.[11] [12]

Hash harvesting

Before an attacker can carry out a pass-the-hash attack, they must obtain the password hashes of the target user accounts. To this end, penetration testers and attackers can harvest password hashes using a number of different methods:

Mitigations

Any system using LM or NTLM authentication in combination with any communication protocol (SMB, FTP, RPC, HTTP etc.) is at risk from this attack.[1] The exploit is very difficult to defend against, due to possible exploits in Windows and applications running on Windows that can be used by an attacker to elevate their privileges and then carry out the hash harvesting that facilitates the attack. Furthermore, it may only require one machine in a Windows domain to not be configured correctly or be missing a security patch for an attacker to find a way in. A wide range of penetration testing tools are furthermore available to automate the process of discovering a weakness on a machine.

There is no single defense against the technique, thus standard defense in depth practices apply[13] – for example use of firewalls, intrusion prevention systems, 802.1x authentication, IPsec, antivirus software, reducing the number of people with elevated privileges,[14] pro-active security patching[15] etc. Preventing Windows from storing cached credentials may limit attackers to obtaining hashes from memory, which usually means that the target account must be logged into the machine when the attack is executed.[16] Allowing domain administrators to log into systems that may be compromised or untrusted will create a scenario where the administrators' hashes become the targets of attackers; limiting domain administrator logons to trusted domain controllers can therefore limit the opportunities for an attacker.[13] The principle of least privilege suggests that a least user access (LUA) approach should be taken, in that users should not use accounts with more privileges than necessary to complete the task at hand.[13] Configuring systems not to use LM or NTLM can also strengthen security, but newer exploits are able to forward Kerberos tickets in a similar way.[17] Limiting the scope of debug privileges on system may frustrate some attacks that inject code or steal hashes from the memory of sensitive processes.[13]

Restricted Admin Mode is a new Windows operating system feature introduced in 2014 via security bulletin 2871997, which is designed to reduce the effectiveness of the attack.[18]

See also

External links

Notes and References

  1. Why Crack When You Can Pass the Hash?. 12 October 2009. SANS Institute. Chris Hummel.
  2. Web site: LsaLogonUser. 7 September 2011. 25 October 2011. Microsoft.
  3. Note that Windows may use Kerberos authentication by default.
  4. Web site: How Interactive Logon Works. 22 January 2009. 25 October 2011. Microsoft.
  5. Web site: What is a Pass-the-Hash Attack (PtH)? . BeyondTrust . 2023-08-04 . 2024-06-23 . https://web.archive.org/web/20240515111754/https://www.beyondtrust.com/resources/glossary/pass-the-hash-pth-attack . 2024-05-15 . live.
  6. Web site: Lenaerts-Bergmans . Bart . What is a Pass-the-Hash Attack? . crowdstrike.com . 2024-02-21 . 2024-06-23 . https://web.archive.org/web/20240407190414/https://www.crowdstrike.com/cybersecurity-101/pass-the-hash/ . 2024-04-07 . live.
  7. Web site: Windows Attack — Gain Enterprise Admin Privileges in 5 Minutes. Daniel Stirnimann. Compass Security AG. 9 August 2010. 10 October 2010.
  8. Web site: What is Pass-The-Hash Toolkit?. Hernan Ochoa. 2 July 2008. 20 October 2011.
  9. WCE Internals. Hernan Ochoa. RootedCON. 2011.
  10. Web site: Windows Credentials Editor (WCE) F.A.Q.. Hernan Ochoa. Amplia Security. 2011. 25 October 2011.
  11. Web site: SecurityRisk.WinCredEd. https://web.archive.org/web/20120413100903/http://www.symantec.com/security_response/writeup.jsp?docid=2011-032115-3507-99. dead. April 13, 2012. Symantec. 21 March 2011. 25 October 2011.
  12. Web site: HackTool:Win32/Wincred.A. 1 October 2011. 25 October 2011. Microsoft.
  13. Pass-the-hash attacks: Tools and Mitigation. Bashar Ewaida. 21 January 2010. SANS Institute.
  14. Stop pass-the-hash attacks before they begin . Roger Grimes. 26 July 2011. 25 October 2011. InfoWorld.
  15. Book: Seven Deadliest Microsoft Attacks. Rob Kraus . Brian Barber . Mike Borkin . Naomi Alpern . 12–14. 978-1-59749-551-6. 2010. Syngress.
  16. Web site: Preventing Pass-the-Hash Attacks and Cached Credential Attacks. Berkley Lab Computer Protection Program. 20 October 2011.
  17. Web site: Microsoft Windows Kerberos 'Pass The Ticket' Replay Security Bypass Vulnerability. 12 March 2016. 20 October 2010. 13 August 2010. securityfocus.com. https://web.archive.org/web/20160312213027/http://www.securityfocus.com/bid/42435/info.
  18. Web site: Microsoft Security Advisory 2871997 . 14 October 2022 .