Workload Identity with AWS & IMDSv2 use expired token #1755
Labels
priority: p2
Moderately-important priority. Fix may not be included in next release.
type: bug
Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Thanks for stopping by to let us know something could be better!
PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.
Environment details
google-auth-library
version: 9.4.0Steps to reproduce
imdsv2_session_token_url
.The error object we receive is:
I think this is because in
google-auth-library-nodejs/src/auth/awsclient.ts
Lines 151 to 161 in 3b19e9c
this.awsRequestSigner
is null, then is reused for all subsequent requests.However in
getImdsV2SessionToken
thex-aws-ec2-metadata-token-ttl-seconds
is only configured to be 300s:google-auth-library-nodejs/src/auth/awsclient.ts
Line 242 in 3b19e9c
so after the application run for some times the GCP token expires and refreshing of the token fails because it use expired IMDSv2 token.
Semi-related but I checked how the Go SDK has implemented and it seems to be 1:1 match to this behavior and may also have similar problem https://cs.opensource.google/go/x/oauth2/+/refs/tags/v0.17.0:google/internal/externalaccount/aws.go;l=304
The text was updated successfully, but these errors were encountered: