Securing AI Services II: Guardrails, Agents, and Logs
Explore how to secure AI services by implementing Amazon Bedrock guardrails that filter inputs and outputs, controlling AI agent actions through authorization and session isolation, and protecting sensitive data in monitoring logs using masking and encryption. Understand how these controls work together to prevent unauthorized content processing and data exposure in AI applications.
Once an application sends user text to a foundation model, three new problems appear. Users can type content the application should never process, such as personal data, off-topic requests, or attempts to override the developer’s instructions. The model can return content the application should never show. And the logs that record every prompt and response become a second copy of whatever sensitive data passed through.
This lesson covers one control for each problem. Amazon Bedrock Guardrails filter what goes into and comes out of a model. Tool authorization, session isolation, and approval steps limit what an AI agent can do. Masking and access control protect the content in the logs. Access to the model itself and network privacy were covered in the previous security lesson. Here, the focus is on the content.
The diagram below shows where each control sits around a model call.
Filtering inputs and outputs with guardrails
An Amazon Bedrock guardrail is a reusable set of policies that evaluates text before it reaches the model and again before the response reaches the user. Each policy answers one of the kinds of control the exam names.
Content filters: Detect harmful content in the categories Hate, Insults, Sexual, Violence, and Misconduct. Each category has a filter strength of none, low, medium, or high, and input and output can use different strengths.
Denied topics: Block subjects the application must not discuss, defined in plain words with optional sample phrases. A banking assistant can refuse requests for investment advice even when the wording is harmless.
Sensitive information filters: Detect personally identifiable information (PII) such as names, email addresses, and card numbers, plus custom patterns defined by a regular expression. The action is either block, which rejects the whole request or response, or mask, which replaces each value with its type, for example
{EMAIL}.Prompt attack filter: A content filter category that detects jailbreaks, prompt injection (text that tells the model to ignore the developer’s instructions) and, in the Standard tier, prompt leakage (text that tries to extract the system prompt). It applies to user input.
Word filters: Block exact words or phrases, such as profanity or competitor names.
Contextual ...