Adding manual encryption key management for encrypted recordings#56920
Adding manual encryption key management for encrypted recordings#56920
Conversation
There was a problem hiding this comment.
I added these helpers because I noticed that most of the enum types with custom unmarshalers were doing essentially the same thing. For now these are only used by PrivateKeyType since that's the only one I'm modifying for this PR, but I might do a separate PR that updates the other enum types to use this unless I get feedback against implementing this generically.
65d37b1 to
4c6f773
Compare
72bfb2a to
e6cde62
Compare
| shouldUpdate := len(addedKeys) > 0 && (keysChanged || len(existingKeys) != len(addedKeys)) | ||
| if !shouldUpdate { |
There was a problem hiding this comment.
This was previously failing to remove keys after rotation
e6cde62 to
03952e5
Compare
4c6f773 to
cd87b3e
Compare
03952e5 to
11aec2a
Compare
cd87b3e to
6044e3f
Compare
24ea8a4 to
cd09a43
Compare
|
Amplify deployment status
|
29da268 to
3f8ea79
Compare
17e0aab to
ced2f23
Compare
3f8ea79 to
6c7edeb
Compare
6c7edeb to
174da72
Compare
174da72 to
836f806
Compare
|
|
||
| func (s *kmsKey) Decrypt(rand io.Reader, ciphertext []byte, opts crypto.DecrypterOpts) (plaintext []byte, err error) { | ||
| resp, err := doGCPRequest(s.ctx, s.g, s.g.kmsClient.AsymmetricDecrypt, &kmspb.AsymmetricDecryptRequest{ | ||
| resp, err := doGCPRequest(context.Background(), s.g, s.g.kmsClient.AsymmetricDecrypt, &kmspb.AsymmetricDecryptRequest{ |
There was a problem hiding this comment.
How come this was changed to a background context?
There was a problem hiding this comment.
I meant to come back around and fix this. The embedded context in kmsKey was causing cache issues because it only had a request lifetime when the keys were fetched during asession_recording_config update. I added a context to the Manager struct to be used for this so any cached key context has at least the same lifetime as the manager itself.
72c8635 to
72afacd
Compare
7739cfa to
6f668f3
Compare
I do and you can find it here.
Most definitely, should be in the latest commit 👍 |
6f668f3 to
27e5b9c
Compare
| return nil, trace.AccessDenied("this request can be only executed by an auth server") | ||
| } | ||
|
|
||
| if err := cfg.CheckAndSetDefaults(); err != nil { |
There was a problem hiding this comment.
What do you think about adding a services.ValidateSessionRecordingConfig function similar to services.ValidateAuthPreference which can also be home to the cloud and fips checks from your future PR instead of performing a CheckAndSetDefaults in the gRPC layer?
There was a problem hiding this comment.
Yeah I wasn't totally sure about using CheckAndSetDefaults for this. Adding a new validation func to services makes sense to me 👍
d114b67 to
3d01dd2
Compare
|
@nklaassen @rudream friendly ping! |
| ) | ||
|
|
||
| // ValidateSessionRecordingConfig checks that the state of a [SessionRecordingConfig] meets constraints. | ||
| func ValidateSessionRecordingConfig(cfg types.SessionRecordingConfig) error { |
There was a problem hiding this comment.
Suggestion: add some test coverage for this
3d01dd2 to
0372b0a
Compare
0372b0a to
2c98b5d
Compare
* adding support for encryption/decryption keys to keystore manager (#54428, #55652) * adds new protos for resources related to encrypted session recordings and updates the existing SessionRecordingConfig protos to include a Status (#54780) * adding local service implementation for recording encryption resources (#54816) * adding Manager for RecordingEncryption resources that handles shared ops more complex than CRUD (#55078) * Adding session recording plugin for `age` (#55120) * adding Manager for RecordingEncryption resources that handles shared ops more complex than CRUD * adding age plugin wrapping default X25519 Identity/Recipient implementation with hooks to more efficiently lookup private keys given their respective public key * Adding recording encryption and playback for `sync` modes (#54901) * adding cache for RecordingEncryption (#55857) * adding recording_encryption service protos (#55121) * adding async recording encryption with gRPC multipart uploader (#55859) * adding file configuration for encrypted session recording (#56200) * Switching recording encryption to unwrap keys using direct keystore RSA decryption (#56776) * adding manual key management config (#56920) * updating protos for recording encryption (#57055) * Add missing handling for recording encryption configs and keys (#57279) * updating protos for recording encryption * changing labels for encryption keys to prevent automatic cleanup, adjusting pkcs11 host UUID check to allow for key sharing of encryption keys, preventing cloud tenants from enabling manual key management, preventing use of recording encryption in FIPS mode * adding new protos for rotated keys and the local service for interacting (#57576) with them * Switching encryption keys from PEM to ASN.1 DER encoding (#58137) * using pregenerated RSA4096 key for keystore tests because generation is too slow (#58138) * extending precomputed RSA keys to support 4096-bit keys (#58251) * adding rotation process to Manager and exposing with new RPCs and (#57577) * adding rotation sub commands for recording encryption keys and fixing (#57780) broken session_recording_config when using fileconf * using more reliable method of validating key bit length
This PR adds configurations for manual management of session recording encryption keys. This works by accepting an active and rotated list of
KeyLabels which designate which keystore a key can be found in and an identifying label. For HSM systems this is a label that that might identify multiple keys, but for KMS systems this will be an ID, ARN, or fully qualified version name of a specific key.Once an auth server knows how to find the keys, it will search for them in its configured keystore (configurable with
ca_key_params), save the public keys to thesession_recording_configresource to enable encryption, and cache the associatedcrypto.Decrypterfor future replay. When in manual management mode, Teleport will make no attempt at provisioning or rotating recording encryption keys.