I recently did some work integrating Duo MFA with Amazon WorkSpaces. The integration work ran into a few challenges, and I wanted to blog about those challenges to help others in the future.
Understanding Amazon WorkSpaces
If you couldn’t tell by the name, Amazon WorkSpaces is a cloud-hosted Desktop-as-a-Service offering that runs on Amazon Web Services (AWS). It utilizes AWS’s underlying infrastructure to deploy desktop workloads, either using licensing provided by Amazon or the customer. The benefit of this over on-premises VDI solutions is that Amazon manages the management infrastructure. Amazon also provides multiple methods to integrate with the customer’s Active Directory environment, so users can continue to use their existing credentials to access the deployed desktops.
WorkSpaces uses an implementation of the PCoIP protocol for accessing desktops from the client application, and the client application is available on Windows, Linux, MacOS, iOS, and Android. Amazon also has a web-based client that allows users to access their desktop from a web browser. This feature is not enabled by default.
Anyway, that’s a very high-level overview of WorkSpaces.
Understanding How Users Connect to WorkSpaces
Before we can talk about how to integrate any multi-factor authentication solution into WorkSpaces, let’s go through the connection path and how that impacts how MFA is used. WorkSpaces differs from traditional on-premises VDI in that all user connections to the desktop go through a public-facing service. This happens even if I have a VPN tunnel or use DirectConnect.
The following image illustrates the connection path between the users and the desktop when a VPN connection is in place between the on-premises environment and AWS:
Image courtesy of AWS, retrieved from http://docs.aws.amazon.com/workspaces/latest/adminguide/prep_connect.html
As you can see from the diagram, on-premises users don’t connect to the WorkSpaces over the VPN tunnel – they do it over the Internet. They are coming into their desktop from an untrusted connection, even if the endpoint they are connecting from is on a trusted network.
Note: The page that I retrieved this diagram from shows users connecting to WorkSpaces over a DirectConnect link when one is present. This diagram shows a DirectConnect link that has a public endpoint, and all WorkSpaces connections are routed through this public endpoint. In this configuration, logins are treated the same as logins coming in over the Internet.
When multi-factor authentication is configured for WorkSpaces, it is required for all user logins. There is no way to configure rules to apply MFA to users connecting from untrusted networks because WorkSpaces sees all connections coming in on a public, Internet-facing service.
WorkSpaces MFA Requirements
WorkSpaces only works with MFA providers that support RADIUS. The RADIUS servers can be located on-premises or in AWS. I recommend placing the RADIUS proxies in another VPC in AWS where other supporting infrastructure resources, like AD Domain Controllers, are located. These servers can be placed in the WorkSpaces VPC, but I wouldn’t recommend it.
WorkSpaces can use multiple RADIUS servers,and it will load-balance requests across all configured RADIUS servers. RADIUS can be configured on both the Active Directory Connectors and the managed Microsoft AD directory services options.
Note: The Duo documentation states that RADIUS can only be configured on the Active Directory Connector. Testing shows that RADIUS works on both enterprise WorkSpaces Directory Services options.
Configuring Duo
Before we can enable MFA in WorkSpaces, Duo needs to be configured. At least one Duo proxy needs to be reachable from the WorkSpaces VPC. This could be on a Windows or Linux EC2 instance in the WorkSpaces VPC, but it will most likely be an EC2 instance in a shared services or management VPC or in an on-premises datacenter. The steps for installing the Duo Proxies are beyond the scope of this article, but they can be found in the Duo documentation.
Before the Duo Authentication Proxies are configured, we need to configure a new application in the Duo Admin console. This step generates an integration key and secret key that will be used by the proxy and configure how new users will be handled. The steps for creating the new application in Duo are:
1. Log into your Duo Admin Console at https://admin.duosecurity.com
2. Login as your user and select the two-factor authentication method for your account. Once you’ve completed the two-factor sign-on, you will have access to your Duo Admin panel.
3. Click on Applications in the upper left-hand corner.
4. Click on Protect an Application
5. Search for RADIUS.
6. Click Protect this Application underneath the RADIUS application.
7. Record the Integration Key, Secret Key, and API Hostname. These will be used when configuring the Duo Proxy in a few steps.
8. Provide a Name for the Application. Users will see this name in their mobile device if they use Duo Push.
9. Set the New User Policy to Deny Access. Deny Access is required because the WorkSpaces setup process will fail if Duo is configured to fail open or auto-enroll.
10. Click Save Changes to save the new application.
Get the AWS Directory Services IP Addresses
The RADIUS Servers need to know which endpoints to accept RADIUS requests from. When WorkSpaces is configured for MFA, these requests come from the Directory Services instance. This can either be the Active Directory Connectors or the Managed Active Directory domain controllers.
The IP addresses that will be required can be found in the AWS Console under WorkSpaces –> Directories. The field to use depends on the directory service type you’re using. If you’re using Active Directory Connectors, the IP addresses are in the Directory IP Address field. If you’re using the managed Microsoft AD service, the Directory IP address field has a value of “None,” so you will need to use the IP addresses in the DNS Address field.
Configure AWS Security Group Rules for RADIUS
By default, the AWS security group for the Directory Services instance heavily restrict the inbound and outbound traffic. In order to enable RADIUS, you’ll need to add inbound and outbound UDP 1812 to the destination destination IPs or subnet where the proxies are located.
The steps for updating the AWS security group rules are:
1. Log into the AWS Console.
2. Click on the Services menu and select WorkSpaces.
3. Click on Directories.
4. Copy the value in the Directory ID field of the directory that will have RADIUS configured.
5. Click on the Services menu and select VPC.
6. Click on Security Groups.
7. Paste the Directory ID into the Search field to find the Security Group attached to the Directory Services instance.
8. Select the Security Group.
9. Click on the Inbound Rules tab.
10. Click Edit.
11. Click Add Another Rule.
12. Select Custom UDP Rule in the Type dropdown box.
13. Enter 1812 in the port range field.
14. Enter the IP Address of the RADIUS Server in the Source field.
15. Repeat Steps 11 through 14 as necessary to create inbound rules for each Duo Proxy.
16. Click Save.
17. Click on the Outbound Rules tab.
18. Click Edit.
19. Click Add Another Rule.
20. Select Custom UDP Rule in the Type dropdown box.
21. Enter 1812 in the port range field.
22. Enter the IP Address of the RADIUS Server in the Source field.
23. Repeat Steps 11 through 14 as necessary to create inbound rules for each Duo Proxy.
24. Click Save.
Configure the Duo Authentication Proxies
Once the Duo side is configured and the AWS security rules are set up, we need to configure our Authentication Proxy or Proxies. This needs to be done locally on each Authentication Proxy. The steps for configuring the Authentication Proxy are:
Note: This step assumes the authentication proxy is running on Windows.The steps for installing the authentication proxy are beyond the scope of this article. You can find the directions for installing the proxy at: https://duo.com/docs/
1. Log into your Authentication Proxy.
2. Open the authproxy.cfg file located in C:\Program Files (x86)\Duo Security Authentication Proxy\conf.
Note: The authproxy.cfg file uses the Unix newline setup, and it may require a different text editor than Notepad. If you can install it on your server, I recommend Notepad++ or Sublime Text.
3. Add the following lines to your config file. This requires the Integration Key, Secret Key, and API Hostname from Duo and the IP Addresses of the WorkSpaces Active Directory Connectors or Managed Active Directory domain controllers. Both RADIUS servers need to use the same RADIUS shared secret, and it should be a complex string.
[duo_only_client]
[radius_server_duo_only]
ikey=<Integration Key>
skey=<Secret Key>
api_host=<API Hostname>.duosecurity.com
failmode=safe
radius_ip_1=Directory Service IP 1
radius_secret_1=Secret Key
radius_ip_2=Directory Service IP 2
radius_secret_2=Secret Key
port=1812
4. Save the configuration file.
5. Restart the Duo Authentication Proxy Service to apply the new configuration.
Integrating WorkSpaces with Duo
Now that our base infrastructure is configured, it’s time to set up Multi-Factor Authentication in WorkSpaces. MFA is configured on the Directory Services instance. If multiple directory services instances are required to meet different WorkSpaces use cases, then this configuration will need to be performed on each directory service instance.
The steps for enabling WorkSpaces with Duo are:
1. Log into the AWS Console.
2. Click on the Services menu and select Directory Service.
3. Click on the Directory ID of the directory where MFA will be enabled.
4. Click the Multi-Factor authentication tab.
5. Click the Enable Multi-Factor Authentication checkbox.
6. Enter the IP address or addresses of your Duo Authentication Proxies in the RADIUS Server IP Address(es) field.
7. Enter the RADIUS Shared Secret in the Shared Secret Code and Confirm Shared Secret Code fields.
8. Change the Protocol to PAP.
9. Change the Server Timeout to 20 seconds.
10. Change the Max Retries to 3.
11. Click Update Directory.
12. If RADIUS setup is successful, the RADIUS Status should say Completed.
Using WorkSpaces with Duo
Once RADIUS is configured, the WorkSpaces client login prompt will change. Users will be prompted for an MFA code along with their username and password. This can be the one-time password generated in the mobile app, a push, or a text message with a one-time password. If the SMS option is used, the user’s login will fail, but they will receive a text message with a one-time password. They will need to log in again using one of the codes received in the text message.
Troubleshooting
If the RADIUS setup does not complete successfully, there are a few things that you can check. The first step is to verify that port 1812 is open on the Duo Authentication Proxies. Also verify that the security group the directory services instance is configured to allow port 1812 inbound and outbound.
One issue that I ran into in previous setups was the New User Policy in the Duo settings. If it is not set to Deny Access, the process setup process will fail. WorkSpaces is expecting a response code of Access Reject. If it receives anything else, the process stalls out and fails about 15 minutes later.
Finally, review the Duo Authentication Proxy logs. These can be found in C:\Program Files (x86)\Duo Security Authentication Proxy\log on Authentication Proxies running Windows. A tool like WinTail can be useful for watching the logs in real-time when trying to troubleshoot issues or verify that the RADIUS Services are functioning correctly.