fix(bedrockagentcore): browser grantUse is missing ConnectBrowserAutomationStream - #38657
Open
badmintoncryer wants to merge 2 commits into
Open
Conversation
…mationStream `BrowserCustom.grantUse()` did not grant `bedrock-agentcore:ConnectBrowserAutomationStream`, so a grantee could start a browser session but was rejected with 403 when connecting to the automation stream over CDP. Added the action to `BROWSER_USE_PERMS` and updated the docs accordingly. Also pinned the granted actions in the unit tests, which previously only asserted that a grant had been produced.
badmintoncryer
temporarily deployed
to
automation
August 25, 2026 06:33 — with
GitHub Actions
Inactive
badmintoncryer
temporarily deployed
to
automation
August 25, 2026 06:33 — with
GitHub Actions
Inactive
badmintoncryer
temporarily deployed
to
automation
August 25, 2026 06:34 — with
GitHub Actions
Inactive
aws-cdk-automation
temporarily deployed
to
automation
August 25, 2026 07:05 — with
GitHub Actions
Inactive
aws-cdk-automation
temporarily deployed
to
automation
August 25, 2026 07:05 — with
GitHub Actions
Inactive
aws-cdk-automation
temporarily deployed
to
automation
August 25, 2026 07:33 — with
GitHub Actions
Inactive
aws-cdk-automation
temporarily deployed
to
automation
August 25, 2026 07:34 — with
GitHub Actions
Inactive
Contributor
Author
|
Thanks @lpizzinidev ! |
aws-cdk-automation
temporarily deployed
to
automation
August 25, 2026 09:31 — with
GitHub Actions
Inactive
aws-cdk-automation
temporarily deployed
to
automation
August 25, 2026 09:31 — with
GitHub Actions
Inactive
aws-cdk-automation
temporarily deployed
to
automation
August 25, 2026 09:31 — with
GitHub Actions
Inactive
badmintoncryer
temporarily deployed
to
automation
August 25, 2026 14:20 — with
GitHub Actions
Inactive
badmintoncryer
temporarily deployed
to
automation
August 25, 2026 14:21 — with
GitHub Actions
Inactive
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue # (if applicable)
Closes #38656.
Reason for this change
BrowserCustom.grantUse()does not grant enough permissions for the grantee to actually use the browser.Granting
grantUse()to an agent runtime and then driving the browser,StartBrowserSessionsucceeds, but the subsequent connection to the automation stream is rejected with403 Forbidden:This is unpleasant to debug, because the session is created successfully and reaches
READY. Only the WebSocket connection to the returned stream endpoint fails, so nothing in the logs points at IAM.The cause is that
BROWSER_USE_PERMSis missingbedrock-agentcore:ConnectBrowserAutomationStream:https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-bedrockagentcore/lib/tools/perms.ts#L61-L65
Connecting to the automation stream over the Chrome DevTools Protocol is not an optional extra — it is how you interact with a browser session at all. The devguide describes the automation endpoint as the way an agent performs browser actions, and both published IAM policies for the browser tool include the action:
AgentCoreBrowserCustom)So
grantUse()currently grants a set of permissions that cannot be used for anything.Description of changes
Added
bedrock-agentcore:ConnectBrowserAutomationStreamtoBROWSER_USE_PERMS, and updated the JSDoc onIBrowserCustom.grantUse(), the@defaultblock onBrowserCustomBase.grantUse()and the README to match. The interface doc previously mentioned anInvokeaction, which does not exist for this resource.On
ConnectBrowserLiveViewStream: I deliberately did not add it.perms.tsalready contains an unusedBROWSER_STREAM_PERMSconstant that bundles the automation stream and the live view stream together:https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-bedrockagentcore/lib/tools/perms.ts#L21-L28
It is not referenced anywhere in the repository. Wiring it into
grantUse()wholesale would also grant the live view stream, which serves a different consumer — the devguide presents the automation endpoint as the agent's interface and the live view endpoint as the way an end user watches and takes over a session. An agent does not need the latter, so including it would go against least privilege. That is possibly why the constant was never wired up: no single consumer needs exactly that set.That does leave
ConnectBrowserLiveViewStreamreachable only throughgrant(). I would be happy to follow up with a companionBrowserCustomGrantsclass (per theno-grantsawslint rule) that exposes the live view path as its own grant, but I could not find documentation specifying which actions that consumer needs — the published policies grant everything in one statement — so I did not want to guess at a public API in a stable module. Guidance welcome.Describe any new or updated permissions being added
BrowserCustom.grantUse()now additionally grantsbedrock-agentcore:ConnectBrowserAutomationStream, scoped to the browser's ARN. This action supports resource-level permissions; theAgentCoreBrowserCustompolicy linked above scopes it toarn:aws:bedrock-agentcore:<region>:<accountId>:browser-custom/<browserCustomId>. No permissions are removed, and no other grant is affected.Description of how you validated changes
Added unit tests that pin the exact action list and resource scope produced by
grantUse()andgrantRead(). The existing grant tests only assertedgrant.successandprincipalStatements.length > 0, which is why a missing action went unnoticed.Updated
integ.browser.tsto grant a role against the browser, and deployed it tous-east-1— the test passes and the snapshot matches.Originally found while building an agent on AgentCore Runtime + Browser, where the 403 above disappears once this action is granted.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license