fix(awsutil): only set AssumeRole ExternalID when provided#186
Open
nomeelnoj wants to merge 1 commit into
Open
fix(awsutil): only set AssumeRole ExternalID when provided#186nomeelnoj wants to merge 1 commit into
nomeelnoj wants to merge 1 commit into
Conversation
The non-web-identity AssumeRole path set options.ExternalID unconditionally
via aws.String(c.RoleExternalId). When no external ID was configured this
produced a non-nil pointer to an empty string, which the SDK serializes as
ExternalId="" on the STS AssumeRole call. STS then rejects the request with
a ValidationError ("Member must have length greater than or equal to 2"),
breaking role assumption for any caller that does not use an external ID.
Guard the assignment so ExternalID is only set when a non-empty value is
provided, matching the existing empty-value handling for this field. Adds a
regression test covering AssumeRole without an external ID.
Signed-off-by: nomeelnoj <4316746+nomeelnoj@users.noreply.github.com>
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
The non-web-identity AssumeRole path in
awsutil/generate_credentials.gosetoptions.ExternalIDunconditionally:When no external ID is configured,
aws.String("")is a non-nil pointer to an empty string, which the SDK serializes asExternalId=""on thests:AssumeRolecall. STS rejects it with:This breaks role assumption for any caller that does not use an external ID.
Fix
Only assign
ExternalIDwhen a non-empty value was provided. This matches the existing empty-value handling forRoleExternalIdelsewhere in the file (line 149) and leavesAssumeRoleOptions.ExternalIDasnilwhen unset, so noExternalIdparameter is sent to STS.Only the plain (non-web-identity) AssumeRole path is affected; the web-identity branches never set
ExternalID.Fixes: #185
Context
Surfaced downstream in
terraform-provider-vault(hashicorp/terraform-provider-vault#2922, fix in hashicorp/terraform-provider-vault#2923). The provider change stops routing non-web-identity assumption throughWithRoleArn, which incidentally avoids this code path; this PR fixes the underlying library defect so other consumers are protected.Notes for maintainers
awsutilmodule has noCHANGELOGfile, so no changelog entry was added. Happy to add one if you keep release notes elsewhere.CONTRIBUTING, flagging that this touches credential/AssumeRole behavior used across multiple products; reviewers from affected teams welcome. The change is intentionally minimal and behavior-preserving when an external ID is provided.PCI review checklist
If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.
If applicable, I've worked with GRC to document the impact of any changes to security controls.
Examples of changes to controls include access controls, encryption, logging, etc.
If applicable, I've worked with GRC to ensure compliance due to a significant change to the in-scope PCI environment.
Examples include changes to operating systems, ports, protocols, services, cryptography-related components, PII processing code, etc.