A Bedrock knowledge base answers every caller with whatever its service role could read at ingestion time, unless you add a filter or an access list that says otherwise. Permission leakage in retrieval augmented generation (RAG) rarely comes from a broken model: it comes from an ingestion role scoped to a whole bucket, a metadata filter built from a client parameter, an ACL that never synced, or a document that should have been deleted but whose vectors were retained. This guide goes deeper than the broad Amazon Bedrock Security Guide and stays on Knowledge Bases: data source scoping, the service role, metadata filtering, document level access control on managed knowledge bases, encryption, deletion and logging. It is for cloud security engineers, AI platform owners and application teams building retrieval on Bedrock.
This is an independent guide from NHI Mgmt Group, based on AWS's public documentation as of November 2026. It is not sponsored or reviewed by AWS. Product features change, so confirm settings against AWS's current documentation.
Key takeaways
- The service role is the real read boundary. Ingestion runs as the knowledge base role, and AWS notes that CreateDataSource, UpdateDataSource and StartIngestionJob do not pass a role, so anyone who can manage data sources can ingest anything that role can read and then query it with Retrieve.
- Metadata filters are a query feature, not authorisation. They only protect data when your server builds the filter from a verified identity; a filter the client can influence is a suggestion.
- Managed knowledge base ACLs fail closed but do not authenticate. AWS describes ACL awareness as filtering, not authorisation: your application must authenticate the user and pass a verified email in userContext.userId.
- Deletion has two meanings. dataDeletionPolicy DELETE removes the embedded data when the data source or knowledge base is deleted; RETAIN keeps it, and in both cases the vector store itself survives.
- Retrieval is invisible by default. Retrieve and RetrieveAndGenerate are CloudTrail data events on AWS::Bedrock::KnowledgeBase and are not logged unless you add advanced event selectors.
Where permission leakage happens in a knowledge base
A knowledge base has three trust transitions. Source content (S3 or a connector such as SharePoint, Confluence or Google Drive) is read by the knowledge base service role. It is parsed, chunked, embedded with a Bedrock embedding model and written to a vector store (OpenSearch Serverless, OpenSearch Managed Clusters, Aurora PostgreSQL through the RDS Data API, Neptune Analytics, S3 Vectors, or a third party store such as Pinecone or Redis Enterprise Cloud reached with a Secrets Manager secret). At query time, a caller with bedrock:Retrieve or bedrock:RetrieveAndGenerate on the knowledge base gets back chunks, optionally filtered. Any source permission that is not carried across one of those transitions is lost.
| Stage | Who acts | How leakage happens | Primary control |
|---|---|---|---|
| Data source definition | Principals with bedrock:CreateDataSource or UpdateDataSource | Pointing a data source at a prefix the role can read but the audience should not see | Restrict data source management; scope the role to named buckets and prefixes |
| Ingestion | Knowledge base service role | Role reads whole buckets or every connector site, so restricted files are embedded | Resource-scoped s3:GetObject, inclusionPrefixes, connector scope |
| Metadata and ACL attach | Whoever can write .metadata.json sidecars or the global ACL file | Tampered or missing metadata reclassifies documents | Write access to sidecars limited to one pipeline role; S3 versioning |
| Vector store | Store administrators and the service role | Direct reads of the index bypass every Bedrock filter | Store-level access policy, KMS keys, network policy |
| Retrieval | Application role calling Retrieve or RetrieveAndGenerate | Filter or userContext taken from client input; one shared app role for all tenants | Server-built filters, ACL-aware retrieval, per-tenant knowledge bases |
| Generation | Model and prompt template | Injected instructions in retrieved chunks steer the answer or exfiltrate data | Guardrails, prompt templates, output handling |
OWASP lists this class of problem as LLM08:2025 Vector and Embedding Weaknesses, which covers unauthorised access and cross-context leakage in vector stores, and LLM02:2025 Sensitive Information Disclosure for what reaches the user. For general threat modelling of retrieval pipelines see the RAG Threat Modelling Guide.
Scoping the service role and data sources
AWS documents the knowledge base service role in detail. The trust policy allows bedrock.amazonaws.com to call sts:AssumeRole with two conditions: aws:SourceAccount set to your account ID and aws:SourceArn set to arn:aws:bedrock:<region>:<account>:knowledge-base/*. AWS recommends replacing the wildcard with specific knowledge base IDs after creation, which stops another knowledge base in the account from borrowing a role that reads sensitive data.
Permissions by component
| Component | Actions the role needs | Scoping advice |
|---|---|---|
| Embedding model | bedrock:InvokeModel (plus ListFoundationModels, ListCustomModels on *) | Name the embedding model ARN, not bedrock:* |
| S3 data source | s3:ListBucket, s3:GetObject | Bucket and prefix ARNs; condition aws:ResourceAccount; kms:Decrypt with kms:ViaService s3.<region>.amazonaws.com |
| SharePoint, OneDrive, Google Drive, Salesforce, Web Crawler | secretsmanager:GetSecretValue, kms:Decrypt | One secret ARN per connector; kms:ViaService secretsmanager.<region>.amazonaws.com |
| Confluence with OAuth 2.0 | secretsmanager:GetSecretValue and PutSecretValue | PutSecretValue only where refresh tokens are written back |
| OpenSearch Serverless | aoss:APIAccessAll | Collection ARN; pair with a data access policy naming only this role |
| Aurora (RDS Data API) | rds:DescribeDBClusters, rds-data:ExecuteStatement, BatchExecuteStatement | Cluster ARN; the cluster must be in the same account |
| S3 Vectors | s3vectors:PutVectors, GetVectors, DeleteVectors, QueryVectors, GetIndex | Index ARN only |
| Transient ingestion key | kms:GenerateDataKey, kms:Decrypt | Key ARN |
AWS also states that a policy used as a service role cannot be shared between multiple roles. Treat that as a design rule: one role per knowledge base, so a role's reach equals one knowledge base's audience. Connector credentials are non-human identities in their own right (Entra ID app registrations, Google service accounts, Salesforce JWT bearer apps); grant them read-only scopes on the sites in scope and store them in AWS Secrets Manager with rotation.
- inclusionPrefixes: the S3DataSourceConfiguration field limits ingestion to listed prefixes. The API reference shows a fixed number of one item, so use one data source per prefix and keep the role's s3:GetObject resource aligned with it.
- bucketOwnerAccountId: for cross-account sources, set it and condition the role on aws:ResourceAccount equal to the bucket owner; the owner's bucket policy and KMS key policy must also grant the knowledge base role.
- Custom transformation Lambda: customTransformationConfiguration runs your Lambda over documents with intermediate storage in S3. That Lambda and bucket see every document, so give them the same classification as the source.
- Parsing with a foundation model: parsingConfiguration can call a model with a parsingPrompt. Treat that prompt as code under change control, because it shapes what is stored.
Use IAM Access Analyzer to review what each role can reach and the Amazon S3 Security Guide for the source bucket baseline.
Metadata filtering done safely
Metadata filtering narrows results at query time using attributes stored with each chunk. For S3 sources each document needs a sidecar named fileName.extension.metadata.json. The filter goes in retrievalConfiguration.vectorSearchConfiguration.filter and supports these operators:
| Operator | Value types | Security use | Notes from AWS docs |
|---|---|---|---|
| equals, notEquals | string, number, boolean | Single tenant or department ID | Prefer equals on an allow value over notEquals on a deny value |
| in, notIn | string list | Set of groups or departments the user may read | Supported on managed knowledge bases |
| greaterThan, greaterThanOrEquals, lessThan, lessThanOrEquals | number | Clearance levels, expiry epochs | Useful for retention windows |
| stringContains, listContains, startsWith | string | Avoid for authorisation | Best supported on OpenSearch Serverless; startsWith and stringContains not supported on managed knowledge bases or S3 vector indexes |
| andAll, orAll | groups of expressions | Combine tenant with classification | Up to 5 filter types per group and one level of nesting |
Four rules turn filtering into a real control:
- Build the filter on the server. The AWS Architecture Blog reference design for multi-tenant RAG builds an equals or orAll filter in middleware after an authorisation decision (Amazon Verified Permissions, Cedar policies) and fails closed when no department is permitted. Never accept a filter, tenant ID or department from the request body.
- Do not use implicit filtering for access. implicitFilterConfiguration lets a model generate the filter from the user's question (AWS lists Anthropic Claude models only). That is a relevance feature: a prompt can shape it, so always AND it with a server-built access filter.
- Protect the metadata. Whoever can write the sidecar can reclassify the document. The same AWS blog design lets only the tagging Lambda write to the bucket, enables S3 versioning and CloudTrail data events, and alarms on writes to .metadata.json from unexpected principals.
- Respect reserved fields. Custom knowledge bases reserve fields prefixed x-amz-bedrock and managed knowledge bases reserve underscore-prefixed fields such as _source_uri and _data_source_id. Do not design access attributes that collide with them.
AWS's own reference design calls this filter-level (logical) isolation, not IAM-enforced isolation, and recommends a dedicated knowledge base per tenant with IAM boundaries where separate customers or organisations are involved. That is the main decision in this guide.
Document level access control on managed knowledge bases
Bedrock Managed Knowledge Base can crawl permissions alongside content (allowed users, denied users, allowed groups, denied groups) and filter results to what a named user may see. ACL awareness is turned on per data source, and retrieval passes the user in the Retrieve request as userContext.userId, the user's email as known to the data source.
| Connector | Pre-retrieval filter | Real-time ACL check | Auth type AWS lists |
|---|---|---|---|
| Amazon S3 | Yes | No: customer ACL file is the source of truth | Not applicable |
| Box | Yes | Yes | CCG |
| Confluence / Confluence Data Center | Yes | Yes (Data Center with VPC configuration) | BASIC; Data Center also PERSONAL_TOKEN |
| Custom | Yes | No: customer metadata | Not applicable |
| Google Drive | Yes | Yes | SERVICE_ACCOUNT |
| OneDrive | Yes | Yes | ENTRA_APP_ID |
| Salesforce | Yes | Yes, excluding Experience Cloud users | OAUTH2_WITH_JWT_BEARER |
| ServiceNow | Yes | Partial: scripted criteria with an installed verifier endpoint | OAUTH2 |
| SharePoint | Yes | Yes | ENTRA_ID_APP_ONLY |
| Zendesk | Yes | Yes | OAUTH2 |
AWS documents the Web Crawler connector without ACL filtering, so keep crawled public content in a separate data source or knowledge base from restricted content.
Behaviour you must design for
- Fails closed: if group resolution or real-time verification fails, affected documents are withheld. Documents with no ACL are never returned, and on S3 they are not ingested at all.
- Deny overrides allow: a user in both lists is denied.
- No userContext, no results: ACL-enabled data sources return zero results if userContext is omitted, while non-ACL data sources in the same knowledge base still return results normally. Mixing ACL and non-ACL sources in one knowledge base therefore needs a deliberate decision.
- Exact email match: there is no alias resolution or cross-IdP mapping. Mismatches fail silently, and reassigned addresses after leavers must be handled before you pass identity.
- Staleness: permissions are as current as the last successful sync. AWS notes third party identity provider credentials can be cached for up to an hour and changes typically take a few minutes to propagate, so revocation is not instant.
- S3 ACL files: set aclEnabled true in connectorParameters and either a global ACL file (globalAccessControlListS3Uri, keyPrefix entries) or per-document accessControlList entries with Name, Type USER and Access ALLOW or DENY. Per-document metadata overrides the global file, the ACL file must sit in the same bucket, and global file changes need a resync of the affected prefix.
The trust point is userContext. If any service can call Retrieve with an arbitrary email, ACL awareness protects nothing. Derive the email from a validated token on the server (for workforce users, an IAM Identity Center or IdP session; see the AWS IAM Identity Center Guide) and never from a request field.
Choosing an isolation model
| Model | Enforcement point | Fits | Trade-off |
|---|---|---|---|
| Knowledge base per tenant or audience | IAM on bedrock:Retrieve per knowledge base ARN, separate service roles and stores | External customers, regulated data, legal separation | More resources, ingestion jobs and cost to run |
| Shared knowledge base with server-built metadata filter | Your middleware plus metadata integrity | Departments within one organisation with coarse labels | One bug or tampered sidecar exposes data across groups |
| Managed knowledge base with ACL awareness | Crawled source ACLs plus real-time checks where supported | Workforce search over SharePoint, Confluence, Drive and similar | Email matching, sync lag, still needs upstream authentication |
| Layered | Per-tenant knowledge base, then ACLs or filters inside it | Multi-tenant SaaS with per-user permissions | Most engineering, strongest boundary |
Small organisations: one knowledge base per audience (for example all staff, HR, finance) with separate roles is simpler and safer than building a filter layer. Large organisations: use managed ACL awareness for connector content, per-tenant knowledge bases for customer data, and an authorisation service for filters, with IAM policies that bind each application role to named knowledge base ARNs. Agents add another path to the same data; see the Amazon Bedrock Agents Security Guide for knowledge base association.
Encryption, retention and deletion
- Customer managed keys: AWS documents keys for transient ingestion data (set on the ingestion job), the vector store where Bedrock creates it (OpenSearch Service or S3 Vectors), S3 data sources (SSE-S3 is the default), third party vector store secrets, and RetrieveAndGenerate sessions through kmsKeyArn. Fully managed knowledge bases take one key at creation; the creating identity needs kms:CreateGrant scoped by kms:ViaService bedrock.<region>.amazonaws.com and kms:GrantOperations, and Bedrock retires the grant when the knowledge base is deleted. See the AWS KMS Security Guide.
- Retrieval instructions: encryption at rest is always on with an AWS owned key by default; a customer key is set with customerEncryptionKeyArn at creation, must be symmetric, in the same Region and account, referenced by ARN, and cannot be changed later.
- dataDeletionPolicy: DELETE removes the embedded data when the data source or knowledge base resource is deleted; RETAIN keeps it. The vector store itself is not deleted in either case, and for managed knowledge bases DELETE is the only and default option. Set DELETE unless a records rule requires retention, and record that decision.
- Source deletion: a document removed from the source stays retrievable until the next successful sync. Schedule syncs to match how quickly removals must take effect, and run one on demand for takedowns.
- Orphaned stores: because deleting a knowledge base never deletes the vector store, inventory OpenSearch collections, Aurora tables and S3 vector buckets left behind and delete them explicitly.
Retrieval-time defences against poisoned content
Anyone who can write to a source can place text that a later answer will follow (ATLAS AML.T0070 RAG Poisoning, and indirect prompt injection, AML.T0051.001). Retrieval access control does not stop a legitimate author from planting instructions. Layer these controls:
- Guardrails on RetrieveAndGenerate: pass guardrailConfiguration (guardrailId, guardrailVersion) inside generationConfiguration. AWS notes contextual grounding for knowledge bases is not supported on Claude 3 Sonnet and Haiku, so check your model. See the Amazon Bedrock Guardrails Configuration Guide.
- Prompt templates: a custom textPromptTemplate must keep $search_results$ and $query$; wrap search results in clearly delimited tags and instruct the model to treat them as data. AWS notes the default prompt is visible in model invocation logs.
- Bound the blast radius: numberOfResults defaults to 5; keep it small. QUERY_DECOMPOSITION may run several queries, so test it against your filters.
- Write control on sources: treat write access to an ingested prefix or site as write access to the assistant's answers. For poisoning response steps see the RAG Knowledge Base Poisoning Response Playbook and the AML.T0070 RAG Poisoning guide.
- Secrets in sources: credentials in indexed documents become retrievable (ATLAS AML.T0082 RAG Credential Harvesting). Scan sources for secrets before first ingestion. See MITRE ATLAS AML.T0082 RAG Credential Harvesting.
Rolling out a secure knowledge base
- Classify and inventory: list each intended source, its owner, its audience and its highest data classification. Reject sources whose audience cannot be expressed as a knowledge base, filter or ACL.
- Create one role per knowledge base: trust policy with aws:SourceAccount and a specific aws:SourceArn; resource-scoped S3, store and secret permissions; restrict bedrock:CreateDataSource, UpdateDataSource and StartIngestionJob to the pipeline owners.
- Turn on logging before ingesting: APPLICATION_LOGS delivery (needs bedrock:AllowVendedLogDeliveryForResource) and CloudTrail data events for AWS::Bedrock::KnowledgeBase.
- Pilot with test identities: ingest a test corpus that includes deliberately restricted documents and canary strings, then call Retrieve as users who should and should not see them. Confirm zero results without userContext on ACL sources. The RAG Security Test Plan Template gives a test structure.
- Expand by data source: add sources one at a time, checking RESOURCE_IGNORED and failure statuses in ingestion logs after each sync.
- Roll back: if leakage is found, remove bedrock:Retrieve from the application role or disable the endpoint first, then delete or fix the data source with dataDeletionPolicy DELETE and resync, and rotate any credential found in retrieved content.
Detection and measurement
| Signal | Source | What to alert on |
|---|---|---|
| Retrieve, RetrieveAndGenerate calls | CloudTrail data events, AWS::Bedrock::KnowledgeBase (off by default, extra cost) | New calling principals, calls outside the application role, volume spikes |
| Data source changes | CloudTrail management events (CreateDataSource, UpdateDataSource, StartIngestionJob) | Any change outside the pipeline role or change window |
| Ingestion outcomes | APPLICATION_LOGS: StartIngestionJob.ResourceStatusChanged | RESOURCE_IGNORED, EMBEDDING_FAILED, INDEXING_FAILED, METADATA_UPDATE_FAILED, PARTIALLY_INDEXED |
| Metadata and ACL file writes | S3 data events on .metadata.json and the global ACL file | Writes by any principal other than the tagging pipeline |
| Prompt and response bodies | Model invocation logging | Canary strings, secrets patterns, guardrail interventions |
Log destinations for ingestion logs are CloudWatch Logs, S3 or Data Firehose. AWS states log deliveries are not supported for knowledge bases with a structured data store or a Kendra GenAI Index, so plan compensating monitoring there. Querying CloudTrail is covered in the AWS CloudTrail Guide.
Metrics that show it is working:
- Percentage of knowledge base roles with a specific aws:SourceArn and no bucket-wide s3:GetObject (target 100%).
- Percentage of knowledge bases with CloudTrail data events and ingestion log delivery active.
- Negative test pass rate: restricted canary documents never returned to unauthorised test users across releases.
- Time from source permission change or deletion to effect in retrieval (sync interval plus propagation).
- Count of documents with no ACL or failed metadata per sync, trending to zero.
- Count of orphaned vector stores with no live knowledge base.
Framework mapping
| Control area | NIST SP 800-53 Rev 5 | NIST CSF 2.0 | Threat reference |
|---|---|---|---|
| Service role scoping, data source management rights | AC-6 Least Privilege | PR.AA-05 | OWASP LLM08:2025 |
| Filters and ACL-aware retrieval | AC-3 Access Enforcement, AC-4 Information Flow Enforcement | PR.AA-05 | OWASP LLM02:2025 |
| KMS keys and deletion policy | SC-12, SC-28 | PR.DS-01 | ATLAS AML.T0082 |
| CloudTrail data events and ingestion logs | AU-2, AU-12 | PR.PS-04 | All of the above |
| Poisoning and injection monitoring | SI-4 System Monitoring | DE.CM-09 | ATLAS AML.T0070, AML.T0051.001 |
In ISO/IEC 27001:2022 Annex A the same controls sit mainly under A.5.15 Access control, A.8.3 Information access restriction, A.8.24 Use of cryptography and A.8.15 Logging.
Common failure patterns
- Bucket-wide role: the role can read the whole bucket, so a data source edit by anyone with UpdateDataSource quietly ingests HR or legal folders.
- Client-supplied filter or user: the front end sends tenantId or userContext.userId and the backend passes it through, so changing one field reads another tenant's data.
- Implicit filtering as access control: a model-generated filter is treated as a boundary and a crafted question widens it.
- RETAIN by habit: a data source is deleted after a complaint but its embedded data is retained, or the vector store is left behind after the knowledge base is gone.
- Mixed ACL and non-ACL sources: restricted connector content is ACL-aware but a sibling S3 source with no ACL returns to everyone in the same knowledge base.
- No retrieval logs: data events were never enabled, so an investigation cannot say who retrieved a leaked chunk.
Practitioner checklist
- Give every knowledge base its own service role with aws:SourceAccount and a specific aws:SourceArn in the trust policy.
- Scope s3:GetObject, store and secret permissions to named resources and match inclusionPrefixes to the role's prefix.
- Limit bedrock:CreateDataSource, UpdateDataSource and StartIngestionJob to the pipeline owners and alert on any other caller.
- Build metadata filters and userContext on the server from a verified identity; never accept them from the client.
- Use a separate knowledge base per external tenant; use filters or ACLs only inside a trust boundary.
- Restrict writes to .metadata.json sidecars and ACL files to one pipeline role, with S3 versioning on.
- Set dataDeletionPolicy to DELETE unless retention is required, and delete orphaned vector stores.
- Enable CloudTrail data events for AWS::Bedrock::KnowledgeBase and ingestion APPLICATION_LOGS before first ingestion.
- Attach a guardrail to RetrieveAndGenerate and scan sources for secrets before ingestion.
- Run negative access tests with canary documents on every release and connector change.
Standards and references
- AWS: Create a service role for Amazon Bedrock Knowledge Bases
- AWS: Access Control Lists awareness enablement
- AWS: Document-level access controls for Amazon S3 data sources
- AWS: Configure and customise queries and response generation
- AWS: Encryption of knowledge base resources
- AWS: Monitor knowledge bases using CloudWatch Logs
- AWS: CreateDataSource API reference
- AWS Architecture Blog: Secure multi-tenant RAG with Amazon Bedrock and Verified Permissions
Related NHI Mgmt Group resources: Amazon Bedrock Security Guide · RAG Threat Modelling Guide · Agent Memory Poisoning vs RAG Poisoning · AWS IAM Policies and Roles Guide