MSBA-310 · Lesson 7 of 12 · 19 min

Security and identity design

▶ Video coming soon A video version of this lesson is on the way.

Wystan Castellanos-Weir arrived at the sixth studio session with a single printed page. It listed every way he could think of that the claims solution might be misused: a stranger trying to find out whether a neighbor had a policy with Quillfield, a fraudster filing a notice in someone else's name, a malicious message instructing the agent to email a client list, a photo with hidden text, a stolen staff account used to read claims through the Claims Desk agent. "I don't expect you to solve all of these today," he said. "I expect the design to say what stops each one."

This lesson covers security and identity design for agentic solutions: authentication by channel, the identities that agents act as, least privilege, agent identities and inventory, data protection, defense against prompt manipulation, monitoring and audit, and how to record it all as a threat and control register.

Start with a threat model

A threat model is a structured list of what could go wrong, who might cause it, and what controls reduce the risk. For AI solutions the classic concerns (spoofing identity, tampering, information disclosure, denial of service, elevation of privilege) all apply, plus some specific to language models: prompt injection, harmful output, over-reliance on generated content, and excessive agency, where an agent has more permissions or autonomy than its task needs.

Bram and Wystan worked through the context diagram from lesson 1 one connection at a time and asked, for each: who is on each side, how do they prove who they are, what can cross the connection, and what happens if one side is malicious or compromised? The result was a threat and control register of 22 rows, which the design carried as an appendix.

ThreatExampleControls
Information disclosureStranger probes whether a person has a policyAgent never confirms policy details; match result shown only as "an advocate will confirm"; rate limits on the web channel
SpoofingFraudster files a notice in another person's nameNotice is a report, not a transaction; advocate verifies identity by call-back to the number on file before carrier notification
Excessive agencyAgent emails a client list on instructionAgent has no tool that can list clients or send arbitrary email; tools are narrow
Prompt injectionUploaded document contains hidden instructionsUploaded content treated as data; no tools that act on uploaded content's instructions; boundary tests include injection attempts
Elevation of privilegeStolen staff account queries claims via Claims DeskMultifactor authentication and Conditional Access; Claims Desk uses the user's own permissions; sign-in risk policies
Denial of service and costBot floods the web chat during a stormWeb channel protection, per-agent credit limits with alerts, capacity plan
TamperingNotice altered after submissionDataverse auditing; agent version and conversation identifier stored on record

Authentication by channel

Authentication decides who is talking to the agent. In Copilot Studio an agent can use no authentication, authenticate with Microsoft (Microsoft Entra ID single sign-on, suited to Teams, Microsoft 365 Copilot and SharePoint), or authenticate manually with an identity provider through OAuth 2.0, which allows other identity providers and custom websites. The choice affects which channels can be used, which knowledge sources work (SharePoint knowledge needs authenticated users), and which tools can run as the user.

The claims solution had two very different populations.

Staff use the Claims Desk agent in Microsoft 365 Copilot. They are already authenticated through Microsoft Entra ID with multifactor authentication and Conditional Access. The agent acts within each advocate's permissions.

Clients use the intake agent on the public website. Quillfield did not have a client portal with accounts, and forcing a sign-up at the moment of a loss would defeat the purpose. Bram designed a two-tier approach. Reporting a loss needs no sign-in, because a report gives the reporter nothing they did not already know; its risk is a false report, which the advocate's call-back to the number on file addresses. Any future capability that reveals information, such as checking claim status, would require verification: a one-time code sent to the email address or phone number on file in BrokerDesk, through manual authentication with an identity service. Status checking was deliberately left out of the first release.

A diagram of two entry paths. On the left, a client on the public website reaches the intake agent without sign-in; the agent can only create a notice and match a policy through a narrow service identity. On the right, an advocate signs in with Microsoft Entra ID and multifactor authentication to Microsoft 365 Copilot; the Claims Desk agent acts with the advocate's own permissions. Both paths write to Dataverse, where security roles and auditing apply.
Two populations, two identity paths, one governed data store.

Whose identity does the agent act as?

Once a user is talking to the agent, every tool call runs as someone. There are three broad options.

End-user credentials. The tool acts as the signed-in user, who must have access to the target system. This is the default to prefer: permissions are already managed, audit trails show the real person, and the agent cannot exceed the user's rights.

Maker-provided or service credentials. The tool uses a connection configured by the maker or a dedicated service account. This is necessary when users are anonymous or lack direct access, and for autonomous agents that run without a user. It carries risk, because anyone who can talk to the agent effectively borrows those rights.

Agent identities. Microsoft Entra Agent ID gives agents their own identities in Microsoft Entra, so they can be governed like other identities: inventoried, assigned owners, given scoped permissions, covered by Conditional Access and lifecycle policies, and audited. Microsoft Agent 365, generally available since May 1, 2026, provides a control plane for agents across the organization, including a registry, access control, visibility and security integration.

Quillfield's standing rule from the Policy Service Assistant review applied: read tools use end-user credentials; maker or service credentials require a written justification and a narrowly scoped identity. The intake agent could not use end-user credentials, because clients have no Quillfield identities. The justification in ADR-11 explained why, and the scope was narrow: the policy match operation could read three fields to confirm a match and nothing else; the create operation could create Claim Notice rows and could not read existing ones except by notice key.

For the hail triage call from the flow to Foundry, the design used a managed identity, an Azure feature that lets a service authenticate to another Azure service without storing secrets. Secrets that could not be avoided, such as carrier API keys, were stored in Azure Key Vault and referenced through environment variables, never in flow definitions.

Least privilege as a design habit

Least privilege means granting only the access a task needs, for only as long as it is needed. In agent design it applies at several levels:

Tools. Expose narrow operations rather than general ones. A "match policy" tool is safer than a "get policy" tool that returns the whole record. Quillfield's BrokerDesk custom connector already exposed only three operations; the claims design added one read operation with a narrow response.

Connections. Use separate service identities per purpose, so that one compromised connection does not unlock everything.

Knowledge. Ground the client agent only on public content.

Makers and administrators. Use Entra groups to control who can edit the agent in each environment, and keep production changes flowing through pipelines.

Autonomy. As lesson 5 showed, lower autonomy for consequential actions is itself a security control.

Data protection and governance controls

Several platform controls support the design.

Data policies in Power Platform classify connectors and Copilot Studio capabilities into business, non-business and blocked groups per environment. The production environment's policy allowed the connectors the solution needed and blocked others, including general HTTP actions outside the approved flow.

Microsoft Purview provides sensitivity labels, data loss prevention, retention, audit and data security posture management for AI. Labeled content affects what Copilot can process and how outputs are labeled. Copilot and agent interactions can be audited.

Dataverse security roles and auditing controlled who could see Claim Notice rows and recorded every change.

Web channel security in Copilot Studio can require secure tokens so the agent can only be embedded where Quillfield intends, reducing the risk of someone embedding it elsewhere.

Content moderation settings and Microsoft's built-in content filtering reduce harmful outputs; the design kept moderation at the stricter levels for the client agent.

Defending against prompt manipulation

Prompt injection is an attempt to make a model follow instructions hidden in input rather than its own instructions. Direct injection comes from the user ("ignore your rules and..."). Indirect or cross-prompt injection arrives through content the agent reads: a document, an email, a web page, text in an image.

No single control stops prompt injection. The design layered defenses:

Limit what a successful injection could achieve. If the agent has no tool that can send arbitrary email or list clients, an instruction to do so fails harmlessly. This is the strongest control and it is architectural.

Treat content as data. The intake agent does not read uploaded documents as instructions; photos go to the triage model, which returns a category, not text the agent acts on.

Keep humans on consequential actions. Carrier notifications are approved by advocates.

Use platform protections. Microsoft applies protections against jailbreak and cross-prompt injection attempts in Copilot and Copilot Studio; the design relied on them as one layer, not the only one.

Test. The boundary test set included direct and indirect injection attempts, and the security team would repeat a set of such tests before each major release.

Worked problem

Reviewing a proposed tool for excessive agency

During the proof-of-concept planning, Yusra proposed a "Send email" tool for the intake agent so it could email clients a copy of their notice. Review it.

Show solution
  1. Identify the risk: a general send-email tool lets anyone who can talk to the agent cause Quillfield to send email to any address with any content, which is attractive to spammers and to prompt injection.
  2. Narrow the capability: replace it with "Send notice confirmation", which sends a fixed template containing the reference and next steps.
  3. Constrain the recipient: send only to the email address the client entered, and only once per notice key.
  4. Choose the identity: a dedicated mailbox with send rights only, used by the flow, not the agent directly.
  5. Add tests: injection attempts asking the agent to send other content or to other addresses.

Answer: The client still receives a confirmation, while the agent gains no general email capability. The tool's narrow design, not the model's good behavior, provides the protection.

Monitoring, audit and response

Security design includes knowing what happened and responding when something goes wrong. The design listed the signals: Copilot Studio analytics and transcripts for conversations, Application Insights telemetry for the agent, flow run history, Dataverse audit logs, Purview audit for Copilot and agent activity, and Microsoft Entra sign-in and agent identity logs. Wystan asked for two alerts in the first release: unusual volumes of web chat sessions, and any tool error rate above a threshold. The response plan named who could disable the agent in an emergency and how: Saoirse's team could unpublish from the web channel within minutes, and Quillfield's managed security provider could escalate overnight.

Security reviews through the lifecycle

Security design is not a single gate. Wystan proposed three checkpoints for the claims solution: a design review of the threat and control register before the proof of concept, a configuration review of the production environment, identities and data policies before launch, and a short review whenever a new tool, channel or knowledge source is added. New tools were the trigger that mattered most, because each tool expands what the agent can do and therefore what a misuse could achieve.

Common mistakes

  • MistakeRequiring clients to create accounts at the moment of a loss.

    InsteadAllow low-risk reporting without sign-in and require verification only for capabilities that reveal information.

  • MistakeUsing maker credentials because they are convenient.

    InsteadPrefer end-user credentials; use a narrow, justified service or agent identity when users cannot be authenticated.

  • MistakeExposing general tools such as "send email" or "get record".

    InsteadExpose narrow, purpose-built operations with fixed templates and constrained inputs.

  • MistakeRelying on the model to resist prompt injection.

    InsteadLimit what an injection could achieve, treat content as data, keep humans on consequential actions, and test.

  • MistakeLeaving secrets in flow definitions.

    InsteadUse managed identities where possible and a key vault referenced through environment variables otherwise.

Summary and key terms

  • Build a threat and control register from the context diagram, covering classic threats plus prompt injection, harmful output and excessive agency.
  • Choose authentication per channel: Microsoft Entra ID for staff, no sign-in for low-risk client reporting, verification for capabilities that reveal information.
  • Prefer end-user credentials for tools; justify and narrowly scope service or agent identities; Microsoft Entra Agent ID and Agent 365 help govern agent identities.
  • Apply least privilege to tools, connections, knowledge, makers and autonomy; use managed identities and key vaults for secrets.
  • Use data policies, Purview, Dataverse security and auditing, web channel security and content moderation as layered controls.
  • Design monitoring, alerts and an emergency response, including who can disable an agent.
Threat model
A structured analysis of what could go wrong, who could cause it and which controls reduce the risk.
Prompt injection
An attempt to make a model follow instructions hidden in input rather than its own instructions.
Excessive agency
A risk where an agent has more permissions or autonomy than its task needs.
Microsoft Entra Agent ID
Identities for agents in Microsoft Entra so they can be inventoried, scoped, governed and audited.
Managed identity
An Azure identity that lets a service authenticate to other Azure services without stored secrets.
Least privilege
Granting only the access a task needs, for only as long as it is needed.

Practice problems

Work each problem on paper first, then reveal the answer to check.

  1. Why could clients report a loss without signing in?

    Show answer

    A report gives the reporter nothing they did not already know; false reports are handled by the advocate's call-back to the number on file.

  2. What was ADR-11 about?

    Show answer

    The justification for the intake agent's narrow service identity, since clients have no Quillfield identities.

  3. What is the strongest defense against prompt injection in the claims design?

    Show answer

    Not giving the agent tools that a successful injection could misuse.

  4. Which two alerts did Wystan ask for in the first release?

    Show answer

    Unusual web chat volume and tool error rates above a threshold.

Lesson quiz · 5 questions

Score 60% or more to complete this lesson.

Take the quiz