Skip to content

Choosing guardrails against malicious input to a Gen AI application

Guardrails protect GenAI applications from malicious or adversarial user inputs such as prompt injection, jailbreak attempts, and requests for harmful or off-topic content. Databricks recommends a layered approach combining system prompt design, input/output validation, and platform-level safety tools rather than relying on a single defense. Guardrails should be applied both to what enters the model (input filtering) and what leaves it (output filtering) to reduce risk end-to-end.

1 · Learn the must-know

  • A well-designed system prompt that clearly defines the assistant's role, scope, and behavioral boundaries is a first line of defense against prompt injection and off-topic misuse.
  • Input validation/guardrails should inspect and filter user queries before they reach the model to catch malicious instructions, toxic content, or attempts to override system instructions.
  • Output validation/guardrails should inspect model responses before returning them to the user to catch leaked sensitive data, toxic language, or unsafe recommendations.
  • Databricks provides safety filtering capabilities (e.g., a safety filter option on Foundation Model APIs) that can be enabled to automatically flag or block harmful content in requests and responses.
  • Guardrails cannot fully eliminate risk from adversarial inputs, so combining multiple layers (prompting, filtering, monitoring, human review) is more robust than any single technique.
  • Ongoing monitoring and logging of inputs/outputs (e.g., via Lakehouse Monitoring or MLflow tracing) helps detect novel attack patterns and supports iterative improvement of guardrails.

2 · Check your understanding

Check this objectiveFree · always available

A team builds a RAG assistant over Unity Catalog tables containing customer support tickets. During testing, malicious users paste text containing other customers' account numbers and Social Security numbers into the chat input, attempting to trick the assistant into returning matching records from the index. The team needs the endpoint to automatically detect and redact PII in both requests and responses in real time. Which Mosaic AI Gateway feature should the team configure?

Your objective map0 tried · 0 answered correctly · 56 untouched

What you have tried across Databricks GenAI Engineer's objectives, not a readiness score.

Design Applications10.71% of the exam*0 of 6 tried
Data Preparation14.29% of the exam*0 of 8 tried
Application Development23.21% of the exam*0 of 13 tried
Assembling and Deploying Applications26.79% of the exam*0 of 15 tried
Governance7.14% of the exam*0 of 4 tried
Evaluation and Monitoring17.86% of the exam*0 of 10 tried

* Our estimate. Databricks publishes no section weights.

3 · Keep going