AI: grounding, prompt injection and fairness

Why language models invent answers and obey planted text, the layered defences that stop both - grounding with citations, fences with a one-time nonce, no tools, checked output and a person who confirms - how to red-team an AI feature, how fairness is measured when AI touches people, and the OWASP Top 10 for LLM applications mapped to defences.

In short

A language model invents a fluent answer when it does not know one, and obeys instructions it finds in any text you show it. The first habit is called hallucination, the second prompt injection. {{brand}} answers the first with grounding: answer only from retrieved material, cite it, or say the sources don't cover it. It answers the second with layers: material fenced with a one-time nonce, a rule that material is never instructions, no tools for the model, and checked output. When AI acts, a person confirms every step; when AI touches people, it never judges them.

After this lesson you can Explain why models hallucinate and how grounding and citations reduce it. Tell direct from indirect prompt injection and build a layered defence against both. Let AI propose actions safely, with a person in the loop, and red-team the feature in every build. Map the OWASP Top 10 for LLM applications and the EU AI Act's hiring rules to real defences.

Words you need

Hallucination: why models invent, and how grounding stops it

A language model predicts the most likely next words. Fluent and true are different things, and nothing inside the model raises a hand to say I don't know. Asked about your workspace, which it never saw, it fills the gap with something plausible: an overdue count, a person's name, a date. Many ways of training and scoring models also reward a lucky guess over an honest I don't know, so models learn to guess. In a tool people use to decide whether something is tested or ready, a plausible invention is worse than silence.

Prompt injection: direct and indirect

A model reads its rules, the material and the question as one stream of text. It has no reliable way to tell which words came from the developer and which from a stranger, and prompt injection abuses exactly that. SQL injection is largely prevented by parameterized queries, which keep code and data in separate channels. Language models have no such channel yet, so every defence lowers the odds or limits the damage - none removes the risk.

The lethal trifecta Security researcher Simon Willison named three things that together make an AI feature exploitable: access to private data, exposure to untrusted content, and a way to communicate out. A feature with all three can be steered into sending your data to an attacker. Remove one leg and the attack loses its payoff. {{brand}} removes the way out: no tools, no unchecked links, no images loaded from model text.

The defence, in layers

No single rule stops every trick, so the defence is layered. Each layer catches some of what the one before it misses, and the last layers make sure that a fooled model still cannot do harm. Here they are in the order a question meets them.

The options in the market

Two decisions shape every AI feature: how to defend against injected text, and how much the AI may do on its own. These are the options teams choose between today.

What {{brand}} chose, and why

{{brand}} reads text written by many people it cannot vouch for: teammates, guests, job candidates and the APIs people test. So it assumes the model will sometimes be fooled, and builds the product so that a fooled model has nothing dangerous to do.

The trade-off accepted A fooled model can still write a misleading sentence inside an answer. {{brand}} accepts that and limits it. Answers cite their sources, links are checked and nothing acts without a person. Answer summaries and follow-up passages are held to closed sets and the person's own words; a CV summary is neutral description read through a strict schema; AI never scores or ranks.

Another choice is right elsewhere. An agent that must browse the open web and act alone needs more: an input classifier, sandboxed tools, an allowlist of where data may go, and tight budgets. A consumer chat app with millions of anonymous users may want a classifier in front as well. And where an AI judgement would decide something about a person - a loan, a hire - the right amount of AI in the decision may be none.

Treat model output as untrusted input

OWASP calls this risk improper output handling: the app trusts what the model wrote and renders it as HTML, runs it as SQL or follows it as a link. The rule is simple - model output is input from a stranger. Check it the way you check a form field, every time, on the server.

Why the check repeats until nothing changes Removing a link can create a new one. In [[x](https://a.example)](https://b.example), taking out the inner link leaves [x](https://b.example) - a fresh link to check. So the check runs again until the text stops changing. A real product may also allow links quoted by its own trusted documentation. Whatever the rule, the check must read links the same way the screen does.

Excessive agency and the human in the loop

Agency is what a model can do beyond writing text: every tool, every right and every step taken without asking adds to it. OWASP lists excessive agency as a risk of its own, because it turns a fooled model into a fooled employee with keys. {{brand}}'s rule: the AI has no powers of its own. It can only propose what the person could do by hand, and the person confirms.

One gate for every model call

A product with many AI features cannot trust each one to remember the rules. So every model call passes one gate, whatever made it and whoever's key answers. The gate holds the rules that must never depend on a feature author's memory, and a new feature gets them for free.

Why a reused answer is safe An answer may be reused only under a key that is a fingerprint (a hash) of the exact material it was built from. If another person's own permission-checked retrieval returns different material - an edited page, a record they cannot see - the fingerprint differs and they get a fresh answer. Safety comes from what the key contains, not from trusting the cache.

Red-team testing of AI features

A model answers differently from one day to the next, so you cannot prove safety by asking it nicely a few times. Instead, test the system around the model with a stand-in that is as bad as possible: a fake model that obeys every planted instruction. If the invariants hold when the model is completely fooled, they hold when it is only a little fooled.

Fairness: when AI is about people

Bias in AI is usually learned from history. A widely reported example: an experimental recruiting model trained on ten years of past CVs learned to rank down CVs that contained the word women's, as in women's chess club. Nobody wrote that rule; the data taught it. Such a judgement is hard to measure, harder to fix and impossible to explain to the person it rejected. So {{brand}}'s rule is short: AI never scores, ranks, recommends or rejects a person.

When free text is unavoidable, restrict it to neutral description, read only the fields you expect, and drop anything else the model adds. When it is avoidable, check the output instead of trusting it: topics must come from a closed list, and a quote must appear word for word in the source.

Fair by construction, then measured Two ideas carry the design. Construction: give the model a task that cannot judge - pick from a closed list, quote word for word. Measurement: check the remaining filters on data they never saw, language by language, and keep a language off until it passes. The features that summarize or quote what candidates wrote run on the platform's own models, because that is where the filters were measured.

How bias is measured

Saying a system is fair is not a measurement. A junior engineer should be able to answer: how would you test this model for bias? The honest answer is a few small, repeatable tests on data you did not tune on, run for every group you care about.

The OWASP Top 10 for LLM applications, mapped to defences

OWASP - the Open Worldwide Application Security Project - publishes a Top 10 for large language model applications (this lesson follows the 2025 edition). It is the checklist security reviewers and interviewers use. Here is each risk, what it looks like, and how {{brand}} answers it.

Use it as a design checklist Read the list before you build an AI feature, not after. For each risk, write down the layer that answers it and the test that proves it. A risk with no test is a risk you only hope is covered.

Try it yourself: attack and defend a tiny assistant

You need any chat model - the free tier of a hosted API, or a local model run with Ollama - and an hour. You will watch an injection work, then take its payoff away.

Common mistakes

Interview questions

Related