Protecting generative AI applications
SCS-C03 · Lesson 11 of 22 · 1:31:11
YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗
Learning with these videos? Subscribe for new courses and exam-style questions.
Subscribe on YouTube (opens in a new tab)In this lesson
Prepare for the SCS-C03 exam (AWS Certified Security – Specialty). In this lesson: the OWASP Top 10 for LLM applications, Amazon Bedrock Guardrails (content filters, denied topics, word filters, sensitive information filters, contextual grounding checks), the prompt attack filter and input tags, and enforcing guardrails with IAM conditions and Bedrock policies while limiting what agents can do. Includes three original practice questions.
Study notes
The text of this lesson, to read at your own pace. Information as of November 2026.
A model follows instructions
AnyCompany Health is launching a patient assistant on Amazon Bedrock that answers questions about appointments and coverage from a knowledge base. A language model follows the instructions that it reads, and some of those instructions can come from an attacker. This lesson covers the OWASP Top 10 for LLM applications and the AWS controls that answer it.
The OWASP Top 10 for LLM applications
The OWASP Top 10 for LLM Applications, in its 2025 version, lists the biggest risks of applications built on large language models. The first five are prompt injection, sensitive information disclosure, supply chain, data and model poisoning, and improper output handling. The next five are excessive agency, system prompt leakage, vector and embedding weaknesses, misinformation, and unbounded consumption. On AWS, the controls fall into three groups: guardrails filter what goes in and out of the model, IAM limits what the application and its agents can do, and your own code validates every response before using it.
Amazon Bedrock Guardrails
Amazon Bedrock Guardrails evaluates both the user input and the model response against the policies that you configure. Content filters detect categories such as hate, violence, misconduct, and prompt attacks, each with a strength that you set, and denied topics block whole subjects, for example a diagnosis from the patient assistant. Sensitive information filters block or mask personal data such as names and phone numbers, and a custom regular expression can catch a patient ID. Contextual grounding checks flag a response that is not grounded in the retrieved source, or that does not answer the question, which helps against hallucinations in a RAG application. You create a version of the guardrail and pass its ID and version in the inference call, or you call the ApplyGuardrail API to check text without invoking a model.
Prompt attacks
In a direct prompt injection, the user tells the model to ignore its instructions, a jailbreak tries to get around its safety training, and prompt leakage tries to reveal the system prompt. The prompt attack filter of a guardrail detects jailbreaks and injections, and on the Standard tier, prompt leakage too. With InvokeModel, it only evaluates the user input that you wrap in guardrail input tags, so without tags, prompt attacks are not filtered, and with the Converse API, you mark the parts to evaluate in the content blocks. An indirect prompt injection hides instructions in content that the model reads, such as a document in the knowledge base, a web page, or a tool result, and the prompt attack filter does not evaluate tool results. So treat retrieved content as untrusted, and keep the permissions of the application small, because a model that is tricked can only do what its role allows.
Enforcing guardrails and limiting agency
A guardrail protects only the calls that use it, so enforce it: an IAM condition key on the guardrail identifier denies any inference request that does not include the required guardrail. At a larger scale, an Amazon Bedrock policy in AWS Organizations applies a guardrail to every model invocation in the chosen accounts or organizational units, and when an application also passes its own guardrail, the stricter control wins. Against excessive agency, give each agent action only the permissions that it needs, and require user confirmation before an action such as canceling an appointment. Against improper output handling, treat every model response as untrusted input: validate it and encode it before it reaches a browser, a database, or a shell. Finally, model invocation logging sends prompts and responses to CloudWatch Logs or S3 for investigations, and an interface VPC endpoint keeps the traffic to Bedrock private.
Recap
Let's recap. The OWASP Top 10 for LLM applications starts with prompt injection and covers ten risks. Guardrails filter content, topics, words, and sensitive information, and they check grounding. The prompt attack filter needs input tags with InvokeModel, and it does not evaluate tool results. And IAM conditions, Bedrock policies, least privilege, and user confirmation keep the guardrails on and the agents limited.
Quick checks for this lesson
The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.
The patient assistant must keep answering, but every patient ID and phone number in its responses must be replaced with a placeholder, and patient IDs follow a format specific to AnyCompany Health. What should the security engineer configure in the guardrail?
- A denied topic about patient identifiers
- A word filter listing every phone number
- Sensitive information filter: mask + regex
- A contextual grounding check on responses
Show the answer
Sensitive information filter: mask + regex
A sensitive information filter with the mask action replaces the values with a placeholder, and a custom regular expression catches the format of patient IDs. “A denied topic about patient identifiers” would block whole answers instead of masking a value. “A word filter listing every phone number” would match only exact words, and phone numbers change with each patient. And “A contextual grounding check on responses” is for responses that are not grounded in the source.
The developers call InvokeModel with a guardrail whose prompt attack filter is set to high. Their prompt holds the system instructions and the user's message, yet injection tests in the user's message are not filtered. What should they change?
- Wrap the user's message in input tags
- Add a denied topic named prompt injection
- Put the system prompt in a word filter
- Turn on model invocation logging
Show the answer
Wrap the user's message in input tags
With InvokeModel, the prompt attack filter only evaluates the user input inside guardrail input tags, and without tags, prompt attacks are not filtered. “Add a denied topic named prompt injection” would block a subject, without fixing the missing tags. “Put the system prompt in a word filter” would block words, and the system prompt is not the attack. And “Turn on model invocation logging” would keep a log of each request, without filtering anything.
The security team must apply the central guardrail to every Amazon Bedrock model invocation in all member accounts of the organization, even when a developer forgets to reference it. What should they use?
- A word filter in each application's guardrail
- Model invocation logging in every account
- An AWS Config rule that checks each guardrail
- An Amazon Bedrock policy in AWS Organizations
Show the answer
An Amazon Bedrock policy in AWS Organizations
An Amazon Bedrock policy in AWS Organizations applies the guardrail to the model invocations of the member accounts, with no change to the applications. “A word filter in each application's guardrail” would depend on each application. “Model invocation logging in every account” would keep a log of the calls, without protecting them. And “An AWS Config rule that checks each guardrail” would report a problem after the fact, without applying anything.