Freeze AWS credentials before SigV4 signing - #1854
Open
sylvesterkaczmarek wants to merge 1 commit into
Open
Conversation
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
Freeze the AWS credential set before constructing a SigV4 signer so each request is signed from one coherent credential generation.
get_auth_headers()currently passes the object returned byboto3.Session.get_credentials()directly toSigV4Auth. That object may be refreshable. Its access key, secret key, and session token are exposed through credential properties, so using the live refreshable object during signing can allow a refresh to occur while the signer is reading the credential set.A request should be signed with one immutable access-key / secret-key / session-token tuple. Botocore's own signing path obtains a frozen credential snapshot before constructing the auth implementation.
Fix
Call
credentials.get_frozen_credentials()after resolving the session credentials and pass that snapshot toSigV4Auth.Static credentials are unaffected. Missing-credential behavior, region selection, request construction, and signed-header handling are unchanged.
Regression coverage
Adds a deterministic unit test verifying:
get_frozen_credentials()is called exactly once;SigV4Authreceives the frozen snapshot rather than the live credential proxy;The production change is confined to the hand-maintained AWS SigV4 auth helper.