Skip to content

Fix STS Signature does not match non us-east-1#194

Open
bcsamrudh wants to merge 5 commits into
mainfrom
fix-sts-signature-does-not-match-non-us-east-1
Open

Fix STS Signature does not match non us-east-1#194
bcsamrudh wants to merge 5 commits into
mainfrom
fix-sts-signature-does-not-match-non-us-east-1

Conversation

@bcsamrudh

@bcsamrudh bcsamrudh commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Jira: https://hashicorp.atlassian.net/browse/VAULT-46705

Description:
Lambda function using vault-lambda-extension with AWS SDK V2 crashes when vault and lambda function are in a region other than us-east-1 and also if vault and lambda function are in different regions.

Testing Evidence:

Note : use_sts_region_from_client=false i.eVAULT_STS_ENDPOINT_REGIONis not used

Case 1 : Vault and lambda in different region :

Vault is running in ap-southeast-1 and Lambda Function is in ap-southeast-2

Creating Vault server in ap-southeast-1 and lambda function in ap-southeast-2 via terraform:
image

Result of lambda invoke:
image

This case was also tested using HCP where Vault cluster was in us-west-2 and lambda function in ap-south-1

Case 2: Both vault and lambda in same region other than us-east-1:

Both the Vault and Lambda Function are in eu-central-1

Creating Vault server and Lambda in eu-central-1 via terraform
image

Result of Lambda invoke
image

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses AWS STS SignatureDoesNotMatch failures when Vault and the Lambda function are in different regions by changing the IAM auth payload signing behavior to default to the global STS endpoint (sts.amazonaws.com) and us-east-1 signing region.

Changes:

  • Default IAM auth payload signing to the global STS endpoint and us-east-1 signing region unless a custom STS endpoint is configured.
  • Remove prior behavior that adjusted the assumed-role AWS config region based on STSEndpointRegion.
  • Add/adjust unit tests to assert the new default signing behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
internal/vault/client.go Updates IAM auth payload signing to prefer global STS endpoint/us-east-1, and adjusts endpoint/region selection logic.
internal/vault/client_test.go Adds a new test for the global endpoint default path and updates an existing assertion to expect us-east-1 signing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/vault/client.go Outdated
Comment thread internal/vault/client.go
Comment thread internal/vault/client_test.go
Comment thread internal/vault/client.go Outdated
@bcsamrudh
bcsamrudh marked this pull request as ready for review July 3, 2026 04:52
@bcsamrudh
bcsamrudh requested review from a team as code owners July 3, 2026 04:52
@bcsamrudh bcsamrudh changed the title Fix STS Signature does not match non us-east-1(cross region) Fix STS Signature does not match non us-east-1 Jul 7, 2026
Comment thread internal/vault/client.go
Comment thread internal/vault/client.go
Comment thread internal/vault/client_test.go
stuti-sr
stuti-sr previously approved these changes Jul 8, 2026

@stuti-sr stuti-sr left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Comment thread internal/vault/client.go Outdated
Comment thread internal/vault/client.go
Comment thread internal/vault/client.go Outdated
Comment thread internal/vault/client.go Outdated

@stuti-sr stuti-sr left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

provided comments. Can you please add jira story in description?

@hashicorp-cla-app

hashicorp-cla-app Bot commented Jul 15, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@bcsamrudh
bcsamrudh force-pushed the fix-sts-signature-does-not-match-non-us-east-1 branch from 563ac5d to 140a962 Compare July 15, 2026 08:51

@arjunkshashicorp arjunkshashicorp left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@stuti-sr stuti-sr left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!!

@santoshhashicorp santoshhashicorp left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Balaji2198 Balaji2198 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this. Provided few comments.

// TestToken_RegionalSTSEndpointWithoutBaseEndpoint verifies that when STSEndpointRegion
// is set without BaseEndpoint (matching production config), the regional endpoint is used
// and requests are signed for the correct region.
func TestToken_RegionalSTSEndpointWithoutBaseEndpoint(t *testing.T) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a test case to cover the behavior when opts.BaseEndpoint is set? It'd be great to verify that custom endpoints resolve and sign correctly.

Comment thread internal/vault/client.go

return u.String(), nil
signingRegion = region
if authOpts, ok := smithyauth.GetAuthOptions(&endpoint.Properties); ok {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add an unit test where GetAuthOptions returns false when endpoint.Properties is missing? This will help ensure the signingRegion fallback to opts.Region works as expected and won't break in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants