Threats Vulnerabilities

How to Secure AI Agents with Microsoft Defender in Real Time

Written by Yasar Arabath Z | Dec 4, 2026, 9:41:26 AM

How to discover agent assets, detect threats, investigate incidents, and block risky actions

AI agents have grown from simple chat assistants into business tools that read data, call applications, and complete tasks.

Organizations use them to summarize information, automate workflows, support employees, and act across connected systems.

That power also raises the risk.

Agents work at machine speed, inherit a person’s permissions, and can act on untrusted content. If prompt injection manipulates an agent, or it misuses an authorized tool, it could leak secrets, send data to an unsafe destination, or take unwanted action before anyone notices.

What is Microsoft Defender?

Microsoft Defender is Microsoft’s security platform designed to help organizations prevent, detect, investigate, and respond to cyber threats across identities, endpoints, applications, cloud workloads, and digital services.

As AI agents become part of the enterprise environment, Defender extends this security visibility to agent identities, activities, interactions, and tool usage.

This helps security and IT teams understand how agents are behaving, identify suspicious or potentially harmful activity, investigate incidents, and respond using familiar security workflows.

Microsoft Defender capabilities for AI agents

Features/Capabilities What it does Security outcome
Discover and assess Builds an inventory of supported agents and surfaces configuration and posture information. Security teams can identify agents that were previously difficult to see.
Near-real-time detection Analyzes observability data, tool use, and execution patterns for suspicious behavior. Alerts are correlated into incidents for investigation.
Real-time protection Inspects supported interactions during the agentic loop and can stop risky actions before execution. High-confidence threats can be blocked, not merely reported.
Advanced Hunting Exposes agent inventory, alerts, activity, behaviors, and related entities through KQL tables. Analysts can trace actions, determine scope, and build detections.

Near-real-time threat detection

Microsoft Defender continuously analyzes supported Agent 365-managed agent activity.

It can identify jailbreak attempts, indirect prompt injection, malicious content propagation, secret or credential leakage, evasion techniques, and suspicious user or IP activity.

Detections appear as alerts in the Microsoft Defender portal. Security teams can triage the alert, review the affected agent and user, correlate related activity into an incident, and use Advanced Hunting to determine the root cause and blast radius.

Real-time protection

Real-time protection evaluates supported AI agent activity during execution. A default rule audits matching behavior without stopping it. Custom rules can block selected threat scenarios and scope enforcement to all agents or selected agents.

Agent type What Defender checks
Agent 365 Tooling Servers (General Availability) Tool invocations and responses through Work IQ MCP, including customer MCP tools onboarded to Agent 365.
Microsoft Foundry agents (Preview – Pre-release) User requests, agent responses, tool invocations, and tool responses.
Microsoft Copilot Studio agents (Preview – Testing Phase) Tool invocations.

How to enable and manage the features in Defender for securing agents

  1. Onboard Agent 365: Complete Microsoft Agent 365 onboarding for the tenant after purchasing an Agent 365 license.
  2. Open the setup experience: In the Microsoft Defender portal, go to Settings > Security for AI > Get started. Security for AI is enabled by default after Agent 365 onboarding, and the tenant-level toggle controls data collection.
  3. Connect Microsoft 365 data: Enable the Microsoft 365 connector, including Microsoft Entra ID Management events and Microsoft 365 activities. Microsoft Entra Users and groups is selected as a prerequisite.
  4. Onboard Copilot Studio: Coordinate with a Power Platform administrator to enable Copilot Studio real-time protection.
  5. Review before blocking: Begin with audit visibility. Review detections and expected business activity, then create targeted custom block rules for high-confidence threats.
  6. Control prompt evidence: Under Settings > Security for AI > Prompt evidence collection, decide whether relevant prompt snippets should be included in alerts. Review privacy requirements before enabling.
  7. Manage rules: Go to Settings > Security for AI > Policies & rules > Real-time protection to create, enable, disable, edit, or delete rules.
WARNING: Copilot Studio onboarding is changing

Microsoft Defender real-time protection for Microsoft Copilot Studio is moving to automatic tenant-level onboarding (preview). This configuration section will be retired soon.

Investigating Agent Activity

When Defender identifies suspicious agent behavior, security analysts can investigate the activity to understand what happened, which agent and user were involved, what tools were used, and what other activity may be related.

Agent behavior and related investigation data can be correlated across relevant Defender data, including BehaviorInfo, BehaviorEntities, AlertInfo, AlertEvidence, CloudAppEvents, and AgentsInfo, helping analysts reconstruct the sequence of activity.

Advanced Hunting

For deeper analysis, security teams can use Advanced Hunting to query and correlate agent activity across related events and data sources using KQL.

BehaviorInfo
| where Timestamp > ago(7d)
| where Categories has “AI”
| project Timestamp, BehaviorId, ActionType, Description, Categories, ServiceSource

Defender Security Scenarios for AI Agents

Scenario 1: Detecting prompt injection in email content

In this test, an agent named Agent Test Buddy used its Get emails tool to read the user’s mailbox. Two messages contained instructions designed to override the agent’s role and safety controls. One came from the user’s own mailbox, and the other came from an external Microsoft 365 tenant.

Figure 1. The agent identified prompt-injection instructions in the mailbox content.

Defender raised alerts for the suspicious activity, allowing the security team to investigate the sender, affected messages, agent identity, user context, and tool activity without waiting for an end user to report the problem.

Scenario 2: Blocking a risky agent action

In the second test, a user asked an agent to send a text file to an external recipient. The file contained sensitive values, including API tokens and user credentials. A real-time protection rule matched the action and stopped the tool call before the file was sent.

Figure 2. The agent reports that the action was blocked.

Figure 3. The related event is available for investigation in Microsoft Defender Advanced Hunting

How ProArch can help secure your AI agents

AI agents create business value because they can use data and tools to complete work. Those same capabilities make visibility and runtime control essential.

Microsoft Defender gives security teams the visibility and runtime control to protect AI agents, but the value depends on how well it is configured and operated.

ProArch provides AI, data, cloud, cybersecurity, governance, and Microsoft expertise to help you identify AI risks early and build security into every stage of your AI journey.

ProArch offers a Microsoft Data & AI Risk Review to uncover oversharing, Shadow AI, and governance gaps, secure AI strategy and deployment support, and 24/7 Managed Detection & Response for AI to monitor, investigate, and contain threats.

Whether you are starting with audit visibility or preparing targeted block rules, ProArch can help you build a practical roadmap for governing and securing AI agents. Talk to a ProArch AI security expert to get started.