Deep dive · Cross-cutting

AI & agent security deep dive

The AI material is listed as one sub-skill of Skill 3, but it reaches into Skill 1 for identity and Skill 4 for monitoring. This page follows it as one story — from the data an assistant can see, through the model and the gateway, to the agent identity acting on your behalf.

Generative AI does not create an entirely new set of security problems so much as it amplifies existing ones at machine speed. Permissions that were technically wrong but practically harmless become a search result. A user who would never have found a document now has it summarised for them. And an agent with a standing credential can be talked into using it by text hidden inside a file it was asked to read.

flowchart TB
  subgraph IDP["Wrapped by identity — every agent gets a Microsoft Entra Agent ID, a sponsor and Conditional Access"]
    subgraph STACK["The four places a control can go"]
      direction TB
      DATA["Data · Purview and SharePoint Advanced Management — data risk assessments<br/>sensitivity labels · DLP for Copilot · Restricted Content Discovery and Access Control"]
      GATE["Gateway · AI Gateway in Azure API Management — token limits and quotas<br/>semantic caching · content safety policy · token telemetry"]
      MODEL["Model and agent · Microsoft Foundry guardrails and controls — Prompt Shields<br/>groundedness · PII · protected material · blocklists · spotlighting"]
      RUN["Runtime · Microsoft Defender Security for AI — real-time protection over<br/>tool invocations · Defender for AI Services detections"]
      DATA --> GATE
      GATE --> MODEL
      MODEL --> RUN
    end
  end
Four control points, all inside one identity plane. An exam question usually describes a symptom at one layer; your job is to name the layer before you name the product.

The threats you are being asked to control

ThreatWhat it looks likePrimary control
OversharingCopilot surfaces a salary file from a site shared with "Everyone except external users"Purview DSPM data risk assessments; SharePoint Restricted Content Discovery and Restricted Access Control
User prompt injection (UPIA / jailbreak)A user talks the model out of its system instructionsFoundry Prompt Shields — user prompt attack control
Cross-domain / indirect prompt injection (XPIA)Hidden instructions inside a document, email or web page the agent readsPrompt Shields — document attack control, plus spotlighting
Data exfiltration through the modelSensitive content leaves in a prompt or a completionPurview DLP for Copilot, Foundry PII control, sensitivity labels honoured at retrieval
Wallet abuse / denial of walletOne team or one attacker consumes the whole token quotaAI Gateway token limits and quotas
Agent takeover and excessive agencyA subverted agent uses its own standing permissions to actEntra Agent ID plus Conditional Access, least-privilege agent permissions, Defender real-time protection over tool invocations
Ungoverned "shadow" agentsAgents created by makers that nobody is trackingAgent inventory in Defender and in the Microsoft 365 admin center; sponsors and owners in ID Governance

1 · The data layer: stop the assistant seeing what it should not

This is the single highest-value piece of work before deploying Copilot, and it is entirely conventional data governance done properly.

Finding the oversharing

  • Purview DSPM data risk assessments — an assessment runs automatically each week over the top 100 most-used SharePoint sites, and you can add custom assessments. It surfaces sites with sensitive data, risky sharing links and broad permissions, with remediation actions attached.
  • SharePoint Advanced Management data access governance reports — sharing links, "Everyone except external users" (EEEU) usage, permission state for sites, OneDrive and files, and sensitivity labels applied to files.
  • Content management assessment — finds sites with oversized audiences, EEEU, broken inheritance, inappropriate sharing, and sites that are inactive or ownerless.
  • Site access review — delegates the review of those reports to the site owners who actually know whether the access is justified.

Containing it

ControlEffectSet at
Restricted Content Discovery (RCD)The site's content stops appearing in organisation-wide search and in Copilot and agentic experiences. Permissions are unchanged, the content stays in the search index, and users can still reach content they own or have recently interacted with.Per site, in the SharePoint admin center → Active sites → Settings, or Set-SPOSite -RestrictContentOrgWideSearch $true
Restricted Access Control (RAC)Only members of a named Microsoft Entra security group or Microsoft 365 group can access the site at all — even if they previously had permissions or a sharing link. A genuine access boundary.Per site, under SharePoint admin center → Policies → Access control
DLP for Microsoft 365 CopilotExcludes labelled content from being used to ground a Copilot response.Purview DLP policy, Copilot location
Sensitivity labelsEncryption and usage rights travel with the file; Copilot honours them and inherits the label into generated content.Purview information protection

RCD is discoverability, RAC is access

The distinction is exam-shaped. "Prevent this site's content from turning up in Copilot answers while the owners review permissions" is Restricted Content Discovery — it leaves access alone, which is why it can be applied quickly and reversed. "Ensure only the HR team can open this site, regardless of existing permissions" is Restricted Access Control. And note that RCD propagation is not instant — it depends on site size and index load.

Two things that have moved

Restricted SharePoint Search is retiring. It was the temporary allow-list of sites usable by Copilot; new enablement was blocked from 31 July 2026, and Microsoft directs you to Restricted Content Discovery instead. DSPM for AI is now "classic". Its capabilities have been folded into the unified Data Security Posture Management experience organised around data security objectives — one of which is "prevent data exposure in Microsoft 365 Copilot and Microsoft Copilot interactions". Exam items written against the older list will still say "DSPM for AI".

Monitoring what the AI is actually doing

In Purview, Activity explorer has an AI activities view showing AI interactions, the sensitive information types they contained, visits to generative AI websites, and DLP rule matches during those interactions. Workloads are grouped as Copilot experiences and agents, Enterprise AI apps (such as ChatGPT Enterprise) and Other AI apps. To see interactions with third-party AI sites at all, devices must be onboarded to Purview — which in practice means enrolled in Intune and onboarded to Defender for Endpoint.

2 · The model layer: Foundry guardrails and controls

In Microsoft Foundry, a guardrail is a named container of controls, and you assign it to model deployments and to agents.

ControlApplies atNotes
Hate, Violence, Sexual, Self-harmUser input and model outputSeverity thresholds. These four can be overridden but never deleted from a guardrail.
Prompt Shields — user prompt attackUser inputJailbreak attempts against the system instructions.
Prompt Shields — document attackUser input and tool responsesIndirect injection hidden in third-party content. The tool-response intervention point is what protects agents.
Protected material for text and for codeOutputKnown copyrighted text and public-repository code.
Personally identifiable informationInput and outputRequires a recent API version.
Groundedness detectionOutputFlags claims unsupported by the provided source material. Streaming scenarios only.
Profanity and custom blocklistsInput and outputYour own terms and regular expressions.
foundry request
POST https://<resource>.services.ai.azure.com/openai/v1/responses
Authorization: Bearer <token>
Content-Type: application/json

# Select a named guardrail for this request. If the name does not match an
# existing guardrail, the call fails with InvalidContentFilterPolicy.
x-policy-id: contoso-public-facing

{
  "model": "gpt-5",
  "input": "Summarise the attached policy document.",
  "instructions": "You are a helpful assistant. \"\"\" <documents> ...untrusted content... </documents> \"\"\""
}

Four guardrail facts that get tested

One: Microsoft Default guardrails, such as Default.V2, cannot be edited — create a custom guardrail instead. Two: when both a model and an agent have a guardrail, the agent's guardrail wins. Three: a guardrail cannot be deleted while models or agents are still assigned to it. Four: selecting a guardrail per request is done with the x-policy-id header, and a name that does not exist returns InvalidContentFilterPolicy.

Spotlighting

Spotlighting is extra protection against document attacks: it tags untrusted input documents by base64-encoding them, so the model treats their content as lower-trust data rather than instructions. It is off by default, has no direct cost, and is available only for models used through the Chat Completions API — but the encoding increases the token count, which can push a long document over the input limit or raise cost. Delimit untrusted content with """ <documents> … </documents> """ and JSON-escape it so the safety system can parse it.

Foundry also offers a guided guardrail set-up for agents: a short questionnaire — who uses the agent, where its inputs come from, whether it touches sensitive data or PII, whether it calls external tools, whether it takes consequential actions, whether it generates code — that turns the answers into a recommended control set.

3 · The gateway layer: AI Gateway in API Management

Foundry has a built-in AI Gateway, backed by Azure API Management and configured from Foundry portal → Manage → AI Gateway. It governs ingress to a single Foundry resource; for anything broader you run API Management standalone.

CapabilityPolicyBehaviour
Token rate limitingllm-token-limitTokens per minute per counter key. Exceeding it returns 429 Too Many Requests.
Total token quotallm-token-limitA budget per hour, day, week, month or year. Exceeding it returns 403 Forbidden.
Token telemetryllm-emit-token-metricEmits consumption as a custom metric with your own dimensions — the basis for chargeback.
Content safetyllm-content-safetyScreens prompts through Azure AI Content Safety at the gateway, independently of the model's own guardrail.
Semantic cachingllm-semantic-cache-store / -lookupReuses completions for semantically similar prompts. Needs an external RediSearch-compatible cache such as Azure Managed Redis.
Backend pools and circuit breakingBackend configurationSpread load across deployments, and fail over from provisioned throughput to pay-as-you-go.
apim policy
<inbound>
  <!-- Cap each consumer's token consumption. Exceeding the per-minute rate
       returns 429; exceeding the period quota returns 403. -->
  <llm-token-limit counter-key="@(context.Subscription.Id)"
                   tokens-per-minute="5000"
                   estimate-prompt-tokens="true"
                   remaining-tokens-variable-name="remainingTokens" />

  <!-- Emit token counts as a custom metric, dimensioned per consumer. -->
  <llm-emit-token-metric namespace="genai">
    <dimension name="Subscription ID" value="@(context.Subscription.Id)" />
  </llm-emit-token-metric>

  <!-- Screen prompts with Azure AI Content Safety before they reach the model. -->
  <llm-content-safety backend-id="content-safety-backend" shield-prompt="true">
    <categories output-type="EightSeverityLevels">
      <category name="SelfHarm" threshold="4" />
      <category name="Violence" threshold="4" />
    </categories>
  </llm-content-safety>

  <!-- Reuse a semantically similar previous completion instead of calling the model. -->
  <llm-semantic-cache-lookup score-threshold="0.05"
                             embeddings-backend-id="embeddings-backend"
                             embeddings-backend-auth="system-assigned" />
</inbound>

Limits apply at the project level, so each project gets its own tokens-per-minute and quota. Creating the gateway needs Contributor or Owner to create the API Management instance (or API Management Service Contributor to reuse one), plus a Foundry owner-level role on the Foundry resource. The gateway also registers custom agents and MCP tools hosted anywhere into the Foundry inventory for governance.

Remember the two status codes

429 means the caller went too fast — it is a rate limit and it clears in a minute.403 means the caller has spent its budget for the period. A scenario describing an app that "worked all morning and then stopped entirely for the rest of the day" is the quota and a 403, not the TPM limit.

4 · The identity layer: Microsoft Entra Agent ID

Agent ID extends Microsoft Entra to AI agents, so an agent is a governed non-human identity rather than a shared app registration. Agent identity blueprints act as templates, creating individual agent identities in a parent–child relationship so policy applies consistently across large fleets. It supports OAuth 2.0, the Model Context Protocol (MCP) and agent-to-agent (A2A) protocols, and third-party agents from platforms such as AWS Bedrock can be brought in through the Entra ID Auth SDK sidecar or workload identity federation.

Agents created in Copilot Studio automatically receive an agent identity, with the maker recorded as the sponsor. Microsoft's own agents — the Conditional Access Optimization Agent, for example — carry one too, so their queries are attributed to an agent rather than to a person.

flowchart TB
  Q["You want Conditional Access to govern what an agent can reach"] --> A{"Which OAuth flow is the agent using?"}
  A -->|"On-behalf-of — a user signed in, and<br/>the agent acts as that user"| U["Target users and groups<br/>The user is the subject of the token exchange,<br/>so selecting agent identities would not match"]
  A -->|"Client credentials — the agent acts<br/>as itself, with no user present"| AG["Target agent identities<br/>Scale with custom security attributes,<br/>and use agent risk as a condition"]
The flow decides what the policy targets. Getting this backwards is the single most likely mistake on an Agent ID question.
CapabilityWhat it gives you
Conditional Access for agentsAdaptive policies over agent access, with agent risk as a real-time condition. Microsoft-managed policies provide a baseline that blocks high-risk agents. Scale targeting with custom security attributes rather than naming agents one by one.
ID Protection for agentsRisky-agent detections based on the agent's own behaviour and on the risk of the user it acts for. Learning mode suppresses behavioural alerts for agents with too little history, while a parallel detection still catches genuinely malicious early-life behaviour. Reports need Security Administrator, Security Operator or Security Reader; configuring agent-risk policies needs Conditional Access Administrator.
ID Governance for agentsAccess packages, sponsors and owners, and time-bound access — so agents are onboarded and retired like employees and no agent is left orphaned.
Network controlsGlobal Secure Access applies web content filtering, threat intelligence filtering and file filtering to agent traffic, including for Copilot Studio agents.
Sign-in and audit logsAgent authentication and activity are logged in Microsoft Entra and viewable in the admin center's Agent identities view.

Preview status and licensing

Microsoft Entra Agent ID is in preview. The Agent ID platform itself is available to all Entra customers, but extending Entra security features to agents requires Microsoft Agent 365 — included with Microsoft 365 E7 and available as an add-on to E5, A5 or Business Premium. Treat any exam answer that assumes agent Conditional Access "just works" with an E3 licence with suspicion.

5 · The runtime layer: Defender real-time protection

Guardrails screen text. Real-time protection screens actions — it inspects agent activity throughout the agentic loop and can stop a risky tool invocation before it executes.

flowchart TB
  U["A user or another agent sends a prompt"] --> GW{"AI Gateway in API Management<br/>token limits"}
  GW -->|"Over the tokens-<br/>per-minute limit"| R429["429 Too Many Requests"]
  GW -->|"Over the total token<br/>quota for the period"| R403["403 Forbidden"]
  GW -->|"Within both"| IN{"Foundry guardrail, input controls<br/>hate · violence · sexual · self-harm<br/>user prompt attack · document attack · PII"}
  IN -->|"A control fires"| BLK["Filtered — the annotation records<br/>detected and filtered"]
  IN -->|"Clean"| M["The model responds, then the output controls run —<br/>the same categories plus protected material,<br/>groundedness and custom blocklists"]
  M --> DEF{"The agent invokes a tool, and Defender<br/>real-time protection evaluates the<br/>invocation before it runs"}
  DEF -->|"A custom rule matches"| STOP["Blocked, and recorded<br/>as a behaviour"]
  DEF -->|"Allowed"| DONE["The tool runs; the default rule<br/>still records the behaviour"]
A single request passing every gate, in order. Notice that the last one is about the tool call, not the text.
Agent typeWhat is evaluated
Copilot Studio agentsTool invocations. Only agents using generative orchestration are covered — classic agents are skipped.
Foundry agentsUser requests, agent responses, tool invocations and tool responses — the broadest coverage.
Agent 365 agentsTool invocations evaluated through Work IQ MCP, including customer MCP tools onboarded to Agent 365.
Local agents on endpointsCovered separately by AI agent runtime protection in Microsoft Defender for Endpoint, which must be in active mode.

Default rule versus custom rules

  • The default rule audits every agent: matching activity is recorded as a behaviour, and nothing is stopped. This is how you gain visibility before enforcing.
  • Custom rules block matching actions before they execute, and also record the behaviour. Scope them narrowly to high-confidence threats and specific agents.
  • Behaviours land in the BehaviorInfo table in advanced hunting — what happened, why it was risky, and which agent, user and tool were involved — so they can drive custom detections and downstream automation.
  • Near-real-time detections surface as alerts only in audit mode; once a blocking rule covers an agent, alerts are not generated for it.

Turning it on for Copilot Studio

  1. In the Microsoft Defender portal, open Security for AI → Get started and select the Copilot Studio step.
  2. Toggle Real-time protection on.
  3. Copy the Power Platform integration URL and send it to your Power Platform administrator, who completes onboarding on their side using a Microsoft Entra application.
  4. Take the App ID back from them, paste it into the Defender portal and save. The Copilot Studio step then shows Connected.
  5. Connect the Microsoft 365 connector as well — without it, blocking still works but no alerts or incidents appear in the Defender portal.

Makers see the result in Copilot Studio as a Protection status column on the Agents page, reading Protected, Needs review or Unknown, broken down into threat detection, authentication, policy and content moderation.

Where agent security has landed

From 1 July 2026, agent security capabilities for Copilot Studio and Foundry agents require a Microsoft Agent 365 licence rather than being carried by Defender for Cloud Apps and Defender for Cloud. Three consequences worth knowing: the agent inventory table moved from AIAgentsInfo to AgentsInfo; real-time protection rules are defined under Settings → Security for AI → Policies & rules → Real-time protection; and Defender CSPM still discovers Foundry accounts and projects, but agent-level discovery, posture and threat detection now need the Agent 365 licence. The Defender for AI Services plan continues to protect Foundry models, including Azure OpenAI.

6 · Posture and monitoring for AI

SurfaceWhereAnswers
AI security posture managementIncluded in Defender CSPMDiscovers generative AI workloads agentlessly across Azure OpenAI, Azure Machine Learning and Amazon Bedrock; surfaces the models, SDKs and configurations in use; and runs attack path analysis over them — for example grounding data exposed to the internet and open to poisoning.
Defender for AI ServicesA workload protection plan in Defender for CloudRuntime detection for generative AI workloads — jailbreak attempts detected by Prompt Shields, data exposure, wallet abuse and suspicious access patterns — enriched with Microsoft threat intelligence.
Data and AI security dashboardDefender for CloudOne view of data and AI resources, their protection coverage, top issues, sensitive data findings, internet-exposed grounding resources and prompt-scanning volumes.
Security Dashboard for AIai.security.microsoft.comThe leadership view across Entra, Defender, Purview and Security Copilot: which AI assets exist, their posture, and where to act — including third-party models, apps, agents and MCP servers.
Agent inventoryDefender portal, and the Microsoft 365 admin centerWhich agents exist, who sponsors them, what they connect to, and whether they are protected. Advanced hunting exposes the same data in AgentsInfo.

What the Data and AI security dashboard needs

It is enabled at subscription level and only fills up if the feeding plans are on: Defender CSPM with the sensitive data discovery extension, Defender for Storage, Defender for Databases and threat protection for AI workloads. The minimum privileged role to view it is Security explorer. A question describing an empty dashboard is asking you to spot a missing plan, not a missing permission.

Blast radius

"Analyse blast radius for security risks related to Entra Agent ID by using Defender XDR" is the objective's phrase for a simple question: if this agent is subverted, what can it reach? You answer it by joining the agent's identity and its granted permissions to the exposure graph — the agent inventory in the Defender portal for the identity and its connections, and Microsoft Security Exposure Management's attack paths and critical asset classification for what lies downstream. The remediation is almost always the same two moves: narrow the agent's permissions, and put Conditional Access in front of them.

7 · Managing agents in the Microsoft 365 admin center

The administrative counterpart to all of the above. In the Microsoft 365 admin center you manage the agent inventory across Microsoft 365 — who owns each agent, who it is available to, its lifecycle, and which agents makers are permitted to create and publish at all. Power Platform administrators set the corresponding policies for Copilot Studio, including data loss prevention policies over connectors, which is why the Copilot Studio protection status surfaces Policies as its own category.

Scenario-to-answer lookup

The scenario says…The answer is…
"Copilot returns content from a site that is under permissions review"Restricted Content Discovery on that site
"Only the HR security group may access the site, regardless of existing links"Restricted Access Control
"Identify which sites are overshared before we roll out Copilot"Purview DSPM data risk assessments, plus SharePoint Advanced Management data access governance reports
"Block a document containing hidden instructions from steering the agent"Prompt Shields document attack control, at the tool response intervention point; add spotlighting
"One team must not be able to exhaust the model's capacity"AI Gateway token limit per project or subscription key
"The app stopped working entirely for the rest of the day"The total token quota — a 403, not a 429
"Require phishing-resistant MFA when an agent acts for a user"A Conditional Access policy targeting users and groups, because the flow is on-behalf-of
"Block an autonomous agent when its risk is high"A Conditional Access policy targeting agent identities, with agent risk as the condition
"Stop the agent from running a dangerous tool, not just from saying something"A custom real-time protection rule in Defender Security for AI
"See which agents exist and who is responsible for them"Agent inventory in the Defender portal and the Microsoft 365 admin center; sponsors in Entra ID Governance
"Detect jailbreak attempts against our Azure OpenAI deployment"Defender for AI Services, in Defender for Cloud's workload protection
"Show the CISO our overall AI risk in one place"Security Dashboard for AI

Check the preview line before you memorise

Much of this surface is in preview and changing quarterly: Entra Agent ID, Conditional Access for agents, real-time protection for Copilot Studio and Foundry agents, AI Gateway in Foundry, and spotlighting. The exam states that it may include commonly used preview features, so you cannot skip them — but do re-read the Microsoft Learn page for each one shortly before you sit, because the portal paths in particular have already moved once.

Next: Exam tips & caveats, for the final week.