fix(amazon-bedrock): do not inherit env AWS_SESSION_TOKEN with explicit keys#14262
Closed
giulio-leone wants to merge 1 commit into
Closed
fix(amazon-bedrock): do not inherit env AWS_SESSION_TOKEN with explicit keys#14262giulio-leone wants to merge 1 commit into
giulio-leone wants to merge 1 commit into
Conversation
…it keys When both accessKeyId and secretAccessKey are provided as explicit options, only use options.sessionToken — do not fall back to process.env.AWS_SESSION_TOKEN via loadOptionalSetting. On hosts with workload identity (EKS IRSA, ECS task role, Lambda) the env token belongs to a different principal, causing invalid mixed credentials and SigV4 auth failures. Fixes vercel#14136 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
4 tasks
Collaborator
aayush-kapoor
left a comment
There was a problem hiding this comment.
closing in favour of #14832
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.
Summary
Fixes #14136
When both
accessKeyIdandsecretAccessKeyare provided as explicit options tocreateAmazonBedrock, thesessionTokenis now sourced only fromoptions.sessionToken. Previously,loadOptionalSettingwould unconditionally fall back toprocess.env.AWS_SESSION_TOKEN, which on hosts with workload identity (EKS IRSA, ECS task role, Lambda) belongs to a different principal — producing mixed, invalid SigV4 credentials:Changes
packages/amazon-bedrock/src/bedrock-provider.ts— Whenoptions.accessKeyIdandoptions.secretAccessKeyare both explicitly provided, useoptions.sessionTokendirectly instead of falling through toloadOptionalSetting(which readsAWS_SESSION_TOKENfrom the environment). When keys come from the environment, env session-token fallback is preserved.packages/amazon-bedrock/src/bedrock-provider.test.ts— Three regression tests exercising the credential-resolution callback:AWS_SESSION_TOKENis not inheritedsessionToken→ works correctlyAWS_SESSION_TOKENfallback is preservedBehaviour matrix
accessKeyIdsecretAccessKeysessionTokenoptionAWS_SESSION_TOKENenvsessionToken=undefined(no mixing)sessionToken= option valuesessionToken= env value (preserved)