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 PR comments
Carlos Monastyrski30dd041771a8
diff --git a/backend/src/ee/services/pki-scep/pki-scep-fns.ts b/backend/src/ee/services/pki-scep/pki-scep-fns.tsindex 49d779d7ff..541667fddc 100644--- a/backend/src/ee/services/pki-scep/pki-scep-fns.ts+++ b/backend/src/ee/services/pki-scep/pki-scep-fns.ts@@ -159,18 +159,34 @@ export const normalizeX500Name = (name: x509.Name): string => {return canonicalRdns.join(",");};+// SANs are an unordered set in RFC 5280; normalize each entry and sort for comparison.+export const normalizeSubjectAltNames = (ext: x509.SubjectAlternativeNameExtension | null | undefined): string => {+ if (!ext) return "";+ const pairs: string[] = [];+ for (const item of ext.names.items) {+ const type = String(item.type).toLowerCase();+ const value = String(item.value).normalize("NFC").trim().toLowerCase();+ pairs.push(`${type}:${value}`);+ }+ return pairs.sort().join(",");+};+export const evaluateScepRenewalAuthorization = ({isValidSigner,storedSignerCert,profileId,csrSubjectName,- signerCertSubjectName+ signerCertSubjectName,+ csrSubjectAltNames,+ signerCertSubjectAltNames}: {isValidSigner: boolean;storedSignerCert?: { profileId?: string | null } | null;profileId: string;csrSubjectName: x509.Name;signerCertSubjectName: x509.Name;+ csrSubjectAltNames?: x509.SubjectAlternativeNameExtension | null;+ signerCertSubjectAltNames?: x509.SubjectAlternativeNameExtension | null;}): TScepRenewalAuthResult => {if (!isValidSigner) {return { authorized: false, reason: ScepRenewalDenyReason.InvalidSigner };@@ -180,7 +196,10 @@ export const evaluateScepRenewalAuthorization = ({return { authorized: false, reason: ScepRenewalDenyReason.WrongProfile };}- if (normalizeX500Name(csrSubjectName) !== normalizeX500Name(signerCertSubjectName)) {+ if (+ normalizeX500Name(csrSubjectName) !== normalizeX500Name(signerCertSubjectName) ||+ normalizeSubjectAltNames(csrSubjectAltNames) !== normalizeSubjectAltNames(signerCertSubjectAltNames)+ ) {return { authorized: false, reason: ScepRenewalDenyReason.IdentityMismatch };}diff --git a/backend/src/ee/services/pki-scep/pki-scep-service.ts b/backend/src/ee/services/pki-scep/pki-scep-service.tsindex 2d45941c20..bdd374cc09 100644--- a/backend/src/ee/services/pki-scep/pki-scep-service.ts+++ b/backend/src/ee/services/pki-scep/pki-scep-service.ts@@ -583,13 +583,27 @@ export const pkiScepServiceFactory = ({? await certificateDAL.findOne({ serialNumber: signerCertObj.serialNumber, caId: profile.caId! }): null;+ const toSanExt = (ext: x509.Extension | null): x509.SubjectAlternativeNameExtension | null => {+ if (!ext) return null;+ if (ext instanceof x509.SubjectAlternativeNameExtension) return ext;+ try {+ return new x509.SubjectAlternativeNameExtension(ext.rawData);+ } catch {+ return null;+ }+ };+ const csrSanExt = toSanExt(csrObj.getExtension("2.5.29.17"));+ const signerSanExt = signerCertObj ? toSanExt(signerCertObj.getExtension("2.5.29.17")) : null;+const renewalAuth: TScepRenewalAuthResult = signerCertObj? evaluateScepRenewalAuthorization({isValidSigner,storedSignerCert,profileId: profile.id,csrSubjectName: csrObj.subjectName,- signerCertSubjectName: signerCertObj.subjectName+ signerCertSubjectName: signerCertObj.subjectName,+ csrSubjectAltNames: csrSanExt,+ signerCertSubjectAltNames: signerSanExt}): { authorized: false, reason: ScepRenewalDenyReason.InvalidSigner };