How to Configure Conditional Access Reauthentication in Azure PIM

Reading Time: 5 minutes


In this blog post, I’ll provide a step by step guide on how to enforce admin reauthentication when elevating a role in Azure Privileged Identity Management (PIM) using a Conditional Access policy.

But why would you want an admin to reauthenticate?

Once an admin signs in to the Azure portal, they typically don’t need to authenticate again during that session. Sounds convenient, right? But here’s the problem. If an admin needs to access PIM to elevate their role, they can do so without reauthenticating, because they’re already signed in. This creates a potential security risk. If a bad actor gains access to an authenticated session, they could elevate the admin’s role and cause serious damage to your environment.

By enforcing reauthentication through Conditional Access, you add an extra layer of protection. The admin will be required to verify their identity again before they can elevate to a privileged role, helping to prevent unauthorised access and safeguard your platform.

In this blog post I will:

  • create an Authentication Context.
  • create a Conditional Access policy (including the Authentication Context), that prompts for reauthentication when an admin attempts to elevate a role in PIM.
  • associate the Authentication Context with a PIM role
  • test the configuration

Task 1: Create an Authentication Context


Authentication Context can be used to enhance the security of data and actions within applications. These applications might include your own custom apps, line of business (LOB) solutions, SharePoint, or services protected by Microsoft Defender for Cloud Apps.

For example, an organisation may store files in SharePoint sites, ranging from something simple like a lunch menu to something more sensitive like a secret BBQ sauce recipe. While everyone might have access to the lunch menu site, access to the secret BBQ sauce recipe site could require users to be on a managed device, use a FIDO2 security key, and accept specific terms of use. Authentication Context can help enforce these policies.

Authentication Context can also be applied in Privileged Identity Management (PIM). For instance, you might require administrators requesting high privilege roles, such as Global Administrator, to authenticate using a FIDO2 key, only allow access from a trusted location, a compliant device and so on.

In this blog post, we’ll focus on a specific use case, prompting administrators to reauthenticate before an admin role is assigned to them via PIM.

Let’s go through the steps

  1. Access Entra ID via the Azure Portal portal.azure.com or Entra portal at entra.microsoft.com

  2. In the search bar, type Conditional Access and click Microsoft Entra Conditional Access
Image2



3. From the left pane, click Authentication Contexts

Image4


4. Enter a name, description and click save

Image5

Image6

Task 2: Create a Conditional Access policy and associate it with the newly created Authentication Context

  1. Click Policies from the left pane and + New policy
Image7

  • Give your policy a suitable name
  • Target the users/groups
  • Click target resources. From the drop down (Select what this policy applies to) click Authentication Context.
  • The Authentication Context I created earlier is visible for me to select.
  • Don’t save changes just yet

    Continue to step 2 below
Image8



2. Scroll down and click sessions

Image9

  • Click Sign-in frequency
  • Click Every time
  • Click the select button
Image10


3. Switch the toggle to on and click create

Image11


Note: You may wish to leave the toggle on report only mode which will ensure the policy does not apply but will provide you with audit logs. Once convinced all is working as it should do, you can enforce the policy by turning it on. Ensure you test with a group of pilot users.


Task 3: Assign the Conditional Access policy to PIM

  1. Search for and access PIM (Microsoft Entra Privileged Identity Management)
Image12


2. In this example, I’ll be assigning the Authentication Context I created earlier to the User Administrator role. I have a demo user name Darren who has been assigned the User Administrator Role in PIM. Darren is able to elevate/request for the role and the role is automatically removed after a number of hours.

3. From the left pane, click roles. Search and click User Administrator

Image13

4. From the left pane, click Role settings

Image14

5. Click Edit to access the default settings.

Image15

6. Click the option Microsoft Entra Conditional Access Authentication Context. The Authentication Context I created earlier is visible, which is attached to the Conditional Access Policy which forces the admin to reauthenticate every time.

Image16


7. Click update

Image20


Task 4: Test the Reauthentication Policy


I’ll be logging in to Azure Portal with a demo user named Darren. I have already assigned Darren’s account to the User Administrator through PIM. Therefore, Darren is eligible to activate this role when needed. Darren is also included within the Conditional Access Policy scope.

  1. I login as Darren and go through MFA

    Note: we’ll see the Authentication Context and policy trigger later
Image17

2. Whilst logged in as Darren, I search for PIM and click my roles from the left pane.

Image18

Click activate

Image19

3. Darren is presented with a message requesting for additional verification.

Image21

4. Click the message: A Conditional Access policy is enabled and may require additional verification. Click to continue

5. Darren is prompted to login again (reauthenticate)

Image22

Image23


6. and after reauthenticating, Darren can continue to active the role.

Image24


I hope you found this post useful

Thanks for reading and see you at the next one.

User Guide: How to register passkeys in Microsoft Authenticator and physical passkeys

Reading Time: 4 minutes


In this blog post, I explore the steps to enable:

  • Passkeys in the Microsoft Authenticator app using an iPhone
  • Setting up a passkey via a physical Yubikey 5 (usb-c)

Note: This post is targeted at users who want to set up passkeys in the Microsoft Authenticator app or register a physical key. Your administrators must have enabled the capability to use passkeys before you can complete the steps below. To use passkeys via the Authenticator app, you need Android 14 or later, or iOS 17 or later (at the time of writing this post). Additionally, make sure that your Microsoft Authenticator app is updated to the latest version.

If you wish to learn more about how passkeys work, check out my post at: Part 1 – What is a FIDO2 key and How to Set One Up for Emergency Access in Entra ID | Cloud Build


Configure Passkeys in the Microsoft Authenticator App on an iPhone

  1. Access https://mysignins.microsoft.com and login

  2. Click security info from the left pane

  3. Click + Add sign-in method

4. Click the option, Passkey in Microsoft Authenticator


5. You may be prompted to go through MFA before you are able to add a new sign-in method. Please continue with this. When done, continue to step 6.

6. Read the pre-reqs and click next


7. Don’t click Next just yet. You will need to follow the instructions mentioned on your screen first.

  • Open the Microsoft Authenticator app on your phone. Tap on the account/email address you will be setting this passkey for. Keep the app open while you proceed with the setup.
  • Click Create a passkey.
    If this option does not appear, ensure that you have met the pre-reqs I mentioned at the beginning of this post.


8. You will be prompted to sign-in. Click the Sign-in button and login

9. If it is the first time you’re setting up a passkey via the Microsoft Authenticator app, you’ll be prompted to enable a couple of settings on your phone before you are allowed to continue.


10. We’re done with the configuration on the phone. Continue to the step 11 below.


11. Return to your laptop/desktop and click next to complete the process.

That’s it. If you’re interested in configuring a physical key, such as a YubiKey, the next section goes through the process.


Configure a passkey via a physical Yubikey 5 (usb-c)

  1. Access https://mysignins.microsoft.com and login

  2. Click security info from the left pane

  3. Click + Add sign-in method


3. Click the option Security key


4. You may be prompted to go through MFA before you are able to add a new sign-in method. Please continue with this. When done, continue to step 5.

5. Select the type of security key. I select USB device


6. Have your physical key ready, after clicking next, you’ll be prompted to plug it in.


7. Click next and then select Security key (If this option does not appear, click the option other ways to sign-in and then click Security key). Click next.


8. Read and click OK


9. Read and click ok


10. You will be prompted to insert you physical key


11. You will be prompted to create a new PIN


12. Your physical YubiKey will flash and you will be prompted to place you finger on it


13. Passkey saved, click ok


14. Finally, you will be prompted to give your Physical key a name so you can easily identify it.


15. Done


I hope you found this post useful. Catch you at the one

The Evilginx Threat: Protecting Your Credentials with Phishing Resistant MFA

Reading Time: 6 minutes


In this blog post, I demonstrate how to use an Adversary in The Middle (AiTM) phishing attack to capture a user’s session token utilising a tool called Evilginx. There are several methods to protect against such attacks and I will be concentrating on phishing resistant MFA.


IMPORTANT DISCLAIMER:
The user accounts involved are demo user’s. The information provided in this blog post is intended for educational and demonstration purposes only. Evilginx is a powerful tool that can be used to steal session tokens, which can lead to unauthorised access to user accounts. This tool should only be used for legitimate penetration testing on systems where you have explicit permission to do so. Unauthorised use of Evilginx or any similar tool is illegal and unethical, and can result in severe legal consequences. Always ensure you have proper authorisation before conducting any security testing.


What is Evilginx?
Evilginx is an advanced phishing framework that provides a way to bypass multi-factor authentication (MFA) protections by capturing session tokens. It operates as an Adversary-in-The-Middle (AiTM) proxy, intercepting communication between a victim and a legitimate service to steal authentication credentials and session tokens. Unlike traditional phishing attacks that trick user’s into divulging their passwords, Evilginx focuses on obtaining credentials and session tokens, enabling attackers to login without entering user credentials. This makes it a powerful tool for penetration testers and security researchers who need to assess the resilience of their systems against such sophisticated attacks, however, it can also be used by bad actors.

Here’s how it works in few steps:

  1. Attackers create fake login pages that look almost identical to legitimate ones, such as login pages for Microsoft, Google, Facebook and more.

  2. When user’s enter their credentials, Evilginx captures them and forwards them to the real site, making it seem like a normal login process.

  3. It can also intercept multi-factor authentication (MFA) codes, allowing attackers to gain unauthorised access.

This makes Evilginx particularly dangerous because of its capabilities to bypass security measures like MFA.

To protect yourself, always verify the URL of the login page, use phishing resistant MFA, and be cautious of unexpected login requests.

Let’s dig deeper and understand the process via the diagram below

How does Adversary-in-The-Middle (AiTM) take place using Evilginx

Click the image below to enlarge


Now, let’s see the process in action

Note: I’ve already installed and configured the Evilginx application.

Let’s explore how Evilginx can capture a user’s session token and gain access to data.

  1. I launch Evilginx on my server


2. I type:

lures create microsoft365
lures get-url 0

Click image to enlarge


3. I copy the fake url as shown in the image above. A malicious actor typically requires the user to click on this URL, often distributed through a phishing email.

For demonstration purposes, we’ll assume that the a real user has clicked the malicious link received through a phishing email.

I launch a browser and manually enter the URL of the fake login page.

Enlarge the image below.

Question: Can you spot anything suspicious in the image below?


In case you didn’t spot the suspicious detail, take a closer look at the website address, the letter ‘o’ in ‘micros’ has been replaced with a zero.

Bad actors often use cloned login pages that can appear convincing and legitimate. This highlights the importance of continuously educating ourselves and others about the risks of phishing attacks.

⚠️ WARNING: Please do not attempt to access the fake URL shown above on your own device.

4. Now, let’s assume the user proceeds to log in. For this demo, I’ll be using a test account:

  • Demo Account: [email protected]
  • This account is protected with multi-factor authentication (MFA) using the Microsoft Authenticator app. However, it’s important to note that I am not using phishing-resistant MFA.

I proceed to log in via the fake login page. Meanwhile, the Evilginx application is actively listening and capturing authentication logs in the background.


5. I click Next and am prompted to enter my password to authenticate with Microsoft Entra ID.


6. I enter my username and password, then click Sign in. I complete the MFA challenge via my Authenticator app when prompted. As mentioned earlier, this account does not currently use phishing-resistant MFA.

After logging in, I am briefly signed in before being automatically logged out. However, by this point, the Evilginx tool has already captured the necessary authentication information.


7. Let’s take a look at what Evilginx has captured.


8. At this point, I have successfully captured the user’s credentials, including the username and password, through the fake login page.


Evilginx has now captured the user’s session, including the MFA acceptance, a critical point in demonstrating how traditional MFA can be bypassed in such attacks. Let’s dig a little deeper.

9. I run the sessions command and can see that the username, password, and session token have all been successfully captured.


10. I type sessions 13 and press Enter to inspect the captured session in more detail.

11. The session token is now visible, this includes the full session data that Evilginx has intercepted, allowing an attacker to potentially hijack the authenticated session without needing the user’s credentials or MFA prompt again.


12. Next, I prepare to replay the stolen session token. I highlight and copy the token from the Evilginx output.

13. I’ve downloaded Firefox and installed a cookie editor extension to assist with injecting the session token.

14. I launch Firefox and navigate to https://office.com.


15. I click the Sign in button on office.com and am redirected to the official Microsoft login page.

16. I clear all existing cookies using the cookie editor extension.


17. Inside the cookie editor, I click the Import option and paste the stolen session cookie. I then click Import again.


18. The session cookie has now been loaded


19. I refresh the page, and I now have access.


20. I have access to the user’s apps.


21. I have access to the user’s data


22. I have access to the user’s mailbox



Phishing resistant MFA


Now, i’ll go through the same process again, but this time I’ve enabled phishing resistant MFA for the account [email protected]. I’ve used a passkey. If you’d like to learn more, check out this blog post: Part 1 – What is a FIDO2 key and How to Set One Up for Emergency Access in Entra ID | Cloud Build

  1. I return to the fake login page. I type my username and click Next, but instead of entering a password, I select the option: Use your face, fingerprint, PIN, or security key instead, as shown in the image below.


2. I’m prompted to use a security key, but this prompt is for the fake domain (login.micr0soft.com). My passkey is registered to the legitimate domain (login.microsoft.com), so authentication fails. As a result, Evilginx is unable to capture the session token.


No sessions saved by the Evilginx app

I hope this post was useful. Thanks for reading and see you at the next one.