3.6.5. Guardrails and Access Controls for Generative and Agentic AI
💡 First Principle: Content controls belong at a layer the application developer, and the prompt, cannot skip. Access controls for agents must separate the agent's own identity from the user it acts for, and must be enforced outside the model.
Scenario: A bank requires that every model call in every account blocks hate speech, prompt attacks and customer account numbers, that individual teams cannot weaken this, and that its HR agent can read a user's calendar only with that user's consent.
Amazon Bedrock Guardrails policies: content filters (hate, insults, sexual, violence, misconduct, and prompt attack for jailbreaks and prompt injection), denied topics, word filters, sensitive information filters (PII and custom regex, block or mask), contextual grounding checks (flag answers not supported by the retrieved source, for RAG), and automated reasoning checks (validate answers against rules you define). The ApplyGuardrail API evaluates any text without calling a model, so the same guardrail can protect models hosted on SageMaker AI or elsewhere, or screen user input before retrieval.
| Enforcement level | Mechanism | Strength |
|---|---|---|
| Request | Pass guardrailIdentifier and version in Converse/InvokeModel | Depends on every developer remembering |
| IAM | Allow/deny inference on the bedrock:GuardrailIdentifier condition key | Call fails without the approved guardrail; callers can still tag input to skip input checks (output is always checked) |
| Account | Account-level enforced guardrail, configured per Region | Applies to every model invocation in the account |
| Organization | Amazon Bedrock policies in AWS Organizations reference a numbered guardrail version in the management account (shared with a resource-based policy granting bedrock:ApplyGuardrail), attached to the root, OUs or accounts, optionally including or excluding models | Central, member accounts cannot remove it |
When organization, account and request guardrails all apply, the union is enforced and the most restrictive control wins. Automated reasoning policies are not supported in enforced guardrails.
Access control for agents with AgentCore Identity.
- Inbound: a JWT authorizer validates callers against your IdP (Amazon Cognito, Okta, Microsoft Entra ID, Auth0), or callers sign with IAM SigV4.
- Outbound: credential providers store OAuth tokens, client secrets and API keys in a token vault encrypted with KMS and released only to a verified agent identity. The client credentials grant (2LO) lets the agent act as itself; the authorization code grant (3LO) gets the user's explicit consent so the agent acts on the user's behalf, scoped to that user's data.
- Tool authorization: Policy in AgentCore evaluates every tool call at the Gateway, default-deny, with conditions on the user's claims and the tool's input (for example, refunds above $500 need a manager role).
⚠️ Exam Trap: A system prompt that says "never reveal account numbers" or "only managers may issue large refunds" is not a control, because a prompt injection can override it. Content rules belong in an enforced guardrail; authorization belongs in IAM, AgentCore Identity and Policy, outside the model.