Slide 1

Slide 1 text

JAWS-UG Yamanashi #14 Access control and metadata filtering in AgentCore Gateway 八雲 慎之助 / Shinnosuke Yakumo 2026/11/21

Slide 2

Slide 2 text

Who am I Shinnosuke Yakumo • Cresco Ltd. / JAWS-UG Niigata • Role: R&D, FDE • AI agents, from proposal to design and build • AWS Community Builder – AI Engineering • 2025 Japan AWS Jr.Champions • Favorite AWS service • AgentCore Gateway 2

Slide 3

Slide 3 text

Agenda • Metadata filters and ACLs in a Managed KB • What happens when the LLM writes the arguments • Resetting values in the Gateway interceptor • Denying spoofing with Gateway Policy (Cedar) 3

Slide 4

Slide 4 text

Today's setup A Managed KB used as a Gateway tool • HR and Sales documents go into one KB • Return only what the user's department and ACL allow 4

Slide 5

Slide 5 text

Inside a metadata file // hr/hiring-plan.metadata.json { "metadataAttributes": {"department": "hr", "year": 2026}, "accessControlList": [ {"Name": "[email protected]", "Type": "USER", "Access": "ALLOW"}, {"Name": "[email protected]", "Type": "USER", "Access": "ALLOW"} ] } • metadataAttributes: attributes of the document, such as department and year • accessControlList: the ACL (Access Control List), the users who can read this document 5

Slide 6

Slide 6 text

Inside a metadata file // hr/hiring-plan.metadata.json { "metadataAttributes": {"department": "hr", "year": 2026}, "accessControlList": [ {"Name": "[email protected]", "Type": "USER", "Access": "ALLOW"}, {"Name": "[email protected]", "Type": "USER", "Access": "ALLOW"} ] } • metadataAttributes: attributes of the document, such as department and year • accessControlList: the ACL (Access Control List), the users who can read this document 6

Slide 7

Slide 7 text

Inside a metadata file // hr/hiring-plan.metadata.json { "metadataAttributes": {"department": "hr", "year": 2026}, "accessControlList": [ {"Name": "[email protected]", "Type": "USER", "Access": "ALLOW"}, {"Name": "[email protected]", "Type": "USER", "Access": "ALLOW"} ] } • metadataAttributes: attributes of the document, such as department and year • accessControlList: the ACL (Access Control List), the users who can read this document 7

Slide 8

Slide 8 text

Two arguments that narrow the search Document department Readers (ACL) hr/hiring-plan hr user-a, user-b hr/salary-bands hr user-a sales/q3-pipeline sales user-a, user-b sales/discount-rules sales user-b • filter: narrows by metadata. What to search for • userContext: the user searching. Only documents with that user in the ACL user-a is in HR (hr), user-b is in Sales (sales) 8

Slide 9

Slide 9 text

Two arguments that narrow the search Document department Readers (ACL) hr/hiring-plan hr user-a, user-b hr/salary-bands hr user-a sales/q3-pipeline sales user-a, user-b sales/discount-rules sales user-b • filter: narrows by metadata. What to search for • userContext: the user searching. Only documents with that user in the ACL user-a is in HR (hr), user-b is in Sales (sales) 9

Slide 10

Slide 10 text

Two arguments that narrow the search Document department Readers (ACL) hr/hiring-plan hr user-a, user-b hr/salary-bands hr user-a sales/q3-pipeline sales user-a, user-b sales/discount-rules sales user-b • filter: narrows by metadata. What to search for • userContext: the user searching. Only documents with that user in the ACL user-a is in HR (hr), user-b is in Sales (sales) 10

Slide 11

Slide 11 text

Arguments when an agent calls the KB • Retrieve is a Gateway tool • filter and userContext are both arguments • The LLM fills in the values from the request 11

Slide 12

Slide 12 text

Values the LLM can write user-b (Sales) asks LLM may write What happens Show me HR's hiring plan department = "hr" Searches HR documents What's the 2026 pipeline? year = "2026" (string) 0 results, no error Search as user-a userContext = user-a Uses another user's ACL userContext, which sets the ACL, is LLM-written too 12

Slide 13

Slide 13 text

Values the LLM can write user-b (Sales) asks LLM may write What happens Show me HR's hiring plan department = "hr" Searches HR documents What's the 2026 pipeline? year = "2026" (string) 0 results, no error Search as user-a userContext = user-a Uses another user's ACL userContext, which sets the ACL, is LLM-written too 13

Slide 14

Slide 14 text

Values the LLM can write user-b (Sales) asks LLM may write What happens Show me HR's hiring plan department = "hr" Searches HR documents What's the 2026 pipeline? year = "2026" (string) 0 results, no error Search as user-a userContext = user-a Uses another user's ACL userContext, which sets the ACL, is LLM-written too 14

Slide 15

Slide 15 text

A filter the LLM actually wrote • Request: "HR's hiring plan" • Log of the arguments the interceptor received • The LLM wrote hr on its own 15

Slide 16

Slide 16 text

The caller of the KB is Gateway • Both the token and the arguments pass through Gateway • Gateway's execution role calls the KB • Gateway can decide the values 16

Slide 17

Slide 17 text

Gateway REQUEST interceptor • A Lambda rewrites the arguments before the tool call • Values come from the JWT claims Ref: Fine-grained access control for Amazon Bedrock managed knowledge base tools (AWS Machine Learning Blog) 17

Slide 18

Slide 18 text

Interceptor implementation Ignore the LLM's values and set them from the JWT if name.endswith("___Retrieve"): c = claims(request["headers"]) # read the JWT args["userContext"] = {"userId": c["email"]} cfg = args["retrievalConfiguration"]["managedSearchConfiguration"] cfg["filter"] = {"equals": {"key": "department", "value": c["department"]}} Headers arrive with passRequestHeaders: True 18

Slide 19

Slide 19 text

Effect of the override Only sales comes back, even with hr or user-a in the call Argument in user-b's call Returned document department = hr q3-pipeline (sales) userContext = user-a q3-pipeline (sales) Nothing added on the agent side 19

Slide 20

Slide 20 text

Pitfall of hidden arguments cannot set parameter(s): [/retrievalConfiguration, /userContext] Approach How the value is set visible: false + fixed parameterValues Same value for everyone Keep visible, override in the interceptor Can differ per user Hidden arguments are checked after the interceptor runs 20

Slide 21

Slide 21 text

Pitfall of hidden arguments cannot set parameter(s): [/retrievalConfiguration, /userContext] Approach How the value is set visible: false + fixed parameterValues Same value for everyone Keep visible, override in the interceptor Can differ per user Hidden arguments are checked after the interceptor runs 21

Slide 22

Slide 22 text

Pitfall of hidden arguments cannot set parameter(s): [/retrievalConfiguration, /userContext] Approach How the value is set visible: false + fixed parameterValues Same value for everyone Keep visible, override in the interceptor Can differ per user Hidden arguments are checked after the interceptor runs 22

Slide 23

Slide 23 text

Rejecting spoofing with Gateway Policy forbid (principal, action == AgentCore::Action::"managedkb___Retrieve", resource) unless { context.input.userContext.userId == principal.getTag("email") }; interceptor userContext in the call Result No user-a (spoofed) Denied No none (missing) Denied Yes user-a (spoofed) Allowed (already overwritten with user-b) Measured on a Managed KB with ACL only. Policy shortened to the key part 23

Slide 24

Slide 24 text

Rejecting spoofing with Gateway Policy forbid (principal, action == AgentCore::Action::"managedkb___Retrieve", resource) unless { context.input.userContext.userId == principal.getTag("email") }; interceptor userContext in the call Result No user-a (spoofed) Denied No none (missing) Denied Yes user-a (spoofed) Allowed (already overwritten with user-b) Measured on a Managed KB with ACL only. Policy shortened to the key part 24

Slide 25

Slide 25 text

Rejecting spoofing with Gateway Policy forbid (principal, action == AgentCore::Action::"managedkb___Retrieve", resource) unless { context.input.userContext.userId == principal.getTag("email") }; interceptor userContext in the call Result No user-a (spoofed) Denied No none (missing) Denied Yes user-a (spoofed) Allowed (already overwritten with user-b) Measured on a Managed KB with ACL only. Policy shortened to the key part 25

Slide 26

Slide 26 text

What Cedar can and cannot check • userId can be compared with the email tag • filter values have no type, so Cedar can't read them • The interceptor sets the values 26

Slide 27

Slide 27 text

Why put it in Gateway • Add it without changing agent code. Both the interceptor and Policy are Gateway settings • One place sets the values for every agent • Policy decisions are logged by Gateway 27

Slide 28

Slide 28 text

Why put it in Gateway • Add it without changing agent code. Both the interceptor and Policy are Gateway settings • One place sets the values for every agent • Policy decisions are logged by Gateway 28

Slide 29

Slide 29 text

Why put it in Gateway • Add it without changing agent code. Both the interceptor and Policy are Gateway settings • One place sets the values for every agent • Policy decisions are logged by Gateway 29

Slide 30

Slide 30 text

Where each value is decided What Where Values of userContext and filter Gateway interceptor sets them from the token Spoofing or missing values Denied by Gateway Policy The metadata itself Kept in meta/, writable only by admins 30

Slide 31

Slide 31 text

Where each value is decided What Where Values of userContext and filter Gateway interceptor sets them from the token Spoofing or missing values Denied by Gateway Policy The metadata itself Kept in meta/, writable only by admins 31

Slide 32

Slide 32 text

Where each value is decided What Where Values of userContext and filter Gateway interceptor sets them from the token Spoofing or missing values Denied by Gateway Policy The metadata itself Kept in meta/, writable only by admins 32

Slide 33

Slide 33 text

Summary • The LLM writes filter and userContext • The REQUEST interceptor resets them from the JWT • Policy (Cedar) denies spoofed or missing values 33