AI security: secure and test LLM apps and agents

Stage 2 · Lesson 3 of 7

Where retrieval goes wrong

How LLM apps and agents work, and where they break

Retrieval-augmented generation () splits documents into chunks, turns them into (lists of numbers that capture meaning), stores them in a and adds the closest chunks to the prompt. Three things go wrong. Permissions: if retrieval ignores who is asking, the model becomes a way to read any document in the store, including other customers' files.

Planted content: anyone who can add a document, a wiki page or a support ticket can plant instructions or false facts the app will later retrieve. Leakage through answers: whatever is retrieved can come out in the reply. The fixes are permission filters applied in the retrieval query itself, control over who can write to indexed sources, and separate stores or strict tenant filters for different customers.

Common trapfiltering after the model has already read the chunks, which is too late.

A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock

Resources for this stage

Start with· follow one of these

  • CoursePaid
    Grokking Prompt Engineering for Software Engineers

    Design Gurus · Beginner · Subscription

    How system prompts, context and structured output really work, the ground every LLM risk stands on

  • CourseFree
    Hugging Face Learn

    Hugging Face · Intermediate

    Free courses on how language models, embeddings and agents work, at an engineer's level

Practise

  • Run a small model locally as the heart of the practice app you will defend and test

  • Build your practice app's two tools as a tiny MCP server, so later stages have something real to secure

Keep handy

Also worth your time

Mark this stage as not done?