AI Engineering · Module 09
Guardrails and security
- Lessons
- 12
- Free
- 0
- Reading
- ~4 h
Your progress
0 / 12 lessons done
Sign in to trackLessons
- Risks in LLM applications: an overviewEvery AI feature that reads outside text or calls a tool will meet someone trying to misuse it. A clear map of the risks tells you which failures your code must make impossible and which ones you can measure and reduce.
- Prompt injection: when input becomes instructionsAny feature that sends text from outside your team to a model, such as an email, a chat message or a form field, can be steered by that text. Knowing which defences hold, and measuring them, decides whether an attack ends as a wrong draft someone catches or as money and data that leave.
- Indirect prompt injection through documents and toolsOnce a feature retrieves documents or calls tools, anyone who can write in those places can try to steer it, and the person being helped never sees the attack. Knowing every such path, and which defences hold without the model’s help, decides whether a stolen staff login ends as one marked draft or as a week of promises to customers.
- Data leakage: protecting secrets and personal dataEvery AI feature makes new copies of customer text: in prompts, logs, traces, indexes, eval sets and the provider’s systems. Each copy is a place it can leak from, and most leaks come from copies the team made itself, not from the model.
- Input and output guardrailsEvals tell you how often a feature goes wrong before a release. Guardrails decide what happens to the one output in front of a person right now, and every one you add costs time, money and some good output that gets stopped by mistake.
- Refusals and fallbacks: when the model declinesAny feature built on a current Claude model will sometimes get an answer of nothing, as a normal 200 response. Code that treats that as an error retries it, bills it and shows an empty screen; code that expects it gets the person a useful next step.
- Content moderation: filtering harmful outputAny product where staff read messages from the public, such as a help desk, a marketplace or a community, must decide what reaches those people and what leaves in the company’s name. Get the errors wrong and you either expose people to abuse or hide the customers who most need help.
- Least privilege for agents and toolsNo prompt makes a model impossible to steer, so the real limit on an AI feature is what its tools and credentials can do. Engineers who size that limit before launch turn a successful attack into a logged, capped proposal instead of a data leak.
- MCP security: servers, tokens and tool poisoningOnce your product has an MCP server, your customers will run it next to servers you have never seen. You can’t choose those servers, so your own server has to limit what a steered model can take and make every attempt visible.
- Red-teaming an AI applicationYour own tests only check the failures you already imagined. Before an AI feature talks to customers, someone has to attack it on purpose, write down what worked, and make sure each fix stays fixed in every later release.
- AI regulation: EU AI Act, DPDP and content labelsAny AI feature that talks to the public or handles their data meets these laws before launch. Knowing who owes which duty, and from which date, tells you what to build in from the start instead of patching it later.
- Design: a safe customer-facing assistantMost AI features keep a person between the model and the customer. The first one that doesn’t has to be safe by construction: what the model can see, what code lets it say, and what happens when anything looks wrong.
Practise with
Terms this module teaches 66
Open glossaryAI notice
A fixed message that tells a person they are talking to an AI system, what it can and can’t do, and how to reach a human. It is written by people and sent by code, never generated by the model.
Appeal path
A quick way for a person to overturn an automated verdict, whose corrections are also collected to measure and improve the check.
Attack campaign
An automated red-team run in which an attacker model works through an attack library against the real application and a judge scores each conversation.
Attack library
A team’s stored collection of attack ideas (seeds), each pairing a goal with a technique and saying what success looks like, used by people and by automated campaigns.
Attack mutation
Making variants of an attack seed by changing its wording, language, encoding or number of turns, so a campaign tests the neighbours of a known attack.
Attack set
A group of attack inputs kept in the eval suite, each labelled with the harm it tries to cause, run against every release.
Attack success rate
The share of attack runs in which the attack achieved its goal. Measured over several runs per attack, because model output varies.
Base rate
How common a problem is in real traffic, before any check runs.
Blast radius
Everything a component could damage if it misbehaved or were controlled by an attacker: what its tools and credentials allow, with any input, as often as its limits allow.
CaMeL
A defence design from a 2025 research paper in which a planner model writes a program from the trusted request, a quarantined model parses untrusted data, and an interpreter tracks each value’s source and checks policies before every tool call.
Canary token
A unique made-up string planted in one place only, so that finding it anywhere else proves that place leaked.
Complete mediation
Checking authorization on every access, in the system that performs it, rather than trusting an earlier check or the caller’s judgement.
Content moderation
Checking text or images against a written policy and acting on what breaks it, for example by blurring a message, routing it to a manager or holding back a reply.
Daily spend cap
A limit, enforced in your own code, on how much a feature may spend on model calls in one day for one customer or in total. When it is reached, the feature falls back to a cheaper path instead of calling the model.
Data exfiltration
Moving data out of a system to a place the owner didn’t intend. In AI apps, a steered model can do it by passing data as an argument to a tool that sends it elsewhere.
Data fiduciary
Under India’s DPDP Act, the organisation that decides why and how personal data is processed. It is responsible for the processing, including what its processors do.
Data principal
Under India’s DPDP Act, the person the personal data is about. For a child, it includes the parent or lawful guardian.
Data processor (DPDP)
Under India’s DPDP Act, an organisation that processes personal data on behalf of a data fiduciary, under a contract.
Datamarking
A spotlighting technique that interleaves a special character through untrusted text, usually in place of every space, so the model can tell that text apart from instructions.
Denial of wallet
An attack that runs up a pay-per-use bill, such as model API costs, by sending large volumes of requests, instead of trying to take the service down.
Deployer
In the EU AI Act, a business or body that uses an AI system under its authority, deciding what it is used for and how. Personal, non-professional use doesn’t count.
Deskora Chat
Deskora’s customer-facing chat widget on a shop’s website. It answers from the shop’s help center and reads order status, and hands refunds, replacements, discounts, account changes and angry or unclear cases to a support agent.
Direct prompt injection
Prompt injection where the attacker writes the input the feature is built to read, such as a customer’s own email or chat message.
DPDP Act
India’s Digital Personal Data Protection Act, 2023: the law on how digital personal data may be collected, used, kept and protected, carried out by the DPDP Rules, 2025.
Dual LLM pattern
A design with two models: a privileged one that plans and calls tools but never sees untrusted text, and a quarantined one that reads untrusted text but has no tools.
Enumeration attack
Trying identifiers one after another, such as sequential order numbers or a list of emails, to find which ones exist or to read the data behind them.
EU AI Act
The EU law (Regulation (EU) 2024/1689) that sets rules for AI systems by level of risk: banned uses, high-risk uses with strict requirements, transparency duties, and minimal-risk uses with no extra rules.
Excessive agency
A risk where an AI feature has more tools, permissions or freedom to act than its task needs, so a wrong or manipulated output can cause real damage.
False-positive rate
Of the items that are fine, the share a check wrongly flags.
General-purpose AI model
In the EU AI Act, a model that can do many different tasks and that other companies build into their own AI systems. Its maker has separate duties from the companies that build on it.
Guardrail
A check that runs on a model’s input or output and blocks, changes or flags it when it breaks a rule, such as leaking personal data or stating something unsafe.
Hand-off (to a person)
Ending an automated conversation by passing it to a human, with the conversation and the reason attached, so the customer doesn’t repeat themselves.
Indirect prompt injection
Instructions hidden in content the model reads while working, such as a tool result, document or web page, written to make it act against the app’s rules.
Input classifier
A separate, cheap model call (or other classifier) that labels an input before the main model call, for example as containing instructions aimed at an AI.
Jailbreak
An input written to make a model break its provider’s safety rules, rather than the application’s own rules.
Kill switch
A flag that turns a feature off at once in production, by hand or automatically when a metric crosses a threshold, without a deploy.
Lethal trifecta
Simon Willison’s name for an AI agent that has access to private data, reads untrusted content and can send data out; together they let injected text steal data.
Machine-readable marking
A sign attached to AI-generated content that software can find without a person, such as metadata, a watermark, a provenance signature or a log, so the content can be detected as AI-made.
Multi-turn escalation
An attack spread over several messages, each harmless on its own, that moves the model step by step toward breaking a rule.
Named entity recognition (NER)
A model that labels words in text as people, places, organizations or other kinds of names, using the surrounding words as context.
OAuth scope
A named permission inside an access token, such as read tickets or write notes. A server checks the scope before each action and refuses actions the token’s scopes don’t allow.
Order verification
Checking, in code, that the person asking about an order is its buyer, for example by matching the order number with the email on the order, before showing any of its details.
Over-refusal
A model or safety classifier declining a request that was harmless: a false positive of the safety check.
Precision
Of the items a check flags, the share that really have the problem. Unlike recall, it depends on how common the problem is.
Prompt injection
An attack where text in a model’s input is written to be followed as instructions, overriding what the application intended.
Provenance label
A tag that travels with a piece of text through an AI feature, saying where it came from and who could have written it, so the model, code and people can treat it accordingly.
Provider (AI system)
In the EU AI Act, the company that develops an AI system, or has it developed, and offers it under its own name. The provider carries duties such as telling people they are talking to an AI.
Recall
Of the items that really have a problem, the share a check flags.
Red-teaming
Attacking your own system on purpose, the way a real adversary would, to find failures before release. For an AI application the target is the whole feature, not only the model.
Refresh token
A longer-lived credential an app uses to get new short-lived access tokens without asking the user to sign in again. Rotation means each use returns a new refresh token and the old one stops working.
Refusal
A response in which the model declines to produce the requested output. On the Claude API it arrives as a normal 200 response with stop_reason refusal, not as an error.
Refusal category
The policy area named in stop_details.category when the Claude API declines a request: cyber, bio, frontier_llm, reasoning_extraction or general_harms, or null when none fits. Some categories are billed even when no output was produced.
Risk level
A graded score in a moderation verdict, such as none, low, medium or high, that the application maps to an action instead of a single yes or no.
Rug pull (MCP)
A server that changes a tool’s description, or what the tool does, after the user approved it. Consent given to the old version doesn’t cover the new one.
Rules of engagement
The written limits of a red-team exercise: what may be attacked, how, what is out of scope, and what happens when something serious is found.
Safety classifier
A check that runs with a model and can decline a request it judges could lead to harm. On current Claude models a decline comes back as a normal response with stop_reason refusal.
Server-side fallback
A Claude API option, in beta, where a request that one model declines is retried on another model within the same API call, and the response names the model that answered.
Severity
How bad a failure is: what it costs and whether it can be undone. Used with how often it happens to decide what to fix first.
Spotlighting
A family of prompt techniques that transform untrusted text, by delimiting, datamarking or encoding it, so the model has a continuous signal of where it came from.
Step-up authorization
Asking the user for more permission only when an action first needs it, instead of at sign-in. In MCP, the server answers 403 insufficient_scope with the scope it needs, and the client asks the authorization server again.
Synthetically generated information
In India’s IT Rules (as amended in 2026), audio, images or video made or changed by a computer so they look real. Text on its own is not included.
Threat model
A short written description of what a system must protect, where untrusted input enters it, and who might attack it, used to decide which defences it needs.
Token passthrough
When a server accepts an access token that wasn’t issued for it, or forwards the token it received to another service. MCP forbids both: a server accepts only tokens issued for itself and uses its own token for any service it calls.
Tool list pinning
Storing the tool list a user approved and sending that stored copy to the model, instead of whatever the server lists today. Changes are flagged for review rather than used.
Tool poisoning
Hiding instructions for the model inside a tool’s description, which the model reads but the user usually doesn’t see in full. It is a form of indirect prompt injection.
Tool shadowing
Tool poisoning aimed at another server’s tools: one server’s description changes how the model uses a tool from a different, trusted server.