-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v4.0.0 KMS Keyrings SHOULD explicitly error if non-ARN OnDecrypt #1234
Comments
Howdy @benkehoe , This ciphertext CAN be decrypted; At Encryption, The full Key ID is persisted as part of the Encrypted Data Key; (The AWS SDK and KMS, if called without a region or account ID, use the principal of the caller to fill in those fields; but the serialized Encrypted Data Key MUST be deterministic, as compared to determined by the caller's context.) To decrypt this cipher-text, I have attached a code example that follows your instructions, This demonstrates that the cipher-text is decryptable. However, you make an excellent suggestion; At Decrypt, if the (Note: I had to name the file a |
I'm still confused, though. Using key IDs for both encrypt and decrypt used to work with the Encryption SDK. Is there a good reason it shouldn't work now? The encryption process forms up a full ARN from the key ID (for the reasons you detail). Why can't the decryption process also form an ARN from the input key ID in the same way, which would then match (or not, if the principal has a different account or region) the key in the incoming message? It feels very strange for key IDs to be allowed on one end but not the other. |
Problem:
In previous versions, you could use KMS key ids in addition to ARNs. I believe this is still the intended behavior, but it appears to be broken. You can reproduce it with the aws_kms_keyring_example.py script from the examples. Side note, on line 58 for some reason the example sets the region to us-west-2, which will of course break things if your keys aren't in that region. The example should be changed to remove that. The following output assumes that minor problem is fixed:
First, with the key ARN:
Some sort of minor problem there that should also be fixed, but not a blocking problem (yet). Now, with the key id:
encrypt()
succeeds, butdecrypt()
fails withUnable to decrypt data key: No Encrypted Data Keys found to match.
I discovered this when upgrading with code that used the key id. At the very least
encrypt()
should raise an error, it's much worse to end up with a ciphertext you can't decrypt.Side note: it'd be nice to have a utility that can output the parsed message fields. The structure is documented but it'd be nice to have that provided. The empty string after "Expected:" in the error leads me to think something might be missing from the message, but I'm too lazy to parse it myself. And such a utility would be useful for cataloging, as an example, what keys are in use by a system using the Encryption SDK, without needing to decrypt all the values.
The text was updated successfully, but these errors were encountered: