advancedSpring AI — Tool Calling, Agents & Production
What is prompt injection and how do you defend against it in Spring AI?
Prompt injection is malicious user input designed to override the system's instructions (e.g. 'ignore all previous instructions'). Defend by keeping system and user messages in separate roles rather than concatenating them into one string, sanitizing input, adding output guardrails, and requiring human-in-the-loop confirmation for sensitive tool actions.
This is a Pro question
Sign in, then upgrade to Pro or Power to unlock this question and the full Interview Prep bank.
What is prompt injection and how do you defend against it in Spring AI?