From 33055702a8f4a2601497721a1657a6bf401cece4 Mon Sep 17 00:00:00 2001 From: willhr3 <48725248+willhr3@users.noreply.github.com> Date: Tue, 10 Sep 2019 16:25:33 +0100 Subject: [PATCH] CORDA-2837 Prevent node running SwapIdentitiesFlow from initiating session with itself (#5457) --- .../kotlin/net/corda/confidential/SwapIdentitiesFlow.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/confidential-identities/src/main/kotlin/net/corda/confidential/SwapIdentitiesFlow.kt b/confidential-identities/src/main/kotlin/net/corda/confidential/SwapIdentitiesFlow.kt index d2813f9e1e..4bc0917347 100644 --- a/confidential-identities/src/main/kotlin/net/corda/confidential/SwapIdentitiesFlow.kt +++ b/confidential-identities/src/main/kotlin/net/corda/confidential/SwapIdentitiesFlow.kt @@ -90,10 +90,12 @@ private constructor(private val otherSideSession: FlowSession?, @Suspendable override fun call(): LinkedHashMap { - val session = otherSideSession ?: run { + val session = if (otherParty != null && otherParty != otherSideSession?.counterparty) { logger.warnOnce("The current usage of SwapIdentitiesFlow is unsafe. Please consider upgrading your CorDapp to use " + "SwapIdentitiesFlow with FlowSessions. (${CordappResolver.currentCordapp?.info})") - initiateFlow(otherParty!!) + initiateFlow(otherParty) + } else { + otherSideSession!! } progressTracker.currentStep = GENERATING_IDENTITY val ourAnonymousIdentity = serviceHub.keyManagementService.freshKeyAndCert(ourIdentityAndCert, false)