fix(kms): normalize alias targetKeyId to plain key ID on createAlias - #1648
Merged
hectorvent merged 1 commit intoJul 3, 2026
Merged
Conversation
mikelamutxastegi
marked this pull request as draft
June 30, 2026 11:09
mikelamutxastegi
marked this pull request as ready for review
June 30, 2026 11:10
hectorvent
approved these changes
Jul 3, 2026
hectorvent
left a comment
Collaborator
There was a problem hiding this comment.
Thanks @mikelamutxastegi,
Solid fix implementation
7 tasks
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
createAliasstored thetargetKeyIdparameter as-is inKmsAlias, without normalizing it to the plain key UUID. When a caller passed a full key ARN (e.g.arn:aws:kms:us-east-1:000000000000:key/<uuid>) astargetKeyId, the raw ARN was persisted. On any subsequent operation that resolved the key through that alias (e.g.DescribeKey,Encrypt,Decrypt),resolveKeyretrieved the stored ARN and used it directly as the storage lookup key (region + "::" + arn), which never matched the entry stored asregion + "::" + uuid— causing aNotFoundException.The fix captures the result of
resolveKey(which already handles ARN, alias ARN, and alias name normalization) increateAliasand storeskey.getKeyId()— the plain UUID — in the alias instead of the raw input.A regression test
resolveKeyByAliasCreatedWithArnis added toKmsServiceTestto cover this path.Closes #1647
Type of change
fix:)feat:)feat!:orfix!:)AWS Compatibility
Incorrect behavior:
CreateAliasaccepted a full key ARN asTargetKeyIdbut stored it verbatim, causing any subsequent resolution through that alias (e.g.DescribeKey,Encrypt,Decrypt) to fail withNotFoundException. The AWS SDK and CLI always pass the ARN form in some flows, so this broke real-world SDK usage.Updated behavior:
createAliasnow normalizesTargetKeyIdto the plain key UUID regardless of whether a plain ID, full ARN, or alias ARN is supplied, matching the AWS KMS behavior where aliases always resolve correctly.Checklist
./mvnw testpasses locallyresolveKeyByAliasCreatedWithArninKmsServiceTest)