WCX files can be used to configure a Microsoft Workplace on a system with a couple of clicks. The enrollment process could disclose credentials in the form of a NetNTLM hash. Authentication will either take place automatically on older Windows versions or will prompt a user for credentials on more recent ones. Workplaces can potentially be further weaponised as part of a wider social engineering campaign.
Sometimes, the most dangerous attack payloads are those that leverage native functionality in its intended way. Particularly if it is not widely adopted or perceived to be dangerous. Whilst conducting some research into hardening of Windows systems and potentially dangerous file extensions, I came across the WCX file extension. If you create a file with this extension on a Windows platform you will notice it will gain a 'Microsoft Remote Desktop' looking icon, a hint to what this corresponds to. It turns out that this format is used to provision Microsoft Workplaces where you farm out your applications or desktops to a Terminal Services Farm. Naturally, Microsoft makes the provisioning process as easy as possible and you are one click of a .wcx file away from setting up a 'Workplace'. What happens when you do this?
The WCX file format looks like the following – and I have not seen anything more exotic in files I have seen or any specifications:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<workspace name="abc Remote Access" xmlns="http://schemas.microsoft.com/ts/2008/09/tswcx" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<defaultFeed url="https://example.org/" />
As you can see, a file simply contains a URL to a remote web server. This URL should link to an XML file that contains the information required to set-up applications and desktops.
Clicking on a .wcx file gives you the following warning:
Warning observed that is when clicking on a .wcx file
Now, if you read the technical specification one interesting thing that jumped out straightaway was the following "[The authentication process is] achieved using the Simple and Protected GSS-API Negotiation Mechanism (SPNEGO)-based Kerberos and the NT LAN Manager (NTLM) Authentication Protocol over HTTP, as specified in [RFC4559]." Having read this in the specification I started working on a tool which sets to mimic a Remote Desktop server, handling authentication and delivering all the things required for a successful enrollment.
Introducing Firework, a python-based tool, which for the NetNTLM web server side borrows most of its code from Responder. Beyond this, it simply generates the required resources and serves them following a successful authentication flow.
My first observations were that clicking 'Next' after clicking on a .wcx file causes Windows 7 host to authenticate over a proxy aware HTTPS connection, providing a NetNTLM hash corresponding to the fixed challenge we presented. This hash could be cracked, or potentially, we could modify the process to relay the hash to an application that we have access to. For more recent versions of Windows such including Windows 10 a user is presented with a credential prompt, which should they submit, the hash makes it way out over HTTPS.
Proof of concept tool showing NetNTLMv2 hash capture
Credential prompt shown on Windows 10 host
After giving away the user hash, Windows should receive a valid feed from the tool which looks something like the following XML:
<?xml version="1.0" encoding="utf-8"?>
<ResourceCollection PubDate="2009-07-09T17:57:30.323Z" SchemaVersion="1.1" xmlns="http://schemas.microsoft.com/ts/2007/05/tswf">
<Publisher LastUpdated="2009-07-09T17:57:12.588625Z" Name="abc" ID="Contoso" Description="">
<Resource ID="2489cc78-44d8-46e8-a35d-5539c481d864" Alias="Excel" Title="Excel" LastUpdated="2009-07-09T17:57:12.588625Z" Type="RemoteApp" ExecutableName="excel.exe">
<IconRaw FileType="ico" FileURL="/2489cc78-44d8-46e8-a35d-5539c481d864.ico" />
<FileExtension Name=".xls" />
<ResourceFile FileExtension=".rdp" URL="/2489cc78-44d8-46e8-a35d-5539c481d864.rdp" />
<TerminalServerRef Ref="Contoso" />
<TerminalServer ID="Contoso" Name="Contoso" LastUpdated="2009-07-09T17:57:12.588625Z" />
The victim who clicked on the .wcx file would have seen the following dialog and now there will be a nice icon in their start menu for our 'Application'.
Successfully setting up a workplace hosted by proof of concept tool
Depending on the target OS version the location varies slightly as you can see in the below examples of Windows 7 and Windows 10 respectively.
Published application appearing in Start-Menu
So, behind the scenes what has happened? Well, Windows has gone and downloaded our .rdp and .ico files from our server to the following path:
Workplace Folder Structure
Additionally, Windows has created a shortcut at the following path:
This links to mstsc.exe with the .rdp connection file we served:
Attempts at introducing dangerous values to a provisioning feed were largely unsuccessful and mostly led to the provisioning or update process to fail. However, using as intended links to arbitrary .rdp files can be installed in the start menu. Depending on the configuration of the target, such files may be used as a wider social engineering campaign. Obviously, the feed parameters give us some scope for making a malicious enrollment more believable, for example, using 'Secure' as an publisher name. It may be possible coerce a user to logon to an attacker controlled RDP server, mapping across local resources or, if an attacker had some knowledge of the target environment, they could potentially configure a connection to a local server, and specify a command to be run upon a successful connection. Such attack scenarios are based upon the scope of the RDP connection files themselves which offer a lot of scope for being creative. In a fairly vanilla recent OS configuration there are typically several warnings that must be clicked through by a user and options such as 'password 51' are ineffective. Content checking on the resource files themselves did not appear that strict, therefore we could potentially hide a payload executed by other means.
Another interesting factor to this workplace provisioning process is that, given the nature of the functionality, it is persistent. A system will attempt continue to update the XML feed to refresh available applications and desktops. This is particularly interesting for Windows 7, in doing so we get a new NetNTLM password hash every day. If we do not force authentication on our feed, on more recent operating systems such as Windows 10 we can refresh resources and items in the start menu regularly.
Scheduled tasks that update workplace feeds
- WCX files and the subsequent Workspace provisioning process offers an interesting attack surface to be explored.
- A successful enrolment could result in a NetNTLMv2 hash being sent over HTTPS every day.
- An attacker could leverage the Workspace functionality to introduce a malicious Application or Desktop deployment as part of a wider social engineering campaign. This in turn could have greater implications i.e. loss of data should local resources be mapped to an attacker's terminal server or a command being run on a local server should this be successfully introduced into a configuration file.
- Customers should look to monitor connections with a User-Agent of
TSWorkspace/1.0 which corresponds to this Windows feature.
- In-line proxies should block or monitor NTLM over HTTPS to prevent possible credential exposure.
- Monitor suspicious writes to the file path:
- Secure Remote Desktop configuration in group policy. Ensure that options are set such as preventing logon without prompting for credentials and preventing redirection of local resources where not required. See 'Computer Configuration/Policies/Administrative Templates/Windows Components/Remote Desktop Services'.
- Check credential delegation settings 'Computer Configuration/Administrative Templates/System/Credentials Delegation'.