Repository navigation
fix: strip -fips suffix from AWS service name in SigV4 signer - #3280
macastelaz wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds support for AWS FIPS endpoints by stripping the "-fips" suffix from the host's first segment when determining the service name, and includes corresponding unit tests. The review feedback suggests replacing the magic number 5 with a local constant for the "-fips" suffix to improve code maintainability and readability.
|
We now have ProgrammaticExternalAccountCredential that you can use for any sts exchange that deviates from what we currently support. I know that's not ideal but that's what we can offer at the moment. I'll raise the issue of regional AWS endpoints internally in case we want to support that out of the box. But for now I'll be closing this PR. |
|
Reopening in draft while we discuss internally. |
|
Thanks @amanda-tarafa! Just adding a note here to clarify the framing for future readers on the thread:
I also pushed a quick commit addressing the |
Description
AwsExternalAccountCredentialalready supports regional AWS STS endpoints out of the box by substituting the{region}placeholder inRegionalCredentialVerificationUrl(for example,https://sts.{region}.amazonaws.com?Action=GetCallerIdentity&Version=2011-06-15, which is the default verification URL generated for AWS Workload Identity Federation configurations).However, when a customer in a FIPS-compliant AWS environment configures the corresponding AWS STS FIPS endpoint (
https://sts-fips.{region}.amazonaws.com?Action=GetCallerIdentity&Version=2011-06-15),AwsSignedSubjectToken.Createpreviously derived the SigV4serviceNamedirectly from the first hostname label (host.Split('.')[0]) assts-fips.Per AWS SigV4 specification, the signing key derivation (
keyService) andX-Amz-Credentialcredential scope (<date>/<region>/sts/aws4_request) must always use the canonical AWS service namests, even when the requestHostheader and target URL use thests-fips.<region>.amazonaws.comhostname. Scoping the signature tosts-fipscauses AWS STS to reject the signedGetCallerIdentitytoken exchange with:This PR is part of a coordinated cross-language bugfix across all Google Auth libraries (Python #18920, Node.js #9779, Java #14867, Go
cloud.google.com/go/auth#20805, Gogolang/oauth2#815, gRPC C++ #43804, and Ruby #608) to ensureAwsExternalAccountCredentialstrips the trailing-fipssuffix when computing the SigV4 service name.Fix
-fipssuffix from the first hostname segment inAwsExternalAccountCredential.AwsSignedSubjectToken.cswhen computingserviceName(while preserving the fullsts-fips.<region>.amazonaws.comhostname in thehostheader and request URL).AwsSignedSubjectTokenTests.Create_FipsinAwsSignedSubjectTokenTests.csverifying that a FIPS STS endpoint produces anAuthorizationheader and signature scoped tosts.Manual Testing
Verified end-to-end against live GCP STS (
https://sts.googleapis.com/v1/token) forwarding to live AWS STS (https://sts-fips.us-east-2.amazonaws.com):sts-fips): Rejected by AWS STS withSignatureDoesNotMatch: Credential should be scoped to correct service: 'sts'.sts): Passed AWS STS service-scope validation and proceeded to token validation (InvalidClientTokenId).