liveBook · Manning

Prompt injection

As explained in Generative AI in Action

Jailbreaking is an attack technique that manipulates an AI model into bypassing intended instructions, safeguards, or behavioral constraints.

Prompt injection is an attack in which crafted input steers an LLM away from its intended instructions. It matters especially when a chatbot reads external content or can use plugins: an attacker may influence not just an answer, but an action. Jailbreaking is a related form of attack that tries to bypass safety features or elicit confidential or unsuitable responses. section 6.6 section 13.2.1

The entry point determines how the attack reaches the model:

  • Direct injection: a user submits a prompt intended to override system instructions or circumvent safeguards. section 6.6
  • Indirect injection: an attacker places instructions in a webpage, document, or other external content that the chatbot later reads. This is a particular concern for retrieval-augmented generation (RAG). section 13.2.1

A poisoned webpage

A user asks a chatbot to summarize a webpage. The page contains an attacker’s instruction rather than ordinary content. If the chatbot follows that instruction, the summary workflow may expose sensitive information. A connected bank plugin raises the stakes: rogue instructions on a visited site could lead to unauthorized purchases. section 6.6

The underlying problem is that an LLM may treat external data as instructions. Do not rely on the model alone to prevent injection. Give it only the access needed for its intended function, then test the deployed workflow for harmful outputs and unintended actions. section 13.2.1 section 13.3.2

Include jailbreak and injection attempts in risk-based evaluation. Record harmful results, repeat measurements after mitigations, and use red-teaming for higher-risk systems where feasible. These checks help reveal failures; they do not make the attack surface disappear. section 13.3.2 section 13.4

How Generative AI in Action covers it

How deep it goes
Defines direct and indirect attacks, explains instruction–data confusion, and outlines mitigation and evaluation without model-level internals.
Examples
Uses poisoned webpages, document summaries, and a bank-linked plugin to illustrate manipulated answers and unauthorized actions.
What it assumes
Assumes familiarity with LLM prompts and chatbot workflows while defining direct and indirect injection.
What you can do after
Evaluate/understand it by recognizing attack entry points, limiting access, and testing for harmful outputs and regressions.
How it connects
Connects prompt injection to jailbreaking, system prompts, retrieval-augmented generation, plugins, and red-teaming.

Also explained in

Compare how 9 books explain prompt injection →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Generative AI in Action. The section links point to the parts of the book it draws on.