{"id":384,"date":"2013-07-03T16:00:39","date_gmt":"2013-07-03T20:00:39","guid":{"rendered":"http:\/\/adsecurity.org\/?p=384"},"modified":"2016-01-02T18:11:40","modified_gmt":"2016-01-02T23:11:40","slug":"using-group-policy-preferences-for-password-management-bad-idea","status":"publish","type":"post","link":"https:\/\/adsecurity.org\/?p=384","title":{"rendered":"Using Group Policy Preferences for Password Management = Bad Idea"},"content":{"rendered":"<h4><strong>Using Group Policy Preferences for Password Management = Bad Idea OR \u201cHow to Get Your Network Owned in Several Simple Steps\u201d<\/strong><\/h4>\n<p>One of my customers recently needed to change the local administrator password on several hundred Windows 7 workstations and was trying to determine the best method: PowerShell script or Group Policy Preferences.<\/p>\n<p>The easy answer is to use Group Policy Preferences since it has a built-in mechanism for changing\/managing local computer passwords. The problem is that while the password in Group Policy Preferences is encrypted using AES 256, <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/2c15cbf0-f086-4c74-8b70-1f2fa45dd4be.aspx#endNote2\">the private key for the encryption is posted on MSDN<\/a>. This means that Group Policy Preferences is vulnerable to password exposure.<\/p>\n<p>Since the private key for this data is well known, using Group Policy Preferences to manage local computer passwords means these passwords are vulnerable to discovery. Since the Group Policy Preference data is stored in an XML file in SYSVOL (such as drives.xml, groups.xml, printers.xml, etc), all authenticated users in the domain has read access (they have to in order to apply Group Policy). This means that any authenticated user can open the Group Policy Preference XML file with the encrypted password and decrypt it using the <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/2c15cbf0-f086-4c74-8b70-1f2fa45dd4be.aspx#endNote2\">AES key posted on MSDN<\/a>. This AES key is part of every Windows computer that is Group Policy Preferences capable (native support in Windows 7 and newer; Windows Vista with an install; and Windows XP SP 2 &amp; Windows 2003 SP1 with a patch, <a href=\"https:\/\/www.microsoft.com\/en-us\/download\/details.aspx?id=3628\">KB943729<\/a>) in order for the computers to decrypt the password and use it. If the Group Policy Preference requires a password to be entered, it is stored in an XML file in SYSVOL. <strong>Despite the fact that the password is AES 256-bit encrypted (and <a href=\"http:\/\/blog.csnc.ch\/2012\/04\/exploit-credentials-stored-in-windows-group-policy-preferences\/\">base 64 encoded with padding if necessary<\/a>), it is not secure<\/strong>. Microsoft does not recommend storing passwords in Group Policy Preferences (blog post linked below) and Windows Server 2012 displays a message with a similar warning.<\/p>\n<p>Windows Server 2012 Group Policy Preference password Warning:<\/p>\n<p><a href=\"http:\/\/blogs.metcorpconsulting.com\/tech\/wp-content\/uploads\/2013\/07\/Windows2012-GPP-password-warning.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-1700\" src=\"https:\/\/blogs.metcorpconsulting.com\/tech\/wp-content\/uploads\/2013\/07\/Windows2012-GPP-password-warning.jpg\" alt=\"Windows2012-GPP-password-warning\" width=\"332\" height=\"132\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><i>More information on how Group Policy Preferences are attacked is in the post &#8220;<a href=\"https:\/\/adsecurity.org\/?p=2288\">Finding Passwords in SYSVOL &amp; Exploiting Group Policy Preferences<\/a>&#8220;.<\/i><\/p>\n<p>Here\u2019s a sample groups.xml file from SYSVOL representing a Group Policy using Group Policy Preferences to add a new user to computers in the linked OU.<\/p>\n<p>&lt;?xml version=\u201d1.0\u2033 encoding=\u201dutf-8\u2033?&gt;<br \/>\n&lt;Groups clsid=\u201d{3125E937-EB16-4b4c-9934-544FC6D24D26}\u201d&gt;<br \/>\n&lt;User clsid=\u201d{DF5F1855-51E5-4d24-8B1A-D9BDE98BA1D1}\u201d name=\u201dLocalTestUser\u201d image=\u201d0\u2033 changed=\u201d2013-07-04 00:07:13\u2033 uid=\u201d{47F24835-4B58-4C48-A749-5747EAC84669}\u201d&gt;<br \/>\n&lt;Properties action=\u201dC\u201d fullName=\u201d\u201d description=\u201d\u201d <strong>cpassword=\u201dsFWOJZOU7bJICaqvmd+KAEN0o4RcpxxMLWnK7s7zgNR+JiJwoSa+DLU3kAIdXc1WW5NKrIjIe9MIdBuJHvqFgbcNS873bDK2nbQBqpydkjbsPXV0HRPpQ96phie6N9tn4NF3KYyswokkDnj8gvuyZBXqoG94ML8M1Iq7\/jhe37eHJiZGyi5IBoPuCfKpurj2\u2033<\/strong> changeLogon=\u201d0\u2033 noChange=\u201d0\u2033 neverExpires=\u201d0\u2033 acctDisabled=\u201d0\u2033 userName=\u201dLocalTestUser\u201d\/&gt;<br \/>\n&lt;\/User&gt;<br \/>\n&lt;\/Groups&gt;<\/p>\n<p><strong>cpassword<\/strong> above represents the encrypted password and I was able to browse to and save this file from SYSVOL with a regular domain user account. All that is left to do is to perform a Base64 unencode, then decrypt using the MSDN AES key.<\/p>\n<p>Here\u2019s the 32-byte AES key used to encrypt ALL Group Policy Preferences passwords in any domain:<\/p>\n<blockquote>\n<pre>4e 99 06 e8  fc b6 6c c9  fa f4 93 10  62 0f fe e8\r\nf4 96 e8 06  cc 05 79 90  20 9b 09 a4  33 b6 6c 1b<\/pre>\n<\/blockquote>\n<p><strong>The problem is that since the AES encryption (and decryption) key is known (and posted publicly on <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/2c15cbf0-f086-4c74-8b70-1f2fa45dd4be.aspx#endNote2\">MSDN <\/a>and here), Group Policy Preferences can\u2019t be considered a secure method for changing passwords.<\/strong><\/p>\n<p>The <a href=\"https:\/\/blogs.technet.com\/b\/grouppolicy\/\">Microsoft Group Policy Blog<\/a> posted about <a href=\"http:\/\/blogs.technet.com\/b\/grouppolicy\/archive\/2009\/04\/22\/passwords-in-group-policy-preferences-updated.aspx?Redirected=true\">the potential issues in 2009<\/a>:<\/p>\n<blockquote><p><strong>Are passwords in preference items secure?<\/strong><b><br \/>\n<\/b>A password in a preference item is stored in SYSVOL in the GPO containing that preference item. To obscure the password from casual users, it is not stored as clear text in the XML source code of the preference item. However, the password is not secured. Because the password is stored in SYSVOL, all authenticated users have read access to it. Additionally, it can be read by the client in transit if the user has the necessary permissions.<\/p>\n<p>Because passwords in preference items are not secured, we recommend that you carefully consider the security ramifications when deciding whether to store passwords in preference items. If you choose to use this feature, we recommend that you consider creating dedicated accounts for use with it and that you do not store administrative passwords in preference items.<\/p>\n<p><strong>Where can you use passwords?<\/strong><b><br \/>\n<\/b>You can use passwords in the following types of preference items:<\/p>\n<ul>\n<li><strong>Local User preference items:<\/strong> When you create or modify a local user account, you can specify both a user name and a password for the account.<\/li>\n<li><strong>Data Source preference items:<\/strong> If a user name and password are required to access the data source, you can provide them in the preference item. If you do so, end users to whom the preference item applies can access the data source regardless of their own permissions, but only if the specified account has the necessary permissions.<\/li>\n<li><strong>Mapped Drive preference items:<\/strong> You can specify the user name and password to be used to connect to a mapped drive. If you do so, end users to whom the preference item applies can access the mapped drive regardless of their own permissions, but only if the specified account has the necessary permissions.<\/li>\n<li><strong>Scheduled Task or Immediate Task preference items:<\/strong> You can configure a scheduled task to run under the security context of a specified user (allowing the task to run regardless of whether that user is logged on), by selecting the \u201cRun as\u201d check box and providing a user name and password.<\/li>\n<li><strong>Service preference items: <\/strong>You can modify which account the service runs under by selecting \u201cLocal System account\u201d or by selecting \u201cThis account\u201d and specifying a user name and password.<\/li>\n<\/ul>\n<\/blockquote>\n<p><em>If this HAS to be done and you accept the risk, you can set the group policy for a few days and then delete it. However, there is a chance that someone already copied the XML file containing the password and already knows it. Using SCCM or a scripted solution may be the best answer for now, unless you want to pay for a product from <a href=\"http:\/\/www.cyber-ark.com\/digital-vault-products\/pim-suite\/enterprise-password-vault\/index.asp\">CyberArk <\/a>or <a href=\"http:\/\/www.quest.com\/quest-one-privileged-password-manager\/\">Quest<\/a> (note that these products are mentioned for informational purposes only).<\/em><\/p>\n<p>Here\u2019s a PowerShell script I wrote that reports on what credentials are stored in Group Policies.<a href=\"https:\/\/adsecurity.org\/wp-content\/uploads\/2014\/10\/Get-GPOPwd.txt\"> PowerShell Script: Discover Group Policy Passwords<\/a> (updated 10\/2014). Note that it requires the Active Directory PowerShell cmdlets.<\/p>\n<p><strong>Attack Vectors:<\/strong><\/p>\n<ul>\n<li><a href=\"http:\/\/www.metasploit.com\/modules\/post\/windows\/gather\/credentials\/gpp\">MetaSploit has a module for gathering passwords from Group Policy Preferences.<\/a><\/li>\n<li>There\u2019s also a <a href=\"https:\/\/github.com\/mattifestation\/PowerSploit\/tree\/master\/Recon\">PowerShell script<\/a> that can identify and extract the password(s) stored in Group Policy Preferences using <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/2c15cbf0-f086-4c74-8b70-1f2fa45dd4be.aspx#endNote2\">the MSDN AES key<\/a>.<br \/>\nHere\u2019s the<a href=\"http:\/\/obscuresecurity.blogspot.com\/2012\/05\/gpp-password-retrieval-with-powershell.html\"> original post with the PowerShell script<\/a> that is now hosted and updated on <a href=\"https:\/\/github.com\/mattifestation\/PowerSploit\">GitHub\u2019s PowerSploit section<\/a>.<\/li>\n<li>Details on how simple the process actually is: <a href=\"http:\/\/blog.csnc.ch\/2012\/04\/exploit-credentials-stored-in-windows-group-policy-preferences\/\">Exploit credentials stored in Windows Group Policy Preferences<\/a><\/li>\n<\/ul>\n<p>There is <a href=\"http:\/\/code.msdn.microsoft.com\/Solution-for-management-of-ae44e789\">code on MSDN<\/a> for managing local admin passwords for computers by storing the password in a confidential Active Directory attribute on each computer object. Note that this solution is not supported by Microsoft.<\/p>\n<blockquote><p><strong>Summary<\/strong><\/p>\n<div>\n<p>This sample is a fully working solution that implements automatic management of\u00a0password of builtin Administrator account on computers joined to domain.<\/p>\n<p>Solution currently available out of box on the platform (Group Policy Preferences) does not\u00a0fulfill usual security requirements. Main problems with GPO Preferences are:<\/p>\n<ul>\n<li>Password is the same on many workstations<\/li>\n<li>Password stored in GPO and transported over network is not encrypted, but\u00a0obfuscated (and obfuscation algorithm is published on MSDN),\u00a0so it is not secure solution<\/li>\n<\/ul>\n<p>Solution implemented by this sample does not have such weak points.<\/p>\n<\/div>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Using Group Policy Preferences for Password Management = Bad Idea OR \u201cHow to Get Your Network Owned in Several Simple Steps\u201d One of my customers recently needed to change the local administrator password on several hundred Windows 7 workstations and was trying to determine the best method: PowerShell script or Group Policy Preferences. The easy &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"https:\/\/adsecurity.org\/?p=384\">Continue reading<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,2],"tags":[190,191,194,192,193],"class_list":["post-384","post","type-post","status-publish","format-standard","hentry","category-microsoft-security","category-technical-reference","tag-gposecurity","tag-grouppolicypreferencespassword","tag-grouppolicypreferencesvulnerability","tag-grouppolicysecurity","tag-localadminpassword","item-wrap"],"_links":{"self":[{"href":"https:\/\/adsecurity.org\/index.php?rest_route=\/wp\/v2\/posts\/384","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/adsecurity.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/adsecurity.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/adsecurity.org\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/adsecurity.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=384"}],"version-history":[{"count":6,"href":"https:\/\/adsecurity.org\/index.php?rest_route=\/wp\/v2\/posts\/384\/revisions"}],"predecessor-version":[{"id":2438,"href":"https:\/\/adsecurity.org\/index.php?rest_route=\/wp\/v2\/posts\/384\/revisions\/2438"}],"wp:attachment":[{"href":"https:\/\/adsecurity.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=384"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/adsecurity.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=384"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/adsecurity.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=384"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}