From 85631013fbb28dea7e9c89e5a3b51684defbdd11 Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Sat, 11 Jul 2026 07:41:55 +0000
Subject: [PATCH] [#728] Reject TCP self-connects in replication connect paths (#729)
---
opendj-server-legacy/src/main/java/org/opends/server/replication/service/ReplicationBroker.java | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/replication/service/ReplicationBroker.java b/opendj-server-legacy/src/main/java/org/opends/server/replication/service/ReplicationBroker.java
index c3096b2..3015639 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/replication/service/ReplicationBroker.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/replication/service/ReplicationBroker.java
@@ -13,7 +13,7 @@
*
* Copyright 2006-2010 Sun Microsystems, Inc.
* Portions Copyright 2011-2016 ForgeRock AS.
- * Portions Copyright 2023-2025 3A Systems LLC.
+ * Portions Copyright 2023-2026 3A Systems LLC.
* Portions Copyright 2025 Wren Security.
*/
package org.opends.server.replication.service;
@@ -1083,6 +1083,15 @@
}
int timeoutMS = MultimasterReplication.getConnectionTimeoutMS();
socket.connect(HostPort.valueOf(serverURL).toInetSocketAddress(), timeoutMS);
+ if (isSelfConnection(socket))
+ {
+ // While the RS is down, the kernel may pick the RS port as the local
+ // port of this reconnecting socket (TCP simultaneous open),
+ // "connecting" it to itself. Keeping such a socket open would hold
+ // the RS port and prevent the RS from binding it on restart.
+ throw new ConnectException("Connection to " + serverURL
+ + " is a TCP self-connect, no replication server is listening");
+ }
newSession = replSessionSecurity.createClientSession(socket, timeoutMS);
boolean isSslEncryption = replSessionSecurity.isSslEncryption();
--
Gitblit v1.10.0