Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
feat: changed encrypt function input to buffer
=abbef4fc4417
diff --git a/backend/src/services/kms/kms-service.ts b/backend/src/services/kms/kms-service.tsindex fcd50cd360..93613c58d6 100644--- a/backend/src/services/kms/kms-service.ts+++ b/backend/src/services/kms/kms-service.ts@@ -49,7 +49,7 @@ export const kmsServiceFactory = ({ kmsDAL, kmsRootConfigDAL, keyStore }: TKmsSeconst cipher = symmetricCipherService(SymmetricEncryption.AES_GCM_256);const kmsKey = cipher.decrypt(kmsDoc.encryptedKey, ROOT_ENCRYPTION_KEY);- const encryptedPlainTextBlob = cipher.encrypt(Buffer.from(plainText, "utf8"), kmsKey);+ const encryptedPlainTextBlob = cipher.encrypt(plainText, kmsKey);// Buffer#1 encrypted text + Buffer#2 version numberconst versionBlob = Buffer.from(KMS_VERSION, "utf8"); // length is 3@@ -65,8 +65,8 @@ export const kmsServiceFactory = ({ kmsDAL, kmsRootConfigDAL, keyStore }: TKmsSeconst kmsKey = cipher.decrypt(kmsDoc.encryptedKey, ROOT_ENCRYPTION_KEY);const cipherTextBlob = versionedCipherTextBlob.subarray(0, -KMS_VERSION_BLOB_LENGTH);- const decryptedKmsDataString = cipher.decrypt(cipherTextBlob, kmsKey);- return decryptedKmsDataString;+ const decryptedBlob = cipher.decrypt(cipherTextBlob, kmsKey);+ return decryptedBlob;};const startService = async () => {@@ -91,10 +91,10 @@ export const kmsServiceFactory = ({ kmsDAL, kmsRootConfigDAL, keyStore }: TKmsSeif (lock) await lock.release();logger.info("KMS: Encrypted ROOT Key found from DB. Decrypting.");const decryptedRootKey = cipher.decrypt(kmsRootConfig.encryptedRootKey, Buffer.from(encryptionKey, "utf8"));+ // set the flag so that other instancen nodes can startawait keyStore.setItemWithExpiry(KMS_ROOT_CREATION_WAIT_KEY, KMS_ROOT_CREATION_WAIT_TIME, "true");logger.info("KMS: Loading ROOT Key into Memory.");ROOT_ENCRYPTION_KEY = decryptedRootKey;-return;}@@ -103,6 +103,8 @@ export const kmsServiceFactory = ({ kmsDAL, kmsRootConfigDAL, keyStore }: TKmsSeconst encryptedRootKey = cipher.encrypt(newRootKey, Buffer.from(encryptionKey, "utf8"));// @ts-expect-error id is kept as fixed for idempotence and to avoid race conditionawait kmsRootConfigDAL.create({ encryptedRootKey, id: KMS_ROOT_CONFIG_UUID });++ // set the flag so that other instancen nodes can startawait keyStore.setItemWithExpiry(KMS_ROOT_CREATION_WAIT_KEY, KMS_ROOT_CREATION_WAIT_TIME, "true");logger.info("KMS: Saved and loaded ROOT Key into memory");if (lock) await lock.release();diff --git a/backend/src/services/kms/kms-types.ts b/backend/src/services/kms/kms-types.tsindex 2f6b693ba2..6aa5300fee 100644--- a/backend/src/services/kms/kms-types.ts+++ b/backend/src/services/kms/kms-types.ts@@ -1,7 +1,6 @@export type TEncryptWithKmsDTO = {kmsId: string;- // utf8 encoded- plainText: string;+ plainText: Buffer;};export type TDecryptWithKmsDTO = {