Course menuDVA-C03

Exams / DVA-C03 / Study guide / Guardrails and securing AI agents

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.

Last verified against current AWS documentation ·How we write our questions

What to know for the exam

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.

Try the 2 practice questions

Question 1

Harder · choose 2 ·Link to this question (question 1)

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.

  1. A. Add a system prompt to the chatbot that tells the model to decline investment questions and to avoid hateful or violent language.
  2. B. Create an Amazon Bedrock guardrail with a denied topic for investment advice, and content filters for hate and violence.
  3. C. Add a Lambda function in front of the chatbot that rejects any message that contains a word from a banned-word list.
  4. D. Pass the guardrail identifier and version in the guardrailConfig field of each Converse call that the chatbot makes.
  5. E. 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.
  • B. Right: Correct. A guardrail can define a denied topic and content filters, and it evaluates both the user input and the model completion. Because it is a separate resource, the same guardrail works after the chatbot switches models. Learn more: Detect and filter harmful content by using Amazon Bedrock Guardrails (opens in a new tab)
  • 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.
  • D. Right: Correct. The guardrailConfig field applies a Bedrock guardrail to the request, and by default it covers all messages in it. This attaches the same rules to every chat turn, whichever model the call uses. Learn more: Carry out a conversation with the Converse API (opens in a new tab)
  • 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.

Study

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.

  1. A. 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.
  2. B. 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.
  3. C. 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.
  4. D. 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.
  • B. Right: Correct. ApplyGuardrail evaluates text with a guardrail without invoking a foundation model, so the same rules can screen input and output around any model. The team keeps its own model on EC2. Learn more: Detect and filter harmful content by using Amazon Bedrock Guardrails (opens in a new tab)
  • 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.

Study

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

Study Guardrails and securing AI agents

More Security topics