Assume it cannot be fully prevented, and design so a successful injection does little harm. Treat all untrusted text, including retrieved documents, emails and web pages, as data that may contain instructions. Give the model only the tools and permissions the current user already has, require confirmation for consequential actions, and keep secrets out of prompts. Add filtering and test with injection attempts, but never rely on filters alone.
Why interviewers ask this
Prompt injection is the defining security problem of LLM applications, and there is no reliable filter for it. The interviewer wants to hear that you know this and design for a limited blast radius instead of claiming a clever system prompt solves it. They listen for indirect injection through retrieved content, least privilege on tools, human confirmation, and output handling, since rendering model output as links or images can leak data.
How to structure your answer
- State that injection cannot be fully filtered, so you limit the damage.
- Explain direct versus indirect injection.
- Describe least privilege, confirmation and secret handling.
- Add detection, output handling and adversarial testing.
Example answer
I start from the uncomfortable fact that there is no reliable way to stop a model following instructions planted in its input, so the goal is that a successful injection cannot do much. Direct injection is a user typing ignore your instructions. The more dangerous kind is indirect: an email, web page or document the assistant reads that contains instructions the user never sees. So untrusted text is treated as data, clearly delimited in the prompt, and never as authority. The real defence is permissions. Tools run with the current user's access, so a hijacked model can only reach what that user could reach anyway. Anything consequential, like sending an email or deleting records, needs a confirmation the model cannot give itself. Output matters too, since rendering a model generated image link can send data to an attacker's server, so we only render content from approved domains. We also run classifiers for obvious attempts and keep injection cases in the test suite, knowing they reduce risk rather than remove it.
Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.
See how it worksFollow-up questions to expect
- How could an attacker use a retrieved document to extract data?
- Would a second model checking the first model's output solve this?
- How would you test your application for prompt injection?
Related ai engineer questions
Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.
Predict my questions