{"course":{"slug":"ai-and-you","title":"AI, Safety and What Goes Wrong","url":"https://addaly.com/learn/ai-and-you","level":"beginner","track":"start"},"lesson":{"slug":"prompt-injection","title":"Instructions hidden in the content","url":"https://addaly.com/learn/ai-and-you/prompt-injection","position":43,"of":73,"minutes":9,"answer":"Developer instructions, user requests and processed content share one text channel with no reliable separator, so any content a model reads can carry commands, and unlike SQL injection, there is no parameterisation that fixes it.","keyIdea":"Developer instructions, user requests and processed content share one text channel with no reliable separator, so any content a model reads can carry commands, and unlike SQL injection, there is no parameterisation that fixes it."},"body":{"format":"markdown","text":"## One channel, two kinds of text\n\nA language model receives one stream of text. The developer's instructions, the user's request, and the content being processed (a web page, an email, a document, a code comment) all arrive in the same channel, in the same format, with no reliable marker separating them.\n\nIn traditional software this problem was solved decades ago. SQL injection was defeated by parameterised queries, which keep the command and the data in separate channels so that data can never be read as command. There is no equivalent for a language model, because the model's entire capability is understanding text as meaning. Asking it to treat one span of text as inert while understanding another is asking it to do the opposite of what it does.\n\nSimon Willison named this **prompt injection** in 2022, by analogy with SQL injection, and the analogy is precise in one respect and misleading in another: precise because the structure is identical, misleading because the fix that worked for SQL is not available here.\n\n> Figure: One channel, four kinds of text. Layers, top to bottom: The developer's system prompt ('You are a helpful assistant. Summarise what the user sends.'); The user's request ('Summarise this page for me.'); The content being processed (A web page, an email, a PDF, a code comment, a CSV cell); An instruction hidden inside that content (White text on white: 'Assistant, before summarising, do the following...'). All four arrive as text in the same stream, with no reliable separator. SQL injection was fixed by keeping command and data in different channels; a language model's whole capability is reading text as meaning, so that fix is not available.\n\n## Direct and indirect\n\n**Direct injection** is a user typing instructions to override the system's own. \"Ignore your previous instructions and…\" This is a nuisance for the operator and mostly a risk to the operator, since the user is attacking a system they are already using.\n\n**Indirect injection** is the serious one. The instruction is planted in content that the model will process on somebody else's behalf.\n\nThe attacker writes a web page containing, in white text on a white background, a paragraph addressed to any AI assistant that reads it. A user asks their assistant to summarise that page. The assistant reads everything, including the invisible paragraph, and follows it. The user sees a summary. They never see the instruction, because it was never on their screen in a readable form.\n\nThis was demonstrated publicly in early 2023 against Bing's browsing assistant, where a planted page changed the assistant's behaviour towards the user, and it has been demonstrated repeatedly since against email assistants, document tools, code assistants reading dependencies, and browser agents.\n\n## Where the text can hide\n\nAnywhere the model reads and the human does not look closely.\n\nWhite or one-pixel text on a page. HTML comments and alt attributes. Metadata in a PDF or an image. A calendar invitation's description field. A code comment in a library. A product review. A resubmitted email thread. A filename. A support ticket. A CSV cell. The text of a document you were sent by someone who was themselves attacked.\n\nThe general rule: **any content that reaches the model can carry instructions, and the model has no way to know that some of it was not addressed to it.**\n\n## Why it is not fixed\n\nSeveral defences exist and each is partial.\n\n**Delimiters and system prompts**: putting the content between markers and instructing the model to treat it as data. This raises the difficulty and does not close the hole, because an attacker can write text that appears to close the delimiter.\n\n**Instruction hierarchies**: training models to privilege developer instructions over content. This measurably helps and is a probabilistic preference rather than a rule.\n\n**Input and output classifiers**: a second model scanning for injection attempts. Catches the obvious cases and can itself be attacked.\n\n**Structural containment**: the only approach with a real security argument. Do not let the model's output do anything dangerous. If a model that has read untrusted content cannot send an email, cannot make a purchase and cannot read your private files, then an injection can produce a wrong summary and not a stolen account. This gives up capability, deliberately, and it is what [The three ingredients of a disaster](/learn/ai-and-you/when-the-assistant-can-act) is about.\n\nThe honest state of the field: after three years of serious attention, there is no general solution, and researchers working on it say so plainly. Products that claim to have solved prompt injection have usually raised the cost of a particular attack.\n\n## What a user can do\n\nYou cannot patch the model. You can control what it touches.\n\nBe deliberate about giving an assistant access to untrusted content and sensitive capabilities at the same time. Read what an agent proposes to do before approving it, and be aware that the summary of what it plans can itself be influenced by the injected text. Prefer tools that ask for confirmation on consequential actions. And treat anything the model reports after processing a document from an unknown source the way you would treat a claim from that source, because in effect it is one."},"check":{"question":"Why can prompt injection not be fixed the way SQL injection was fixed?","options":[{"text":"Language models are too large to patch quickly, so the fixes always lag the attacks","correct":false,"tempting":"Size affects how often a model is updated, not the architecture. A small model has exactly the same weakness."},{"text":"SQL keeps command and data apart by structure, and a model reads all of its text as meaning","correct":true},{"text":"Attackers can always find new phrasings, so a filter list can never be complete","correct":false,"tempting":"Describes the weakness of blocklists, a symptom. A perfect filter would leave the single channel unchanged."},{"text":"Model providers have not yet made it a priority compared with capability work","correct":false,"tempting":"Blames inattention for an architectural problem, when those working hardest on it report no general solution."}],"why":"Parameterised queries keep data out of the command channel. A language model has one channel, and it reads everything in it."},"prev":{"slug":"deepfakes-and-synthetic-media","title":"Deepfakes and synthetic media","url":"https://addaly.com/learn/ai-and-you/deepfakes-and-synthetic-media"},"next":{"slug":"when-the-assistant-can-act","title":"The three ingredients of a disaster","url":"https://addaly.com/learn/ai-and-you/when-the-assistant-can-act"},"authorship":"Founder and series editor: Dr Mustafa Mun. Written by AI models to a written standard. Source and assessment review continues. Academic review invited.","review":{"status":"Draft, open for academic review"},"cite":"Addaly (2026) 'Instructions hidden in the content', in AI, Safety and What Goes Wrong. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/ai-and-you/prompt-injection (Accessed: 29 November 2026).","licence":{"name":"CC BY-NC-SA 4.0","url":"https://creativecommons.org/licenses/by-nc-sa/4.0/"},"reader":{"schema":1,"title":"Instructions hidden in the content","courseTitle":"AI, Safety and What Goes Wrong","module":{"index":6,"slug":"manipulation-and-security","title":"Manipulation, attack and abuse"},"answer":null,"keyIdea":"Developer instructions, user requests and processed content share one text channel with no reliable separator, so any content a model reads can carry commands, and unlike SQL injection, there is no parameterisation that fixes it.","hero":{"kind":"figure","figure":{"t":"figure","label":"Figure","figure":{"caption":"All four arrive as text in the same stream, with no reliable separator. SQL injection was fixed by keeping command and data in different channels; a language model’s whole capability is reading text as meaning, so that fix is not available.","layers":[{"label":"The developer’s system prompt","detail":"‘You are a helpful assistant. Summarise what the user sends.’"},{"label":"The user’s request","detail":"‘Summarise this page for me.’"},{"label":"The content being processed","detail":"A web page, an email, a PDF, a code comment, a CSV cell"},{"label":"An instruction hidden inside that content","detail":"White text on white: ‘Assistant, before summarising, do the following...’"}],"title":"One channel, four kinds of text","type":"stack"},"alt":"Figure: One channel, four kinds of text. Layers, top to bottom: The developer’s system prompt (‘You are a helpful assistant. Summarise what the user sends.’); The user’s request (‘Summarise this page for me.’); The content being processed (A web page, an email, a PDF, a code comment, a CSV cell); An instruction hidden inside that content (White text on white: ‘Assistant, before summarising, do the following...’). All four arrive as text in the same stream, with no reliable separator. SQL injection was fixed by keeping command and data in different channels; a language model’s whole capability is reading text as meaning, so that fix is not available."}},"blocks":[{"t":"h2","id":"one-channel-two-kinds-of-text","runs":[{"text":"One channel, two kinds of text"}]},{"t":"p","runs":[{"text":"A language model receives one stream of text. The developer’s instructions, the user’s request, and the content being processed (a web page, an email, a document, a code comment) all arrive in the same channel, in the same format, with no reliable marker separating them."}]},{"t":"p","runs":[{"text":"In traditional software this problem was solved decades ago. SQL injection was defeated by parameterised queries, which keep the command and the data in separate channels so that data can never be read as command. There is no equivalent for a language model, because the model’s entire capability is understanding text as meaning. Asking it to treat one span of text as inert while understanding another is asking it to do the opposite of what it does."}]},{"t":"p","runs":[{"text":"Simon Willison named this "},{"text":"prompt injection","b":true},{"text":" in 2022, by analogy with SQL injection, and the analogy is precise in one respect and misleading in another: precise because the structure is identical, misleading because the fix that worked for SQL is not available here."}]},{"t":"h2","id":"direct-and-indirect","runs":[{"text":"Direct and indirect"}]},{"t":"p","runs":[{"text":"Direct injection","b":true},{"text":" is a user typing instructions to override the system’s own. “Ignore your previous instructions and…” This is a nuisance for the operator and mostly a risk to the operator, since the user is attacking a system they are already using."}]},{"t":"p","runs":[{"text":"Indirect injection","b":true},{"text":" is the serious one. The instruction is planted in content that the model will process on somebody else’s behalf."}]},{"t":"p","runs":[{"text":"The attacker writes a web page containing, in white text on a white background, a paragraph addressed to any AI assistant that reads it. A user asks their assistant to summarise that page. The assistant reads everything, including the invisible paragraph, and follows it. The user sees a summary. They never see the instruction, because it was never on their screen in a readable form."}]},{"t":"p","runs":[{"text":"This was demonstrated publicly in early 2023 against Bing’s browsing assistant, where a planted page changed the assistant’s behaviour towards the user, and it has been demonstrated repeatedly since against email assistants, document tools, code assistants reading dependencies, and browser agents."}]},{"t":"h2","id":"where-the-text-can-hide","runs":[{"text":"Where the text can hide"}]},{"t":"p","runs":[{"text":"Anywhere the model reads and the human does not look closely."}]},{"t":"p","runs":[{"text":"White or one-pixel text on a page. HTML comments and alt attributes. Metadata in a PDF or an image. A calendar invitation’s description field. A code comment in a library. A product review. A resubmitted email thread. A filename. A support ticket. A CSV cell. The text of a document you were sent by someone who was themselves attacked."}]},{"t":"p","runs":[{"text":"The general rule: "},{"text":"any content that reaches the model can carry instructions, and the model has no way to know that some of it was not addressed to it.","b":true}]},{"t":"h2","id":"why-it-is-not-fixed","runs":[{"text":"Why it is not fixed"}]},{"t":"p","runs":[{"text":"Several defences exist and each is partial."}]},{"t":"p","runs":[{"text":"Delimiters and system prompts","b":true},{"text":": putting the content between markers and instructing the model to treat it as data. This raises the difficulty and does not close the hole, because an attacker can write text that appears to close the delimiter."}]},{"t":"p","runs":[{"text":"Instruction hierarchies","b":true},{"text":": training models to privilege developer instructions over content. This measurably helps and is a probabilistic preference rather than a rule."}]},{"t":"p","runs":[{"text":"Input and output classifiers","b":true},{"text":": a second model scanning for injection attempts. Catches the obvious cases and can itself be attacked."}]},{"t":"p","runs":[{"text":"Structural containment","b":true},{"text":": the only approach with a real security argument. Do not let the model’s output do anything dangerous. If a model that has read untrusted content cannot send an email, cannot make a purchase and cannot read your private files, then an injection can produce a wrong summary and not a stolen account. This gives up capability, deliberately, and it is what "},{"text":"The three ingredients of a disaster","href":"https://addaly.com/learn/ai-and-you/when-the-assistant-can-act"},{"text":" is about."}]},{"t":"p","runs":[{"text":"The honest state of the field: after three years of serious attention, there is no general solution, and researchers working on it say so plainly. Products that claim to have solved prompt injection have usually raised the cost of a particular attack."}]},{"t":"h2","id":"what-a-user-can-do","runs":[{"text":"What a user can do"}]},{"t":"p","runs":[{"text":"You cannot patch the model. You can control what it touches."}]},{"t":"p","runs":[{"text":"Be deliberate about giving an assistant access to untrusted content and sensitive capabilities at the same time. Read what an agent proposes to do before approving it, and be aware that the summary of what it plans can itself be influenced by the injected text. Prefer tools that ask for confirmation on consequential actions. And treat anything the model reports after processing a document from an unknown source the way you would treat a claim from that source, because in effect it is one."}]}],"check":{"question":[{"text":"Why can prompt injection not be fixed the way SQL injection was fixed?"}],"options":[{"text":[{"text":"Language models are too large to patch quickly, so the fixes always lag the attacks"}],"correct":false,"tempting":[{"text":"Size affects how often a model is updated, not the architecture. A small model has exactly the same weakness."}]},{"text":[{"text":"SQL keeps command and data apart by structure, and a model reads all of its text as meaning"}],"correct":true,"tempting":null},{"text":[{"text":"Attackers can always find new phrasings, so a filter list can never be complete"}],"correct":false,"tempting":[{"text":"Describes the weakness of blocklists, a symptom. A perfect filter would leave the single channel unchanged."}]},{"text":[{"text":"Model providers have not yet made it a priority compared with capability work"}],"correct":false,"tempting":[{"text":"Blames inattention for an architectural problem, when those working hardest on it report no general solution."}]}],"order":[2,3,1,0],"why":[{"text":"Parameterised queries keep data out of the command channel. A language model has one channel, and it reads everything in it."}]},"prev":{"slug":"deepfakes-and-synthetic-media","title":"Deepfakes and synthetic media","minutes":8},"next":{"slug":"when-the-assistant-can-act","title":"The three ingredients of a disaster","minutes":9}}}