Vibe Coder · Unit 13: Testing and Security · Lesson 8 of 11
Prompt injection
Text your AI feature reads can contain instructions from someone else. How the attack works and how to limit what it can do.
Read the short notes and pictures.Do everything inside a blue frame.
Instructions hidden in data
Prompt injection is when text that your feature processes, such as a message, a web page or a document, includes instructions meant to hijack the model. There is no prompt that fully prevents it. The defence is to control what the model is able to reach and do.

Defences that work
Least access
The model’s tools run as the signed-in user, under your database rules.
Separate data from instructions
Mark user content clearly as content to analyse.
Confirm actions
A person approves anything that sends, deletes or pays.
Check the output
Validate structure, and never run model output as code or queries.

Test it
Write five attacks
Add them to your AI test set.
Run them
Did it leak, obey or act?
Tighten access
Not just the prompt.
Attack your AI feature
Add five injection attempts to your AI test set and run them. Confirm the feature can only reach the signed-in user’s data and that any action needs confirmation.
Done when
Re-run these whenever the feature gains a new tool.
Keep these
- Text your feature reads may contain instructions.
- No prompt fully prevents it.
- Limit access and confirm actions.