Chapter 3. Data protection and permissions

Learning objectives

  • Identify where sensitive information leaks across the data lifecycle from input to logs and minimize it.
  • Diagnose excessive agency by breaking it down into functionality, permissions, and autonomy, and reduce permissions through tool design.
  • Determine under whose authority the agent runs, and minimize delegated tokens and scopes.
  • Treat model outputs as untrusted input, rendering and handling them safely according to their destination.
  • Correct common misconceptions about system prompts and vector stores.

Introduction

The consultation chatbot of a shopping mall used a tool that looked up entire customer accounts in order to answer questions accurately. For a single shipping inquiry, the address, phone number, the ten most recent orders, and even the points balance history entered the context. On most days, there was no problem. Then, when a customer asked, "Show me all the orders from last month," from an account shared with family members, the chatbot kindly laid out even the orders of the other family members. The model made no mistake. It merely faithfully organized the data it had received. The team hurriedly added the sentence "Do not speak of other people's information" to the prompt, but the model had no way of knowing which of the family members using the same account was currently asking. The solution lay not in the prompt, but in the lookup tool.

If Chapter 2 covered "how an attacker's instructions enter," this chapter covers "what they can do once they have entered." The model can state what has entered the context, and does what can be done with the tools in its hands. Therefore, reducing data and permissions constitutes half of injection countermeasures. This chapter begins with pathways and minimization of sensitive information, sequentially covers data terms of external AI services, system prompts and vector stores, excessive agency and tool permission design, and delegation and identity, and finally learns how to safely render and handle model outputs.

Key concepts

Where sensitive information leaks: Data lifecycle

OWASP LLM02 (Sensitive Information Disclosure) addresses the risk of personal information, financial information, health records, confidential business data, credentials, and legal documents being revealed through model outputs. It also points out that data entered by a user can reappear in model outputs later. Because looking only at the final answer misses many points, we follow the entire lifecycle.

Stage How it leaks Basic control
Input collection The user directly enters a Resident Registration Number or password Input guidance, pattern detection and redaction
Context assembly Inserting more records and fields than necessary Field-level lookup tools
External model invocation Transmitting raw text to an external provider Redaction and pseudonymization, verifying contractual terms
Tool arguments The model passes sensitive values to another tool Argument validation, destination restriction
Output Exposing information of another user or another family member Server-side authorization, output inspection
Logs and cache Raw conversations remain in logs and cache Log redaction, retention periods (Chapter 5)
Derived data Remaining in summaries, embeddings, and fine-tuning data Pre-training cleansing, derivative data deletion procedures

OWASP warns that while restricting via system prompts with instructions like "Do not return this kind of data" helps, it is not always followed and can be bypassed by injection. The most definitive protection is not showing it to the model in the first place.

Minimization, redaction, and pseudonymization

Data minimization is the principle of "passing only the fields necessary for the task at the moment they are needed." A shipping inquiry requires the delivery status and scheduled date, not the entire address. This principle is implemented through tool design, not through prompts. Instead of a tool that returns the entire customer record, build a tool that returns only "the shipping status of this order." Korea's Standards for Ensuring the Safety of Personal Information also requires specifying the purpose when outputting personal information and minimizing output items according to that purpose. Passing data into an LLM context should be designed in the same spirit.

Values that must inevitably be passed are redacted.

Method What it does Where to use
Redaction Erases values or replaces them with asterisks Logs, when the model does not need to know the value
Tokenization Replaces values with meaningless surrogate strings and keeps a lookup table separately When the model only needs to know that it is the "same person"
Pseudonymization Alters data so that a specific individual cannot be recognized without additional information Analytics, preparing fine-tuning data

When tokenization is used, the lookup table becomes a new critical asset. The lookup table is not kept in the same storage as the model; it is stored encrypted, and access to it is separately controlled and logged. Redact before sending externally, and restore to the original value only where necessary after receiving the response.

Terms of data sent to external AI services

When using an external provider's model, data crosses organizational boundaries. The questions to check are: is it used for training, how long is it retained for abuse monitoring, until when does application state (conversations, files, vector stores) remain, under what conditions can options that reduce retention be used, and in which region is it stored?

Taking OpenAI's data controls documentation as an example: Data sent via the API is not used for model training unless the user explicitly opts in. Abuse monitoring logs are retained for up to 30 days, but may be retained longer if required by law or necessary to protect the service and third parties from harm. Zero Data Retention and Modified Abuse Monitoring, which reduce data retention, can be used only after obtaining prior approval. Some features retain application state until the user deletes it. Because conditions differ by feature and contract, check official documentation and agreements on a feature-by-feature basis and record the verification date. If personal information is sent to an overseas provider, also verify the cross-border transfer requirements (separate consent or statutory exceptions) under Article 28-8 of the Personal Information Protection Act (PIPA) together with the Privacy Officer.

System prompts are not secrets

The key sentence of OWASP LLM07 is "System prompts must not be treated as secrets or used as security controls." The same document explains that rather than the exposure of the prompt wording itself, the sensitive information and permission structures placed inside it are the real risks.

What must not be placed in prompts What happens if revealed Where to place it
API keys, database connection information Direct access to other systems Secret store, server configuration
Transaction limits, approval rules Splitting requests just below the limit Server-side policy engine
Filtering criteria Searching for phrasing that evades filters Separate guardrails
User roles and permission structures Privilege escalation attempts Authorization system

Separation of privileges and authorization checks are performed outside the model in a deterministic and auditable manner. Tasks with different access levels are divided among multiple agents with least privilege. The goal is a "design where nothing happens even if the prompt is exposed entirely." The 2026 edition of OWASP expands this item to Hidden Context Exposure (LLM08:2026), broadening to developer instructions, retrieved policy text, and tool schemas under the same principle.

Permissions in RAG and vector stores

OWASP LLM08 (Vector and Embedding Weaknesses) cites access control failures and data leakage, cross-context leakage when multiple user groups share a single store, embedding inversion that reconstructs substantial portions of the raw text from embeddings, and index data poisoning as risks of vector stores. Mitigations include permission-aware vector stores and strict segmentation, verification of knowledge sources, review and classification of combined data, and immutable logs of retrieval activity.

The design principle is "Permissions are applied prior to generation, at the retrieval stage." Instructing the model "Do not speak of this document" after it has read an unauthorized document is the mistake of using a prompt as a control. By pre-filtering—attaching the requester's permission conditions directly to the search query—only chunks that were permitted in the first place are returned. When document permissions change or documents are deleted, chunks in the index and caches must also be updated together. It is common for documents deleted from the original source to remain in the index and continue to be retrieved. Treat embeddings as data just as sensitive as the raw text. The fact that they are arrays of numbers is not a protection mechanism.

Excessive agency: Three roots and eight preventive measures

OWASP LLM06 (Excessive Agency) is a vulnerability that enables harmful actions to be executed in response to unexpected, ambiguous, or manipulated model outputs. Regardless of whether the cause is hallucination or injection, the crux is how far things can go when the model makes a wrong judgment. There are three roots.

Root Example How to fix
Excessive functionality A document-reading tool that also has edit and delete capabilities, tools left behind from testing Tools with only necessary functionality, removing unused tools
Excessive permissions Write permissions when only read is needed, shared high-privilege account reaching all user data Read-only permissions, execution in user context
Excessive autonomy Executing high-impact actions without independent verification or user confirmation User approval

The eight preventive measures presented in the 2025 edition are: reducing the number of extensions (tools), reducing functionality per tool, avoiding general-purpose tools, reducing tool permissions, executing in user context, obtaining user approval, complete mediation, and input/output sanitization. The 2026 edition (LLM03:2026) removed input/output sanitization from this list and organized it into seven items. It separately classifies logging and monitoring and rate limiting as reducing the blast radius but not preventing excessive agency itself.

Complete mediation is the principle that "permission is determined not by the model, but by the downstream system on every request." It is like having the badge inspection performed by the turnstile mechanism rather than by the front-desk clerk's memory. Even if the model cannot forge a badge, it can persuade the front-desk clerk.

Translating tool permission minimization into design

Tool permission minimization must manifest not as a principle, but as tool specifications. The OWASP AI Agent Security Cheat Sheet recommends defining permissions per tool by separating reads, writes, and target resources, assigning different tool sets to agents with different trust levels, and failing closed when tools are unknown or approval requirements are missing.

Design mechanism Example
Separating lookup and modification Making get_order_status and request_refund separate tools
Purpose-built tools instead of open-ended tools run_test_suite instead of a general-purpose shell, searching allowed domains instead of fetching arbitrary URLs
Argument constraints Placing enums, ranges, and formats in the schema, and reverifying on the server
Target restrictions Recipient allowlists, monetary caps, daily call limits
Short-lived credentials Issuing per job and revoking once finished
Default deny Never executing tools, arguments, or targets not on the list
{
  "name": "reschedule_my_booking",
  "description": "Changes the date of a single booking belonging to the logged-in user. User confirmation is required before execution.",
  "input_schema": {
    "type": "object",
    "properties": {
      "booking_id": { "type": "string", "pattern": "^BK-[0-9]{8}$" },
      "new_date": { "type": "string", "format": "date" }
    },
    "required": ["booking_id", "new_date"],
    "additionalProperties": false
  }
}

The schema is a mechanism to help prevent the model from generating malformed arguments, but the real control resides on the server. On every request, the server re-checks whether this booking belongs to the logged-in user, whether the new date is within the permitted range, and whether the user has confirmed.

Delegation and identity: Under whose authority does it run?

When an agent calls other systems on behalf of a user, "under whose authority" must be clear. If all calls go out under a highly privileged shared service account, a user who tricks the model can access all data that the account reaches, and the requester is not recorded in the logs. The OWASP Agentic Top 10 states that true least privilege cannot be enforced without managed agent identity, citing this as a cause of ASI03 (Identity and Privilege Abuse). OWASP LLM06 advises executing actions on behalf of a user in that user's context with least privilege—for example, with OAuth authentication at the minimum necessary scope. The MCP security best practices specifically point out the pitfalls of delegation structures.

Pitfall Requirement of the MCP documentation
Token passthrough Verify that the audience of the received token is this MCP server, and reject tokens issued for elsewhere. The authorization specification explicitly prohibits this pattern
Confused deputy (the problem where an authorized intermediary is tricked into exercising authority on behalf of another) MCP proxy servers that relay third-party APIs must implement per-client consent
State handle hijacking Possessing a state handle must not be treated as authentication; bind handles to the authenticated user on the server
Broad scopes Start with minimum scopes and step them up as needed, avoiding wildcards and consolidated scopes

Passing tokens directly disables rate limiting and audit logging on downstream APIs, and someone who steals a token can use the intermediary server as an exfiltration pathway. If broad scopes are acquired from the outset, the moment a single token leaks, every tool is unlocked.

Outputs are untrusted inputs

OWASP LLM05 (Improper Output Handling) is a flaw where model output is not validated, sanitized, and handled before being passed to downstream components. Because output can be manipulated through prompts, using the output as-is is equivalent to granting the user indirect access to downstream functionality. OWASP recommends a zero-trust approach that treats the model "like any other user."

Where output goes Risk Basic control
Browser (HTML, Markdown) XSS, exfiltration via external requests Context-aware encoding, sanitization, CSP
Database SQL injection Parameterized queries
Shell, eval, template engines Remote code execution Avoid execution; sandbox if unavoidable
File paths Path manipulation Normalization and allowed directories
Email templates Phishing Escaping
CSV exported to spreadsheets Formula injection Handle cells so they do not start with formula characters

The impact grows when the model's privileges exceed those of the user, when it is vulnerable to indirect injection, and when output is not encoded appropriately for the context. The risk of installing malicious packages published by attackers using package names hallucinated by models is also addressed by OWASP under this item and LLM09.

Safe rendering of outputs

Rendering model output on screen follows the same rules as rendering user input on screen. Applying the principles of the OWASP XSS Prevention Cheat Sheet to LLM outputs yields the following:

  1. Default to rendering as text. Use methods that handle data solely as text, such as textContent instead of innerHTML.
  2. If formatting is strictly necessary, disable raw HTML in the Markdown renderer and filter the result with an allowlist-based sanitizer. OWASP recommends DOMPurify for HTML sanitization.
  3. Do not use framework escape-bypass features (such as React's dangerouslySetInnerHTML) without sanitization.
  4. Restrict links and images with allowlists. Not loading external images automatically closes exfiltration channels that carry data in image URLs. Check schemes (such as javascript:) and domains for links, and display the actual destination before clicking if necessary.
  5. CSP (Content Security Policy) is an additional defense layer. OWASP advises not to rely on CSP as the primary defense mechanism.
  6. Because streaming output is rendered before all chunks are collected, ensure that unsanitized intermediate results are not rendered on the screen.
<!-- Bad example: Interpreting model output directly as HTML -->
<div id="answer"></div>
<script>answer.innerHTML = modelOutput;</script>

<!-- Better example: Render as text; for formatting, use only sanitized results -->
<script>answer.textContent = modelOutput;</script>

Addresses and code chosen by models: SSRF and code execution

When a server sends requests or executes code using values generated by a model, the risks of output handling move inside the server. If the server fetches a URL chosen by the model as-is, that URL could be replaced with an internal management page or cloud metadata address via injection. This is Server-Side Request Forgery (SSRF). The MCP security best practices recommend that clients fetching OAuth-related URLs require HTTPS in production environments, block private, loopback, and link-local address ranges, inspect redirection targets by the same criteria, and use an egress proxy that blocks internal destinations. It also adds a warning not to implement IP validation directly. This is because encoding tricks are easy to miss. This principle applies directly to all tools where the model chooses URLs.

Executing code or commands generated by a model without sufficient validation and isolation leads to the risk of ASI05 (Unexpected Code Execution) in the OWASP Agentic Top 10. The fundamental principle is "Do not execute if you can avoid execution," and if execution is necessary, run it in a dedicated container or virtual machine with least privilege, restricting network and file access, and without secrets. Anthropic's computer use tool documentation also cites dedicated virtual machines or containers with least privilege, domain allowlists, and the isolation of sensitive data such as login credentials as preventive measures.

MCP 2026-07-28 authorization: Verify token issuer and audience

The current protocol version of MCP is 2026-07-28. The authorization rules of this revision converge on one question: Who issued this token, and for which server was it issued?

Rule Requirement of 2026-07-28
Discovering the authorization server MCP servers must implement OAuth 2.0 Protected Resource Metadata (RFC 9728). Clients discover the authorization server using this document
Audience targeting Clients send the canonical URI of the MCP server in the resource parameter of RFC 8707 in both authorization requests and token requests. It is sent even if the authorization server does not support it
Verifying the issuer If iss of RFC 9207 is present in the response, the authorization code is exchanged only after matching it against the recorded issuer
Client registration Dynamic Client Registration (RFC 7591) has been deprecated, and its place is taken by OAuth Client ID Metadata Documents. DCR remains only for backward compatibility with authorization servers that do not support this
Token passthrough A server neither accepts a token not issued for itself nor passes it elsewhere

Remember resource and iss as a pair. The former nails down where the token will be used at the issuance stage. The latter filters out responses sent by unexpected authorization servers prior to code exchange. If even one is missing, a single token can work across multiple servers, or code from an authorization server set up by an attacker can infiltrate the normal flow. For newly built clients, revisit registration flows relying on DCR first.

Consider a hypothetical internal wiki relay server. Passing the token sent by the user directly to the wiki API may keep the implementation short, but it violates the rules. The server accepts only tokens issued with its own canonical URI as the audience. When calling the wiki API, it uses a token separately obtained with the wiki as the audience. Only then will the actual calling entity be recorded in the wiki's audit logs.

Sessionless MCP: Boundaries between sensitive inputs and cache

With the 2026-07-28 revision, MCP became a stateless protocol. Protocol-level sessions and the Mcp-Session-Id header were removed from the Streamable HTTP transport. Among the flows that relied on sessions, two intersect with this chapter: asking the user for values, and reusing results.

Elicitation, where a server asks the user for additional information, has form mode and URL mode. In form mode, values entered by the user pass through the MCP client before returning to the server. Therefore, passwords, API keys, access tokens, and payment information must not be requested in form mode. Such values are collected directly by redirecting the user to a server-side page in URL mode. Completion signals have also changed. Both the notifications/elicitation/complete notification and the elicitationId field from the 2025-11-25 version are gone. The client checks the result by re-sending the original request. The server ties that re-request to the preceding flow using requestState.

On the reuse side, ttlMs and cacheScope became mandatory in the results of tools/list, prompts/list, resources/list, resources/read, and resources/templates/list. The value of cacheScope is either public or private. Results whose contents differ depending on the requester's permissions are marked as private. Only results that remain the same no matter who asks are designated as public. Setting the scope incorrectly can cause one user's document list to reach another user via the shared cache.

For a hypothetical travel booking MCP server, it is organized as follows: A draft that collected card numbers via a form is switched to URL mode to collect them on the server's payment page. private is attached to resources/read returning customer-specific booking histories, and public is attached to terms of service documents that are identical for everyone.

Identity and origin narrowed per task: GitHub Actions OIDC and Chrome agent

Handing long-lived secrets to pipelines or agents means that the moment that value leaks, all permissions leak with it. It is better to grant only the identity and action scope suited to a single task on demand. Two examples of different natures illustrate the same principle.

In GitHub Actions, instead of keeping cloud keys in repository secrets, OIDC tokens are exchanged. An OIDC JWT cannot be requested if the job lacks the id-token: write permission. For AWS, the aws-actions/configure-aws-credentials action receives the JWT from the GitHub OIDC provider and exchanges it for AWS credentials. At this time, the IAM role trust policy must narrow the entity assuming the role using the sub claim.

The format of this sub diverges based on July 15, 2026. Repositories created after that date use an immutable default subject containing the owner and repository ID. Existing repositories retain the legacy format unless they opt in. However, repositories renamed or transferred after this date transition to the new format. GHES is not affected. Trust policies written based on repository names must be re-checked to ensure they remain correct after renames or transfers.

Chrome's Gemini agent ported the same principle to the browser. In the design unveiled by Google on December 8, 2025, Agent Origin Sets restrict the agent to task-related origins and divide them into a read-only set and a read-write set. User confirmation is obtained before navigating to sensitive sites like banking or healthcare, before signing in with Google Password Manager, and before purchases or payments.

If a hypothetical team were organizing a deployment workflow, they would grant id-token: write only to the deployment job and omit it from test jobs. The role trust policy permits only the sub of the deployment repository. The two designs resemble each other in that identity is bound to the job and origin is bound to the task.

Going deeper

Binding approval to execution

Even if human confirmation is in place, confirmation loses its meaning if "what the user saw" differs from "what is actually executed." The approval screen may have displayed "Reschedule meeting," but ten attendees might have been added to the actual invocation arguments. Furthermore, a user's permissions might be revoked during a long-running task, yet execution runs to completion using the approval obtained at the start of the task. This is the problem of a mismatch between the time of check and the time of use (TOCTOU, Time-of-Check to Time-of-Use).

Approval bound to execution incorporates the following safeguards. The approval request contains the target, arguments, and expected effects as their original values. The approval is stored alongside a hash of those arguments, and right before execution, the arguments are compared to verify whether they match; if they differ, the user is prompted again. The approval is assigned an expiration time and a one-time use limit. In addition, the user's current permissions are rechecked immediately prior to execution. The "pre-action preview" and "undo" recommended by the OWASP AI Agent Security Cheat Sheet also accompany this design.

Isolation of derived data: cache, memory, summary, and export

Even when permissions on the source repository are flawless, data gets mixed up along derivative paths. If user or organization identifiers are omitted from the response cache key, another organization asking a similar question receives the previous organization's answer. When multiple teams reuse shared summaries, confidential information embedded in those summaries reaches unauthorized teams. Conversation exports and shared links often bypass the authorization checks of the original conversation.

There is a single checkpoint question: "Does this derivative inherit the permission boundary of the original?" Answer this question for every cache key, memory store, summary store, export file, and embedding index; wherever the answer is "no," attach user and organization scopes or prevent reuse. The OWASP AI Agent Security Cheat Sheet also treats memory isolation between users and sessions as a distinct item.

At work

Wholeness Hospital: Why medical records were removed from the appointment agent

Wholeness Hospital, a general hospital, sought to introduce an appointment reservation agent. In the draft design, the agent used a service account with read and write permissions across the hospital's entire patient database, placed the patient's entire recent medical records into the context to improve answer quality, and executed reservation changes immediately. Notices written by the agent were rendered in HTML on the app screen, and the internal reservation API address and key were contained in the system prompt.

The security reviewer diagnosed the issue along three roots. In terms of functionality, they asked whether querying medical records was necessary for booking appointments, and determined that only available appointment slots and the patient's own list of reservations were needed. The tool for querying medical records was removed. In terms of permissions, write permissions were reduced strictly to the reservation table, and calls were executed using the token of the logged-in patient themselves. The reservation server directly verified "Can this patient modify this reservation?" on every request. In terms of autonomy, reservation cancellations and transfers to another medical department were executed only after the patient confirmed the date, department, and medical staff on the screen.

Outputs and secret values were also inspected. Notices were rendered as text but passed through a sanitizer that permitted only bold text and lists, while links and images were restricted strictly to the hospital's domain. The API address and key originally in the system prompt were moved to server configuration and a secrets store, and keys that had already been exposed in the prompt were revoked and reissued.

To the counterargument that "medical records are necessary to make accurate doctor recommendations," they responded with a tool that returned only two fields: department and Attending Physician. As a result, even if the agent were compromised, its capabilities were reduced to "showing the user's own reservations and modifying them upon confirmation." On the risk register, "the patient approving on the confirmation screen without reading the content" was recorded as residual risk, and an undo feature allowing reversal within 24 hours of cancellation was scheduled as a task for the following quarter.

Whale Market: One sentence poses different risks in three places

Secondhand trading platform 'Whale Market' built a feature where, when a seller uploaded photos and a short note, a model drafted the listing title and description. The description generated by the model was routed to three destinations: it was rendered in Markdown on the public listing page, displayed on the operations team's review screen, and exported to a weekly operational report CSV to be opened in a spreadsheet.

Two issues were discovered during the beta period. A seller included an HTML snippet in their note, and the model transcribed it verbatim into the description, breaking formatting on the review screen and causing script tags to appear directly on the display. Fortunately, because the review screen rendered content as text, the script was not executed. In addition, some descriptions contained links to external payment sites prompted by sellers in their notes. The operations team proposed, "Let us instruct the model not to use HTML or links."

The security lead treated that instruction only as a secondary measure and applied controls separately for each destination. The public page routed content through a Markdown renderer with raw HTML disabled and an allowlist sanitizer, preserved only links within the platform domain, and displayed only images uploaded to the platform. The review screen rendered content as text while displaying the original note and the model description side by side. In the CSV export, single quotes or tabs were prepended to cells starting with formula characters so that they would be interpreted as text; following OWASP's warning that no universal sanitization method exists due to differing behaviors across spreadsheets, results were verified on the software actually used by the operations team.

The lesson was that "even with identical output, risks and controls differ depending on the destination." Had they relied on a single line of model instruction, all three destinations would have been left exposed simultaneously the day that instruction was bypassed.

Common mistakes

  1. "Writing prohibition rules in the prompt establishes permission control." The entity enforcing the rules is still the model. Downstream systems must determine whether to permit an action on every request.
  2. "Outputs produced by our own in-house model can be trusted." Outputs reflect external content read by the model as well as user input. Treat them exactly like user input before rendering and execution.
  3. "Keys can be kept in the system prompt since they are not visible to users." Invisibility is not a security control. Keep keys where the model cannot reach them directly.
  4. "The more data included for accuracy, the better." The exposure surface expands as more data is included. Create tools that return only the necessary fields.
  5. "Embeddings are safe because they are numbers." A substantial portion of the original text can be recovered through embedding inversion. Control access at the same level as the original text.
  6. "Excessive agency is resolved because logging and rate limiting have been implemented." OWASP classifies both of these as means of mitigating damage. Prevention lies in reducing functionality, permissions, and autonomy.
  7. "Arguments are safe because they passed schema validation." Even if the format is valid, targets and amounts may be incorrect. Business rules and access permissions for that object must be rechecked by the server on every request (OWASP Authorization Cheat Sheet).
  8. "Output encoding can be skipped because CSP is present." CSP is an additional layer of defense. Context-aware encoding and sanitization must come first.

Summary at a glance

Topic Sentence to remember
Sensitive information The model speaks what it has seen. Not showing it is the most reliable approach
Minimization Use field-level tools, and mask before external transmission
External providers Check training usage, retention periods, state retention, and approval conditions on a feature-by-feature basis
System prompt Neither a secret nor a control
RAG Permissions at the retrieval stage; deletions and permission changes down to the index
Excessive agency Functionality, permissions, autonomy; complete mediation
Tool design Separation of queries and mutations, purpose-built tools, argument constraints, default deny
Delegation User context, minimum scope, prohibition against forwarding tokens as-is
Output handling Treat the model as an untrusted user; destination-specific controls
Rendering Text first, sanitization, allowlists for links and images, CSP as secondary
SSRF and code execution Validate model-selected addresses; run code only in isolated environments

Check the official docs

Self-check

3-1. Name three lifecycle points other than the final response where sensitive information remains or leaks, and write one default control for each point.

3-2. What are the two items that OWASP LLM06 classifies as "means of reducing the scale of damage" as distinct from preventive measures, and why are they not preventive measures?

3-3. Define the principle of complete mediation in one sentence, and give one example of a design that violates this principle.

3-4. Write four items that must be verified on a per-feature basis when reviewing the data terms of an external LLM API provider.

3-5. In one sentence each, write the default method when rendering model output on a web screen, the method when formatted HTML is strictly required, and the relationship that CSP has with both of these.

3-6. What do MCP security best practices prohibit regarding state handles, and what must the server do instead?

3-7. Design task: There is an internal assistant that reads employee schedules and reserves meeting rooms. Design up to three tools for this assistant to use, and write one line for each tool detailing its function, permissions, and whether user confirmation is required.

Hands-on tasks

Exercise

Writing a tool permission reduction plan (40 minutes)

  1. List all tools used by the agent or chatbot, and create a table recording each tool's function, permissions, autonomy (whether it executes without confirmation), and execution identity (shared account or user context).
  2. In the adjacent column, write the minimum functions and permissions required for actual work.
  3. For each cell where there is a difference, choose how to reduce it from among "replace with a purpose-built tool", "separate query and mutation", "read-only", "execute in user context", "restrict arguments and targets", or "human approval".
  4. Search for any secret values, limits, or permission structures contained in the system prompt, compile them into a list, and write down where to move them.

Done when: Functions or permissions have actually been reduced in at least one tool, and there is a plan to reduce secrets in the prompt to zero.

Exercise

Creating a model output destination checklist (35 minutes)

  1. List all destinations where model output goes (web screen, admin screen, email, DB, file, export, arguments of another tool).
  2. For each destination, write "what the output can be interpreted as" (HTML, SQL, shell, path, formula, URL).
  3. For each destination, compare the controls currently applied against the default controls in this chapter, and mark any missing controls.
  4. For the single most dangerous destination, create one test input using fake data assuming that the model produced dangerous output, and write down the expected result.

Done when: Three or more destinations are cataloged, and every destination has at least one control listed that operates independently of model instructions.