bouncedcc: only let the user's own clients connect to an IRC-originated bounce

When the DCC request came from IRC, ZNC connects out to the remote peer
and the thing connecting to the bounce listener should be one of the
user's clients. In GetSockObj, compare the connecting address with the
remote IP of each currently connected client and refuse anyone else,
closing the accepted socket straight away while leaving the listener up
for the real client. The user-originated path is unchanged, since there
it is the remote IRC peer that is expected to connect.
This commit is contained in:
Alhuda Khan committed 2026-10-23 13:00:06 +05:30
1 parent 8aef9873fc
commit d5375e58f8
2 files changed
+34

No files matched your search

+9
View File
@@ -766,6 +766,15 @@ TEST_F(ZNCTest, BounceDCCModule) {
client.ReadUntilAndGet(":friend!user@host PRIVMSG nick :\001DCC CHAT chat", line2);
EXPECT_THAT(line2.toStdString(), Not(HasSubstr("3232235521 54321")));
// Only the user's own clients may connect to that bounce port. The test
// client is on a unix socket, so a TCP connection from anywhere is refused.
QByteArray bouncePort = line2.mid(line2.lastIndexOf(' ') + 1);
bouncePort.chop(1); // trailing \001
QTcpSocket outsider;
outsider.connectToHost("127.0.0.1", bouncePort.toUShort());
outsider.waitForConnected();
client.ReadUntil("Refused connection from 127.0.0.1");
// Peer must not be able to make ZNC connect to its own loopback
ircd.Write(":friend!user@host PRIVMSG nick :\001DCC CHAT chat 2130706433 6379\001");
client.ReadUntil("refused: bad address 2130706433");