In this module

1.6 Secure Cloud Apps with Microsoft Defender for Cloud Apps

10-14 hours · Module 1 · Free
Operational Objective
This subsection covers secure cloud apps with microsoft defender for cloud apps — a core operational skill for security teams working in Microsoft 365 environments. Every concept is demonstrated through practical scenarios from the Northgate Engineering environment.
Deliverable: Working proficiency with the techniques and operational patterns covered in this subsection.
Estimated completion: 25 minutes
OPERATIONAL FLOW Input Process Analyse Decide Output

Figure 1.6 — Operational workflow from input through documented output.

Figure — Secure Cloud Apps with Microsoft Defender for Cloud Apps. Applied to security operations at Northgate Engineering.

Secure Cloud Apps and Services with Microsoft Defender for Cloud Apps

Introduction

Required role: Security Reader (minimum for portal navigation). Security Administrator for configuration changes.

Defender for Cloud Apps (formerly Microsoft Cloud App Security) is a Cloud Access Security Broker (CASB) that provides visibility into cloud application usage, detects anomalous behavior, enforces data protection policies, and governs OAuth application permissions across both Microsoft and third-party SaaS applications.

// Detect suspicious OAuth consent grants in the past 7 days
CloudAppEvents
| where Timestamp > ago(7d)
| where ActionType == "Consent to application."
| extend AppName = tostring(RawEventData.Target[3].ID)
| extend Permissions = tostring(RawEventData.ModifiedProperties[4].NewValue)
| project Timestamp, AccountDisplayName, AppName, Permissions
| where Permissions has_any ("Mail.ReadWrite", "Mail.Send", "Files.ReadWrite.All",
    "MailboxSettings.ReadWrite", "User.ReadWrite.All")
| order by Timestamp desc
// Detect suspicious inbox rule creation (post-compromise indicator)
CloudAppEvents
| where Timestamp > ago(7d)
| where ActionType == "New-InboxRule"
| extend RuleDetails = tostring(RawEventData)
| where RuleDetails has_any ("DeleteMessage", "ForwardTo", "RedirectTo",
    "MoveToFolder", "MarkAsRead")
| project Timestamp, AccountDisplayName, IPAddress, RuleDetails
| order by Timestamp desc
// Detect mass file downloads from SharePoint/OneDrive
CloudAppEvents
| where Timestamp > ago(24h)
| where ActionType == "FileDownloaded"
| where Application in ("Microsoft SharePoint Online", "Microsoft OneDrive for Business")
| summarize DownloadCount = count(),
    UniqueFiles = dcount(ObjectName),
    TotalSizeMB = sum(toint(RawEventData.SizeInBytes)) / (1024 * 1024)
    by AccountDisplayName, bin(Timestamp, 1h)
| where DownloadCount > 50
| order by DownloadCount desc
Expand for Deeper Context

While Defender for Endpoint watches the device layer and Defender for Identity watches the on-premises identity layer, Defender for Cloud Apps watches the cloud application layer — what users do inside SaaS applications after they have authenticated. It answers questions that no other Defender product can: Which cloud applications are employees using that IT does not know about? Is a compromised user creating inbox forwarding rules? Did someone consent to a malicious OAuth application that now has access to their mailbox and files? Is a user downloading hundreds of files from SharePoint in a pattern consistent with data exfiltration?

This subsection teaches you how Defender for Cloud Apps discovers shadow IT, how its app connectors provide deep SaaS visibility, how anomaly detection policies identify post-compromise behavior, how OAuth app governance detects consent phishing, and how to investigate CloudAppEvents in Advanced Hunting. Understanding Defender for Cloud Apps is particularly important for Modules 11-13, where post-compromise activity — inbox rule creation, mailbox access, OAuth app abuse — is detected by this product.

---

Cloud Discovery: finding shadow IT

Cloud Discovery is the feature that identifies every cloud application employees are using, including applications that IT has not sanctioned. The discovery data comes from two primary sources.

Defender for Endpoint integration. When Defender for Endpoint is integrated with Defender for Cloud Apps (enabled in Settings → Cloud Apps → Microsoft Defender for Endpoint), the endpoint sensor automatically reports network traffic to cloud applications. Every HTTP and HTTPS connection from an onboarded device to a SaaS application is captured and sent to Defender for Cloud Apps for analysis. This provides per-device, per-user cloud app discovery without requiring any network infrastructure changes — no proxy logs, no firewall configurations, just the existing endpoint sensor.

Log collectors and firewalls. For environments where not all devices are onboarded to Defender for Endpoint (or for network-level visibility), you can configure automatic log upload from firewalls and proxies. Defender for Cloud Apps supports log formats from most enterprise firewalls (Palo Alto, Fortinet, Check Point, Cisco) and web proxies (Zscaler, Squid, Blue Coat). The logs are uploaded to the cloud service, which parses them and maps network traffic to its catalog of over 31,000 cloud applications.

The Cloud Discovery dashboard shows the total number of discovered applications, categorized by risk score. Each application receives a risk score based on factors including regulatory compliance certifications, security features (encryption, MFA support), data handling practices, and legal terms. Applications scoring below your organization's risk threshold can be tagged as "Unsanctioned" — and if Defender for Endpoint integration is enabled, unsanctioned apps can be blocked at the endpoint level, preventing users from accessing them without needing to configure anything at the network layer.

Investigation value of Cloud Discovery. During incident response, Cloud Discovery tells you whether a compromised user was accessing unauthorized cloud storage services (potential data exfiltration channels), whether the organization has exposure to a newly disclosed SaaS vulnerability, and whether users are sending corporate data to personal cloud accounts (Google Drive, Dropbox, personal OneDrive). The "Discovered apps" tab shows usage statistics per application — transaction counts, upload volumes, and download volumes — which helps you assess whether a shadow IT application poses a data leakage risk.

---

App connectors: deep SaaS visibility

While Cloud Discovery identifies which applications are in use, app connectors provide deep visibility into what users do inside those applications. App connectors use the application's API to retrieve activity logs, user accounts, file metadata, and configuration settings.

For Microsoft 365, the connector is automatic — Defender for Cloud Apps has native integration with Exchange Online, SharePoint Online, OneDrive, and Teams. Activity data from these services populates the CloudAppEvents table in Advanced Hunting and feeds anomaly detection policies.

For third-party SaaS applications, you configure app connectors individually. Supported applications include Salesforce, Google Workspace, Box, Dropbox, ServiceNow, Okta, GitHub, Atlassian, and many others. Each connector requires API credentials (typically an OAuth app registration or API key) with read permissions for activity logs and user data.

Once connected, the activity log in Defender for Cloud Apps shows every user action within the connected application: file uploads, file downloads, file shares, permission changes, login events, admin configuration changes, and application-specific actions (such as creating an inbox rule in Exchange Online or modifying a pipeline in GitHub). This activity data is the foundation for both anomaly detection and manual investigation.

---

Anomaly detection policies

Defender for Cloud Apps includes built-in anomaly detection policies that use machine learning to identify suspicious behavior patterns. These policies establish a baseline of normal behavior for each user (login locations, devices, activity volume, typical working hours) and fire alerts when behavior deviates significantly from the baseline.

The most important built-in anomaly detection policies for SOC analysts are:

Impossible travel. Detects when a user authenticates from two geographically distant locations within a time window that makes physical travel impossible. For example, a sign-in from London at 09:00 and a sign-in from Singapore at 09:30 indicates either a compromised account or a VPN/proxy configuration issue. The policy accounts for known VPNs and corporate proxy configurations to reduce false positives.

Activity from infrequent country. Fires when a user performs activity from a country they have never previously accessed applications from. This is a weaker signal than impossible travel (it could be legitimate travel) but becomes significant when combined with other indicators.

Suspicious inbox forwarding. Detects the creation of inbox rules that forward or redirect email to external addresses. This is one of the most common post-compromise actions in business email compromise (BEC) attacks — the attacker creates a forwarding rule to maintain access to the victim's email even after the password is changed. The rule silently copies inbound emails to the attacker's external mailbox.

Unusual file download activity. Fires when a user downloads a volume of files that significantly exceeds their baseline. A user who normally downloads 5-10 files per week suddenly downloading 500 files in an hour is consistent with data exfiltration.

Unusual file share activity. Detects when a user shares files with external users at an unusual rate. This catches both data exfiltration (sharing confidential files with a personal account) and compromised accounts being used to distribute phishing links or malware via shared files.

Multiple failed login attempts. While Entra ID Protection also detects this, Defender for Cloud Apps extends the detection to third-party SaaS applications connected via app connectors. Failed login attempts against Salesforce, GitHub, or ServiceNow are captured here.

Suspicious inbox manipulation rule. Specifically targets inbox rules that delete messages, move them to hidden folders, or mark them as read — behaviors designed to hide the attacker's activity from the legitimate mailbox owner. This is distinct from suspicious forwarding because the rule's purpose is concealment rather than exfiltration.

You can tune anomaly detection policies in Settings → Cloud Apps → Policy management. Tuning options include adjusting sensitivity (fewer false positives vs. broader detection), excluding specific users or groups (service accounts that legitimately perform bulk operations), and configuring scope (apply to all users or only to specific groups).

---

OAuth app governance

OAuth app governance is one of the most critical capabilities for detecting consent phishing attacks. When a user consents to an OAuth application (clicking "Allow" on a permission request popup), that application receives an access token that grants it specific permissions to the user's data — mailbox access, file access, calendar access, or directory read permissions.

Attackers exploit this mechanism through consent phishing: they create a malicious OAuth application, send the victim a link that triggers the consent prompt, and if the user clicks "Allow," the attacker's application receives a persistent access token to the victim's mailbox and files. This token survives password changes and MFA — the attacker does not need to authenticate again because the OAuth application has its own independent access.

Defender for Cloud Apps monitors OAuth application registrations across the tenant and alerts on suspicious patterns: applications requesting excessive permissions (full mailbox access for an application that claims to be a calendar tool), applications with low community trust scores, applications registered by unknown publishers, and applications that were recently created and are rapidly accumulating user consents.

The OAuth app governance dashboard shows every OAuth application that has been granted permissions in your tenant, including the permissions granted, the number of users who consented, the publisher, and the application's community trust score. During investigation, this dashboard tells you whether a compromised user consented to a malicious application, what permissions that application has, and which other users may have also consented.

Expected Output — High-Risk OAuth Consent Grants
TimestampAccountDisplayNameAppNamePermissions
Mar 18 14:22J. MorrisonSecureDoc Viewer ProMail.ReadWrite, Mail.Send, MailboxSettings.ReadWrite
Consent phishing indicator: An application named "SecureDoc Viewer Pro" requesting Mail.ReadWrite, Mail.Send, and MailboxSettings.ReadWrite permissions is consistent with consent phishing. A legitimate document viewer does not need permission to send email or modify mailbox settings. Response: revoke the application's permissions immediately in Entra ID → Enterprise applications, revoke the user's active sessions, and investigate whether the application has already accessed the user's mailbox data.

---

Conditional Access App Control

Conditional Access App Control is a session-level proxy that sits between the user and the cloud application, providing real-time monitoring and enforcement during the user's session. Unlike app connectors (which review activity after the fact via API), session controls intercept activity as it happens.

When Conditional Access App Control is configured for an application, user traffic is routed through the Defender for Cloud Apps proxy. The proxy can then enforce policies such as blocking downloads of files containing sensitive data (credit card numbers, social security numbers), blocking copy-paste of sensitive content from the application, applying read-only access for unmanaged devices, watermarking downloaded documents with the user's identity, and monitoring all session activity in real time.

Session controls are particularly valuable for scenarios where you want to allow access to an application but need to prevent specific high-risk actions — for example, allowing a contractor to view documents in SharePoint Online but blocking them from downloading or printing those documents.

For SOC analysts, session control logs provide granular evidence during investigations. If a compromised user accessed a connected application, the session logs show exactly what the user viewed, downloaded, uploaded, and shared during each session — with the actual content of downloaded files available for review if download monitoring was enabled.

---

Investigating CloudAppEvents

The CloudAppEvents table in Advanced Hunting is where Defender for Cloud Apps activity data lands for KQL investigation. This table contains every user action captured by app connectors and session controls, including actions in Exchange Online, SharePoint Online, OneDrive, Teams, and connected third-party applications.

Key fields in CloudAppEvents include ActionType (the specific action performed, such as "New-InboxRule", "FileDownloaded", "Add delegated permission grant"), AccountDisplayName (the user who performed the action), Application (the cloud application where the action occurred), IPAddress (the source IP), and RawEventData (a JSON blob containing the full event details specific to each action type).

Expected Output — Suspicious Inbox Rules
TimestampAccountIPAddressRuleDetails
Mar 17 11:42J. Morrison203.0.113.47ForwardTo: ext-backup@proton.me, MarkAsRead: true
BEC indicator: An inbox rule forwarding to an external Proton Mail address and marking forwarded messages as read is a textbook BEC/account compromise pattern. The attacker is exfiltrating email while hiding the forwarding from the legitimate user. The external IP address should be cross-referenced with sign-in logs to confirm it belongs to the attacker. Remove the rule immediately, revoke all active sessions, and force MFA re-registration for the compromised user.
Expected Output — Anomalous File Download Volume
AccountDisplayNameTimestampDownloadCountUniqueFilesTotalSizeMB
J. MorrisonMar 17 11:003473122,847
Data exfiltration indicator: 347 file downloads (312 unique files, ~2.8 GB) in a single hour is orders of magnitude above normal user behavior. Cross-reference with sign-in logs to determine whether this activity originated from the user's normal device and location, or from a compromised session. If the IP address matches a known attacker IP from other alerts in the incident, this confirms active data exfiltration.

---

Response actions for cloud app threats

When you identify a cloud app-related threat, the response actions span multiple products because cloud app compromise typically involves identity, email, and data:

Revoke OAuth app permissions. In Entra ID → Enterprise applications → the malicious app → Permissions, revoke all delegated and application permissions. This immediately cuts the attacker's OAuth-based access.

Remove inbox rules. Use Exchange Online PowerShell or the Defender portal to remove malicious inbox rules: Get-InboxRule -Mailbox j.morrison@northgateeng.com | Where-Object {$_.ForwardTo -or $_.RedirectTo} | Remove-InboxRule.

Revoke user sessions. In Entra ID → Users → the compromised user → Revoke sessions. This invalidates all active tokens and forces re-authentication.

Block the source IP. If the attacker accessed cloud apps from a specific IP, add that IP to your Conditional Access named locations as a blocked location, or add it as a Sentinel indicator for automated blocking.

Review file access. Use CloudAppEvents to determine which files the attacker accessed, downloaded, or shared. If sensitive files were accessed, notify the data owner and assess whether the data breach requires regulatory notification.

Try it yourself

In your Defender portal, navigate to Cloud Apps → Cloud Discovery → Dashboard. If you have Defender for Endpoint integration enabled, select the "Defender-managed endpoints" stream to see which cloud applications your onboarded devices are accessing. Explore the discovered apps list — sort by risk score to identify potentially problematic applications. In the Cloud Apps → Activity log, review recent user activities across connected applications. Try filtering by ActionType to see only file downloads or only inbox rule changes.

What you should observe

Cloud Discovery shows the full landscape of SaaS application usage in your environment. The activity log shows individual user actions within connected applications. Together, these provide the cloud application visibility layer that complements Defender for Endpoint (device layer) and Defender for Identity (on-premises identity layer). During investigations, this is where you find post-compromise activity: inbox rules, OAuth consent grants, file downloads, and sharing changes.


Knowledge check

Compliance mapping

NIST CSF: DE.AE-1 (Baseline of operations established), PR.DS-1 (Data-at-rest is protected). ISO 27001: A.8.15 (Logging), A.8.16 (Monitoring activities). SOC 2: CC7.2 (Monitor system components). Every configuration in this subsection contributes to the logging and monitoring controls that auditors verify.

Compliance Myth: "Enabling all Defender products means you are protected"

The myth: Enabling all Defender products means you are protected

The reality: Licensing a product is not deploying a product. Defender for Endpoint requires onboarding devices, configuring policies, and validating telemetry. Defender for Office 365 requires configuring anti-phishing policies, safe links, and safe attachments for your specific domains and VIPs. An enabled-but-unconfigured Defender product provides less protection than a properly configured open-source alternative. Configuration is the capability — the license is just the starting point.


Check your understanding

1. A user reports receiving a "permission request" popup from an application called "Microsoft 365 Security Scanner" asking for Mail.ReadWrite and Files.ReadWrite.All permissions. They clicked Allow. What happened and what is your response?

This is likely consent phishing. The attacker created a malicious OAuth application with a name designed to appear legitimate. By clicking Allow, the user granted the attacker's application persistent access to their mailbox and files — access that survives password changes and MFA. Response: revoke the application's permissions in Entra ID, revoke the user's sessions, check the application's activity for data access, and alert other users who may have also consented.
This is a legitimate Microsoft security tool performing a routine scan.
The popup was informational only; no permissions were actually granted.

2. During an AiTM phishing investigation, you find that the attacker created an inbox rule forwarding email to an external address and marked forwarded messages as read. Which Defender product detected this activity?

Defender for Cloud Apps — its anomaly detection policies monitor Exchange Online activity via the app connector and specifically detect suspicious inbox rule creation patterns including forwarding to external addresses.
Defender for Endpoint — it monitors all application activity on the device.
Defender for Identity — it monitors all authentication and directory changes.

3. Cloud Discovery shows that 47 users are accessing a file-sharing application with a risk score of 2/10. What does this mean for your security posture?

A risk score of 2/10 indicates the application has poor security controls, weak compliance posture, or questionable data handling practices. With 47 users, this represents a significant shadow IT exposure. You should investigate what data users are uploading, consider blocking the application via Defender for Endpoint integration, and provide users with a sanctioned alternative that meets your security requirements.
A risk score of 2/10 means only 2 out of 10 security checks passed — the application is definitely malware.
Risk scores are informational only and do not require action.
Decision point

You manage NE's M365 security stack. Microsoft releases a new Defender feature in preview. The feature promises to reduce AiTM risk by 80%. Do you enable it immediately?

Not in production. Enable in a test tenant or for a pilot group first. Preview features may: change behavior before GA, have undocumented interactions with existing CA policies, or produce unexpected results in specific tenant configurations. The deployment sequence: (1) enable in a test tenant and validate against NE's CA policy set, (2) enable for a pilot group of 10 users for 2 weeks, (3) monitor for FPs and operational impact, (4) roll out to all users after successful pilot. Microsoft's '80% reduction' claim is based on their telemetry across all tenants — NE's specific configuration may produce different results.

You've set up your M365 tenant and learned the Defender XDR unified portal.

Module 0 got your M365 developer tenant configured with sample data. Module 1 took you through the Defender XDR unified incident queue across endpoint, email, identity, and cloud apps. Now you investigate every major M365 attack type and deploy the detections that catch them next time.

  • 15 investigation and configuration modules — Defender for Endpoint, Purview, Defender for Cloud, Security Copilot, Sentinel workspace design, log ingestion, analytics rules, and threat hunting
  • 5 named attack investigations — AiTM credential phishing, BEC and financial fraud, consent phishing and OAuth grant abuse, token replay and session hijacking, insider threat
  • KQL from fundamentals through advanced hunting — dedicated modules on query language, cross-table joins, statistical analysis, and threat hunting queries
  • SC-200 exam objectives fully covered — every module maps to the January 2026 SC-200 update. The certification is the side effect of operational competence, not the goal
  • Production artefacts per module — detection rules, investigation playbooks, and hardening checklists you deploy to your own tenant
Unlock the full course with Premium See Full Syllabus