Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix: correct kmsKey decryption logic in kms-service

Victor Hugo dos Santos264fc9b0f343
diff --git a/backend/src/services/kms/kms-service.ts b/backend/src/services/kms/kms-service.ts
index 69d2d16d1f..513bf8b765 100644
--- a/backend/src/services/kms/kms-service.ts
+++ b/backend/src/services/kms/kms-service.ts
@@ -671,8 +671,9 @@ export const kmsServiceFactory = ({
// internal KMS
const keyCipher = symmetricCipherService(SymmetricKeyAlgorithm.AES_GCM_256);
const dataCipher = symmetricCipherService(encryptionAlgorithm);
+ const kmsKey = keyCipher.decrypt(kmsDoc.internalKms?.encryptedKey as Buffer, ROOT_ENCRYPTION_KEY);
+
return ({ plainText }: Pick<TEncryptWithKmsDTO, "plainText">) => {
- const kmsKey = keyCipher.decrypt(kmsDoc.internalKms?.encryptedKey as Buffer, ROOT_ENCRYPTION_KEY);
const encryptedPlainTextBlob = dataCipher.encrypt(plainText, kmsKey);
// Buffer#1 encrypted text + Buffer#2 version number