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
fix(pki-sync): enforce project boundary when resolving app connections
Carlos Monastyrski4ab5168767b5
diff --git a/backend/src/services/app-connection/app-connection-service.ts b/backend/src/services/app-connection/app-connection-service.tsindex a01140feb2..fe8a3940a0 100644--- a/backend/src/services/app-connection/app-connection-service.ts+++ b/backend/src/services/app-connection/app-connection-service.ts@@ -1214,7 +1214,7 @@ export const appConnectionServiceFactory = ({};const validateAppConnectionUsageById = async (- app: AppConnection,+ app: AppConnection | AppConnection[],{ connectionId, projectId }: TValidateAppConnectionUsageByIdDTO,actor: OrgServiceActor) => {diff --git a/backend/src/services/pki-sync/pki-sync-service.ts b/backend/src/services/pki-sync/pki-sync-service.tsindex 785dc27b11..7fb676918e 100644--- a/backend/src/services/pki-sync/pki-sync-service.ts+++ b/backend/src/services/pki-sync/pki-sync-service.ts@@ -98,7 +98,7 @@ type TPkiSyncServiceFactoryDep = {| "clearSyncMetadataFlag">;pkiSubscriberDAL: Pick<TPkiSubscriberDALFactory, "findById">;- appConnectionService: Pick<TAppConnectionServiceFactory, "connectAppConnectionById">;+ appConnectionService: Pick<TAppConnectionServiceFactory, "validateAppConnectionUsageById">;permissionService: Pick<TPermissionServiceFactory, "getProjectPermission" | "getResourcePermission">;licenseService: Pick<TLicenseServiceFactory, "getPlan">;kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey">;@@ -477,7 +477,11 @@ export const pkiSyncServiceFactory = ({const destinationApps = getPkiSyncConnectionApps(destination);// Validates permission to connect and app is valid for sync destination- const connection = await appConnectionService.connectAppConnectionById(destinationApps, connectionId, actor);+ const connection = await appConnectionService.validateAppConnectionUsageById(+ destinationApps,+ { connectionId, projectId },+ actor+ );assertTargetHostMatchesConnection({ destination, connection, destinationConfig });@@ -640,11 +644,11 @@ export const pkiSyncServiceFactory = ({// Swapping the connection re-runs the App Connection Connect check, as it always has. Editing the// sync's own fields must not: the delivery target is gated by SetTargetHost below, and the sync row// already carries enough of its current connection to validate against.- let resolvedConnection: Awaited<ReturnType<typeof appConnectionService.connectAppConnectionById>> | undefined;+ let resolvedConnection: Awaited<ReturnType<typeof appConnectionService.validateAppConnectionUsageById>> | undefined;const resolveConnection = async () => {- resolvedConnection ??= await appConnectionService.connectAppConnectionById(+ resolvedConnection ??= await appConnectionService.validateAppConnectionUsageById(getPkiSyncConnectionApps(pkiSync.destination),- connectionId ?? pkiSync.connectionId,+ { connectionId: connectionId ?? pkiSync.connectionId, projectId: pkiSync.projectId },actor);return resolvedConnection;@@ -1039,9 +1043,9 @@ export const pkiSyncServiceFactory = ({await validateCertificatesForSync(args.certificateIds, args.projectId, args.applicationId);}- const connection = await appConnectionService.connectAppConnectionById(+ const connection = await appConnectionService.validateAppConnectionUsageById(getPkiSyncConnectionApps(args.destination),- args.connectionId,+ { connectionId: args.connectionId, projectId: args.projectId },actor);