Repository navigation
fix(kms-keyring): validate content algorithm matches selected suite on decrypt - #527
Merged
Merged
Conversation
…crypt The KMS+Context and RSA-OAEP decrypt paths selected the content algorithm suite from the object's content metadata without checking it against the algorithm this data key was bound to. A mismatch (for example a GCM-sealed object whose content-algorithm metadata reads CBC) was accepted, so the object could be processed under a different suite than it was written with. KmsKeyring now rejects a stored aws:x-amz-cek-alg that does not match the selected suite before calling KMS Decrypt. RsaKeyring now accepts only GCM-family selected suites for the RSA-OAEP pseudo-data-key binding. Both preserve the GCM->CTR equivalence used by ranged gets.
RSA-OAEP data keys record AES/GCM/NoPadding for every non-committing suite, including CBC objects rewrapped by reEncryptInstructionFile, so the wrapped value cannot identify the content algorithm. Revert the RsaKeyring check and its tests; keep the KMS+Context check, where the stored aws:x-amz-cek-alg records the actual content algorithm.
kessplas
marked this pull request as ready for review
October 26, 2026 22:53
akareddy04
reviewed
Oct 27, 2026
Contributor
|
Fix looks right for |
Move the Kms+Context content algorithm check into KmsContentAlgorithm and call it from both KmsKeyring and KmsDiscoveryKeyring. Include the stored content algorithm and the selected suite in the error message.
Contributor
|
LGTM |
aws-crypto-tools-ci-bot
pushed a commit
that referenced
this pull request
Nov 4, 2026
## [4.0.4](v4.0.3...v4.0.4) (2026-11-04) ### Fixes * **kms-keyring:** validate content algorithm matches selected suite on decrypt ([#527](#527)) ([96b1c2d](96b1c2d))
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.
Issue #, if available: n/a
Description of changes:
The KMS+Context and RSA-OAEP decrypt paths selected the content algorithm suite from the object's content metadata without checking it against the algorithm this data key was bound to.
KmsKeyring now rejects a stored aws:x-amz-cek-alg that does not match the selected suite before calling KMS Decrypt. RsaKeyring now accepts only GCM-family selected suites for the RSA-OAEP pseudo-data-key binding. Both preserve the GCM->CTR equivalence used by ranged gets.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Check any applicable: