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
Address claude comment
Carlos Monastyrskiba2545cd9896
diff --git a/backend/src/ee/services/pki-scep/pki-scep-message-parser.ts b/backend/src/ee/services/pki-scep/pki-scep-message-parser.tsindex 0ebf266abd..f1287b7e06 100644--- a/backend/src/ee/services/pki-scep/pki-scep-message-parser.ts+++ b/backend/src/ee/services/pki-scep/pki-scep-message-parser.ts@@ -6,7 +6,7 @@ import { BadRequestError } from "@app/lib/errors";import { extractScepAttributes } from "./pki-scep-attributes";import { rsaPkcs1Decrypt, rsaVerify, symmetricDecrypt } from "./pki-scep-crypto";-import { DIGEST_OID_TO_HASH, ScepMessageType, TParsedScepMessage } from "./pki-scep-types";+import { CIPHER_OID_MAP, DIGEST_OID_TO_HASH, ScepMessageType, TParsedScepMessage } from "./pki-scep-types";export const parseScepMessage = (derMessage: Buffer, raPrivateKeyDer: Buffer): TParsedScepMessage => {// Parse the outer ContentInfo@@ -314,15 +314,6 @@ const decryptEnvelopedDataRaw = (throw new BadRequestError({ message: "Failed to extract encrypted key from KeyTransRecipientInfo" });}- // Decrypt the content-encryption key using RSA PKCS1v1.5- let contentEncryptionKey: Buffer;- try {- contentEncryptionKey = rsaPkcs1Decrypt(encryptedKey, raPrivateKeyDer);- } catch {- contentEncryptionKey = crypto.randomBytes(32);- }-- // Extract encrypted content infoconst encContentInfo = (valueBlock[2] as asn1js.Sequence).valueBlock.value;if (encContentInfo.length < 3) {@@ -338,6 +329,10 @@ const decryptEnvelopedDataRaw = (// Get cipher algorithm OID and IV from AlgorithmIdentifierconst algoSeq = (encContentInfo[1] as asn1js.Sequence).valueBlock.value;const cipherOid = (algoSeq[0] as asn1js.ObjectIdentifier).getValue();+ const cipherInfo = CIPHER_OID_MAP[cipherOid];+ if (!cipherInfo) {+ throw new BadRequestError({ message: `Unsupported cipher OID: ${cipherOid}` });+ }// IV is the second element of the AlgorithmIdentifierconst ivElement = algoSeq[1];@@ -357,6 +352,15 @@ const decryptEnvelopedDataRaw = (}// Decrypt the content+ let contentEncryptionKey: Buffer;+ try {+ const decrypted = rsaPkcs1Decrypt(encryptedKey, raPrivateKeyDer);+ contentEncryptionKey =+ decrypted.length === cipherInfo.keyLength ? decrypted : crypto.randomBytes(cipherInfo.keyLength);+ } catch {+ contentEncryptionKey = crypto.randomBytes(cipherInfo.keyLength);+ }+let plainText: Buffer;try {plainText = symmetricDecrypt(encryptedContent, contentEncryptionKey, iv, cipherOid);