Prompt Injection and Safe Frontends
Defending an AI feature: untrusted text, prompt injection, unsafe output, data leaks through images and links, least privilege, refusals and privacy.
An AI feature reads text from many places: the user, documents they paste, web pages, database rows, other tools. The model cannot tell which of that text is an instruction from you and which is only data. Anyone who can put words in front of the model can try to give it orders. This phase is about building screens and routes that stay safe when that happens.
Everything here is defensive. For each threat you learn what it is, how to detect it, how to defend against it and how to verify the defence works. The attacks in the examples use harmless stand-ins (a document that says to reply with the word BANANA, an image pointing at a made-up attacker.example address). The scripted model plays a hostile or gullible model, and your code handles it safely: the lesson is always the defence.
You will treat model output like user input, decide which links and images may appear, give each tool only the power one user needs, show a refusal respectfully, and keep personal data out of places it does not belong. The phase ends by hardening Mitra and checking it against a short list you can run yourself.
Practise this phase
Hands-on exercises: write the code, see your page live, and press Check to have it tested automatically.