Session Policies and App Governance

Earn 25 points (50 with Pro) in two steps

  1. ① Read through the lesson — each section gets a ✓ as you scroll through it.
  2. ② When every section has a ✓, tap Complete lesson.

0 of 7 read · keep scrolling

✦ See fewer ads and earn double points — 50 a lesson instead of 25 — with Pro

Mastering Session Policies and App Governance in Microsoft Defender for Cloud Apps

Introduction: The Modern Perimeter is Identity and Session

In the traditional era of network security, the corporate perimeter was defined by the office firewall. If a user was inside the building, they were "safe," and if they were outside, they were blocked. Today, the perimeter has dissolved. Employees work from cafes, airports, and home offices, accessing corporate data through a vast array of cloud services like Microsoft 365, Salesforce, Slack, and AWS. Because data now flows freely between these services and various devices, the focus of security has shifted from the network edge to the session itself.

Microsoft Defender for Cloud Apps (MDA) acts as a Cloud Access Security Broker (CASB). It sits between your users and the cloud applications they use, providing visibility and control over the data being accessed. Two of the most powerful tools within this suite are Session Policies and App Governance. Session Policies provide real-time monitoring and control over user sessions, while App Governance focuses on the lifecycle and permissions of the OAuth applications that connect to your environment. Together, they form a critical layer of defense against data exfiltration, shadow IT, and malicious third-party integrations.

Understanding these controls is essential for any security professional tasked with protecting a modern organization. Without them, you are essentially flying blind, hoping that your users are making good decisions and that the applications they grant access to your data are trustworthy. This lesson will guide you through the technical implementation, strategic configuration, and ongoing maintenance of these two vital components.


Not read yet

Part 1: Deep Dive into Session Policies

Session policies are the "eyes and ears" of your cloud security posture. Unlike conditional access policies that make a binary decision—allowing or blocking a sign-in—session policies apply granular controls after the user has been authenticated. They leverage the Conditional Access App Control feature of Microsoft Defender for Cloud Apps to proxy the connection between the user's browser and the cloud application.

How Session Policies Work

When a user attempts to access a cloud app that is routed through MDA, the session is intercepted. The policy engine evaluates the session in real-time. If the session matches the criteria you have defined (such as downloading a sensitive file or accessing from an unmanaged device), the policy triggers an action. Because the traffic is proxied, MDA can modify the session content, inject warnings, or prevent specific actions entirely.

Common Use Cases for Session Policies

  • Preventing Data Exfiltration: Blocking the download of sensitive documents from a managed app to an unmanaged personal device.
  • Restricting Cut, Copy, and Paste: Preventing users from copying sensitive text from a corporate web app and pasting it into personal email or social media.
  • Protecting Against Malware: Scanning files being uploaded to cloud storage in real-time and blocking those that contain threats.
  • Monitoring Sensitive Activities: Logging specific user actions, such as changing file permissions or deleting records, for auditing and forensic purposes.

Callout: Session Policies vs. Conditional Access While Conditional Access policies act as the "gatekeeper" at the door, session policies act as the "security guard" inside the building. Conditional Access determines who gets in and from where. Once the user is inside, Session Policies watch what they do and prevent them from performing risky actions within the application environment.

Step-by-Step: Creating a Download Restriction Policy

To create a policy that prevents users from downloading sensitive files to unmanaged devices, follow these steps:

  1. Navigate to the Microsoft Defender portal and select Cloud apps.
  2. Go to Policies > Conditional access > Create policy > Session policy.
  3. Give your policy a descriptive name, such as "Block Download of Sensitive Data on Unmanaged Devices."
  4. Under Session control type, select Control file download (with inspection). This ensures that the content of the file is checked against your sensitivity labels or file patterns.
  5. In the Activities section, filter for the specific application (e.g., SharePoint Online) and the specific activity (e.g., Download).
  6. Under Filters, define the sensitivity labels or the specific file types that should be blocked.
  7. In the Actions section, choose Block. You can also choose to display a custom message to the user explaining why the action was blocked.
  8. Save the policy and ensure it is enabled.

Tip: Always start by putting your session policies in "Test" mode. This allows you to view the logs and see what would have been blocked without actually disrupting user productivity. Once you confirm the policy is hitting the right targets, you can flip it to "Enabled."

Best Practices for Session Policies

  • Use Sensitivity Labels: Don't just rely on file extensions. Integrate with Microsoft Purview Information Protection to block downloads based on the actual content classification of the file.
  • Keep Policies Focused: Avoid creating "catch-all" policies. Create granular policies for specific departments or specific high-risk applications to minimize false positives.
  • Communicate with Users: When blocking an action, always provide a clear, helpful message. If a user is blocked from downloading a file, tell them how they can request access or which device they should be using instead.

Not read yet

Part 2: App Governance and OAuth Security

While Session Policies focus on the user, App Governance focuses on the applications themselves. Modern cloud environments are heavily reliant on OAuth-connected apps. A user might grant a calendar-syncing app access to their email, or a project management tool access to their OneDrive files. Often, users grant these permissions without understanding the scope. If one of these apps is malicious or compromised, the attacker gains a persistent backdoor into your environment that survives password changes and MFA resets.

The Threat of "Shadow" OAuth Apps

The primary risk with OAuth apps is "consent phishing." An attacker lures a user into granting a malicious app permissions to read their mail, calendar, or files. Because the app has been granted a token through the standard OAuth flow, it does not need a password. It operates as the user, potentially scraping data, sending phishing emails from the user's account, or modifying sensitive documents.

App Governance Features

App Governance provides a dashboard to monitor, manage, and govern these apps. It offers:

  • Discovery: Automatically finding all OAuth apps connected to your Microsoft 365, Google Workspace, and Salesforce environments.
  • Risk Scoring: Assigning a risk level to each app based on its permissions, publisher, and usage patterns.
  • Automated Remediation: Setting policies to automatically disable apps that exhibit suspicious behavior, such as high-volume data egress or abnormal API calls.

Implementing an App Governance Policy

To mitigate the risk of risky OAuth apps, you should implement an automated governance policy:

  1. In the Defender portal, navigate to App governance > Policies.
  2. Select Create policy.
  3. Choose a template, such as "App with high-risk permissions."
  4. Define the conditions. For example, select apps that have "Read" and "Write" access to emails or files.
  5. Define the action. You can choose to "Disable the app" or "Notify the administrator" when the policy is triggered.
  6. Set the scope to apply to all apps or specific apps of interest.

Callout: The "Principle of Least Privilege" for Apps Just as you limit user access to only what they need, you must limit application access. If an app only needs to read calendar events, it should not have "Full Access" to the user's mailbox. App Governance allows you to identify these over-privileged applications and remediate them before they become a security incident.

Common Pitfalls in App Governance

  • Ignoring "Low Risk" Apps: Even apps that appear low-risk can be compromised. A common mistake is to only monitor apps with "High" risk scores. Regularly audit the list of all apps, even those with lower scores.
  • Failing to Revoke Permissions: Simply disabling an app isn't always enough. If an app has been used maliciously, you should also revoke the OAuth tokens and force the user to re-authenticate or, better yet, investigate the user's account for signs of compromise.
  • Lack of Communication with App Owners: If you disable an app, business processes might break. Ensure that there is a clear process for users to request an exception or for business owners to vet the apps they are using.

Not read yet

Part 3: Integrating Session Policies and App Governance

The true strength of Defender for Cloud Apps is the synergy between these two components. By using them together, you create a holistic defense that covers both the user's active session and the persistent connections of third-party apps.

Scenario: The Compromised Account

Imagine a scenario where a user's account is compromised. The attacker uses the user's credentials to log in from a new location.

  1. Conditional Access triggers MFA. If the attacker bypasses MFA, they are in.
  2. Session Policies kick in as soon as the user tries to download a sensitive report from SharePoint. Because the device is unmanaged, the download is blocked.
  3. The attacker, frustrated by the download block, attempts to use an OAuth app to synchronize the user's OneDrive to a remote server.
  4. App Governance detects the abnormal API usage and high volume of file synchronization. The policy automatically disables the OAuth app and alerts the security team.

This multi-layered approach ensures that even if one control is bypassed, others are in place to stop the progression of the attack.

Technical Implementation: A Code-Like Logic Flow

When designing your security architecture, it is helpful to think in terms of logical flows. Below is a representation of how these policies evaluate requests:

IF User_Action = "Download" AND File_Sensitivity = "Confidential"
  THEN Evaluate_Session_Context
    IF Device_State = "Managed" THEN Allow
    ELSE Block AND Alert_Admin

IF App_Connection = "OAuth_Grant"
  THEN Evaluate_App_Risk
    IF Permission_Level = "Global_Admin" OR "Full_Mailbox_Access"
      THEN Flag_For_Review AND Notify_User
    IF App_Reputation = "Low" OR "Unknown"
      THEN Disable_App AND Revoke_Tokens

Explanation of the logic:

  • The first block represents a Session Policy. It focuses on the context of the user interaction. It checks the sensitivity of the data and the state of the device.
  • The second block represents an App Governance Policy. It focuses on the static properties of the connection (the OAuth grant) and the reputation of the third-party service.

Not read yet

Part 4: Best Practices and Industry Standards

To maintain a secure environment, you must treat your security policies as living documents. You should review them at least quarterly to ensure they align with the current threat landscape and your organization's evolving business needs.

1. Establish a Baseline for "Normal"

Before you start blocking applications or restricting user sessions, spend time in "Discovery" mode. Use the Cloud Discovery dashboard in Defender for Cloud Apps to see which apps are actually being used. You cannot secure what you do not know exists. Once you have a clear picture of legitimate business usage, you can start building policies that permit the good and block the bad.

2. Implement a Formal App Vetting Process

Instead of letting users connect any app they want, implement a process where a new OAuth app must be approved by IT or Security. Use the App Governance dashboard to vet the app's permissions and publisher reputation before granting it access to your production environment.

3. Leverage Automation

Don't manually investigate every single alert. Use the automation capabilities of Microsoft Defender to handle routine tasks. For example, automatically trigger a "User Risk" level increase in Microsoft Entra ID when a session policy detects a high-risk download. This enables downstream protections like forcing a password reset or requiring MFA for future sessions.

4. Monitor for "Consent Phishing" Trends

Keep an eye on industry reports regarding new phishing campaigns. Attackers frequently change the names and icons of malicious apps to mimic legitimate software like "Microsoft Office 365 Update" or "Adobe PDF Reader." Use the App Governance dashboard to search for these patterns across your tenant.

5. Educate Your Users

Security is a partnership. If a user tries to download a file and is blocked by a session policy, they should be presented with a clear explanation. If an app is disabled by an app governance policy, the user should be told why. When users understand why these controls exist, they are less likely to try to bypass them and more likely to report suspicious activity.

Warning: The "Productivity Tax" If your security policies are too restrictive, you will create a "productivity tax" that frustrates employees. If every file download is blocked, users will find ways to work around the system, such as using personal email to send files. Always seek a balance between security and usability. Test policies thoroughly before enforcing them globally.


Not read yet

Part 5: Common Mistakes and How to Avoid Them

Even experienced administrators can fall into traps when configuring these policies. Here are some of the most common mistakes:

  • Over-reliance on "Block" actions: Blocking everything is the easiest way to secure an environment, but it is also the fastest way to stop business. Use "Monitor" or "Warn" actions where possible. For instance, warn a user that they are downloading a sensitive file rather than blocking it immediately.
  • Failure to account for Service Accounts: Sometimes, legitimate automated processes use OAuth apps. If you apply a sweeping "Disable low-reputation apps" policy, you might accidentally break a critical business process. Always exclude known service accounts or trusted app IDs from your aggressive remediation policies.
  • Neglecting the "App Governance" Onboarding: App Governance requires specific permissions and configuration to work effectively. Many admins enable it but fail to grant it the necessary permissions to scan their environment, leading to a false sense of security. Follow the setup wizard carefully and verify that data is flowing into the dashboard.
  • Ignoring the "User Agent": When writing session policies, consider the user agent. Are you blocking mobile devices? Are you blocking specific browsers? Sometimes a policy might be failing because the user is using a non-standard browser that the policy engine doesn't recognize as "managed."
  • Not testing with different user personas: A policy that works for an IT administrator might behave differently for a finance user. Test your policies with test accounts that have different permission levels and roles to ensure the policy applies correctly across the board.

Not read yet

Quick Reference: Policy Comparison Table

Feature Session Policy App Governance Policy
Primary Focus User activity in real-time OAuth app permissions/lifecycle
Trigger User performs an action (e.g., download) App attempts an action (e.g., API call)
Action Type Block, Monitor, Warn, Protect Disable, Flag, Notify, Revoke
Context User, Device, IP, Data Sensitivity App Reputation, Permissions, Data Volume
Complexity High (Requires proxy configuration) Medium (API-based)

Summary and Key Takeaways

Securing your cloud environment requires a shift in mindset. You are no longer just protecting a network; you are protecting an identity and a session. By leveraging Microsoft Defender for Cloud Apps, you gain the visibility and control needed to navigate this complex landscape.

Key Takeaways:

  1. Session Policies are for Real-Time Control: Use them to monitor and restrict user actions—like downloading or printing—as they happen, ensuring that data stays within the bounds of your security requirements.
  2. App Governance is for Persistent Defense: Use it to manage the lifecycle of OAuth applications, ensuring that only trusted, appropriately privileged apps have access to your organization's resources.
  3. The Power of Proxying: Understand that Session Policies rely on the Conditional Access App Control proxy. This is what allows you to manipulate the browser session and apply granular controls that standard identity policies cannot.
  4. Integration is Critical: The best security posture is achieved when you combine session-based controls with app-based governance. This creates a defense-in-depth model where both the user's current session and their long-term app connections are monitored and secured.
  5. Automation is Your Best Friend: Use automated remediation to handle high-volume threats, such as disabling apps with suspicious behavior or blocking unauthorized downloads, so your security team can focus on complex investigations.
  6. Always Test Before You Enforce: Use "Test" and "Monitor" modes extensively. Never roll out a blocking policy to your entire user base without first validating it against a representative sample to avoid disrupting critical business workflows.
  7. Security is a Continuous Process: The threat landscape changes daily. Review your policies, update your sensitivity labels, and audit your connected apps on a regular cadence to ensure your security posture remains resilient.

By internalizing these concepts and implementing these best practices, you can effectively mitigate the threats associated with modern cloud usage. You are not just building barriers; you are creating a secure, productive environment where users can work from anywhere with confidence. As you continue to build your expertise in Microsoft Defender XDR, remember that the goal is to provide a seamless user experience that is inherently secure by design.

Not read yet

Each section gets a ✓ as you scroll through it. Tap the button to jump to the next one.