Guardrails and securing AI agents: DVA-C03 study notes and practice questions
What to know about Guardrails and securing AI agents for the DVA-C03 exam, from the Security domain (26% of the exam guide), then 2 free questions to test it. Part of the DVA-C03 study guide.
These questions describe an AI feature that leaks data, answers off-topic questions, follows injected instructions, invents facts or takes risky actions. Pick the control that targets that failure.
The guardrail filters
Content filters detect harmful text or images in prompts and responses across hate, insults, sexual, violence and misconduct categories. You set the strength for each, separately for prompts and responses.
Denied topics block subjects you define with a name, a plain-language definition and optional sample phrases, such as investment advice in a bank’s bot.
Word filters block exact words or phrases, and profanity can be blocked with a built-in list.
Sensitive information filters detect PII such as names, email addresses and card numbers, and custom regex patterns. Each entity type can block the whole message or mask (anonymize) the value, with separate actions for prompts and responses, so you can block card numbers on input and mask email addresses on output. A masked value is replaced with a placeholder naming the entity type, such as {EMAIL}.
Contextual grounding checks score a response for grounding in a source and for relevance to the query. A response below the threshold is blocked. This is the check for RAG answers that invent facts.
Prompt attacks and input tags
The prompt attack filter detects jailbreaks and prompt injection in user input. It is an input-side check, and it needs you to mark which part of the prompt is user input, so trusted developer instructions are not flagged. With InvokeModel, wrap the user input in guardrail input tags; AWS recommends a random tag suffix per request so a user cannot close the tag early. Without tags, the prompt attack filter does not run. With Converse, mark the untrusted text as guardContent blocks; the unmarked parts of the message are not evaluated. Instructions hidden in documents or tool results are indirect injection, which this filter does not catch, so limit the agent’s permissions and require confirmation for risky actions.
Applying a guardrail
Attach a guardrail by ID and version to an inference call (guardrailConfig in Converse). Production should pin a numbered version, a fixed snapshot, not the editable DRAFT. When the guardrail acts, Converse returns a stop reason of guardrail_intervened and the configured blocked message; enable the trace to get the assessment and reason for audit logs. The bedrock:GuardrailIdentifier IAM condition key can make a specific guardrail mandatory on invoke and Converse calls. Use the standalone ApplyGuardrail API to check text without calling a model, for example to screen messages from another system or the input and output of a model hosted outside Bedrock. Set the source to INPUT for user content and OUTPUT for model responses. Contextual grounding needs the source text and the query passed as marked content, so the check can compare against them.
Securing agents
AgentCore Identity gets OAuth 2.0 tokens for agent tools and keeps them in a token vault, so tokens are not hard-coded. The user federation (three-legged) flow acts with the end user’s own permissions after consent; the machine-to-machine flow acts as the agent.
AgentCore Gateway exposes tools to agents through authenticated endpoints, so tool use is authorized before a call is made.
Session isolation: AgentCore Runtime gives each session its own microVM, and the microVM’s memory is sanitized when the session ends. Use a unique session ID per user or conversation. AgentCore does not map users to sessions, so your backend must track which session belongs to which user.
Human-in-the-loop: for a sensitive action such as a payment or deletion, have the agent pause and ask a person to approve before it runs.
Authorization in the tool: the tool’s code (for example the action group’s Lambda function) must check that the user may take the action, such as owning the order, using an identity set by the server, not by the model.
How to choose
Scenario wording
Answer
Hide card numbers from responses
Sensitive information filter, mask
Reject any message containing a national ID
Sensitive information filter, block
Stop the bot discussing a banned subject
Denied topics
Block a list of brand names or slurs
Word filter
Users paste “ignore your instructions” text
Prompt attack filter with input tags
Check a RAG answer is supported by documents
Contextual grounding
Agent must not run a refund without approval
Human-in-the-loop confirmation
Refund only the caller’s own orders, under a limit
Checks in the tool’s code, not the prompt
Every model call must use the approved guardrail
IAM condition on bedrock:GuardrailIdentifier
Screen text from a non-Bedrock model or another app
ApplyGuardrail
One user’s agent must not see another user’s data
Session isolation with per-user session IDs
Common traps
Expecting the prompt attack filter to check tool results or responses.
Using masking where the wording requires the request to be rejected.
Assuming an unversioned draft guardrail is what production calls use.
Treating session isolation as user authorization. The app still maps users to sessions.
Relying on a guardrail alone to stop an agent from taking a risky action.
A bank runs a public chatbot that answers questions with models on Amazon Bedrock. The chatbot must refuse to give investment advice, and it must block hateful or violent content in both user questions and model answers.
The compliance team wants these rules enforced by a managed setting, not by instructions written in the prompt. The bank expects to switch to a different Bedrock model next year, and the same rules must apply after the switch.
Which TWO actions meet these requirements? (Choose two.)
Choose two answers.
AA. Add a system prompt to the chatbot that tells the model to decline investment questions and to avoid hateful or violent language.
BB. Create an Amazon Bedrock guardrail with a denied topic for investment advice, and content filters for hate and violence.
CC. Add a Lambda function in front of the chatbot that rejects any message that contains a word from a banned-word list.
DD. Pass the guardrail identifier and version in the guardrailConfig field of each Converse call that the chatbot makes.
EE. Turn on model invocation logging, so the compliance team can review each request and response every day.
Show the answer and explanation
Answers: B, D
A. Wrong: Instructions in the prompt depend on the model following them, so they are not an enforced setting. The compliance team has ruled out relying on prompt wording.
C. Wrong: A word list catches exact words, but a question about which stocks to buy contains none of them, so the topic rule is missed. The list also adds code that the team must keep in step with the rules.
E. Wrong: Logging records requests and responses for review, but it does not refuse or block anything. It is an audit tool, not a filter for the chatbot.
Explanation
A Bedrock guardrail holds the denied topic and content filters as a managed resource. Passing it in guardrailConfig on the Converse call applies those rules to the input and the output, regardless of which Bedrock model answers. Prompt wording, word lists and logging do not block content by themselves.
A health-tech startup runs its own chat model on Amazon EC2 instances, not on Amazon Bedrock, because the model was trained in-house. The application must refuse medical-advice topics, and personal identifiers must not reach the model or the user's screen.
The team already has an Amazon Bedrock guardrail that defines these rules. It wants to reuse that guardrail without moving the model to Amazon Bedrock.
Which design meets these requirements?
Choose one answer.
AA. Send each request to the in-house model through the Converse API with the guardrail in guardrailConfig, so Bedrock checks the call before it reaches the EC2 model.
BB. Call the ApplyGuardrail API on the user's message before it goes to the in-house model, and call it again on the model's reply before the reply is shown.
CC. Keep the rules in the system prompt of the in-house model, and check each reply in the web app against a list of banned keywords.
DD. Copy the guardrail's word list into a DynamoDB table, and have the web tier scan each message and reply for matches before it is sent.
Show the answer and explanation
Answer: B
A. Wrong: The Converse API works with Amazon Bedrock models, so it cannot send a request to a model hosted on EC2. The guardrail would never run against the in-house model.
C. Wrong: Prompt rules depend on the model following them, and a keyword list does not catch a medical-advice topic. The design does not enforce the guardrail's rules.
D. Wrong: A word list covers only the words, so it misses the denied topic and the personal-data rules. The team would also maintain a copy of the rules by hand.
Explanation
The ApplyGuardrail API evaluates text against a guardrail without calling a Bedrock model, so the same rules can screen the input and the output of a model hosted elsewhere. The Converse API only works with Bedrock models. Prompt wording and copied word lists do not enforce the topic and personal-data rules.
Want more on Guardrails and securing AI agents? The 5 full-length practice sets have 14 more Guardrails and securing AI agents questions, 390 in all, none of them in the free exam. One payment of $14.99, no subscription. See the practice sets →