From 740b399ec2f089e6ada109f719ed53932c049061 Mon Sep 17 00:00:00 2001 From: James Lu Date: Sat, 7 Oct 2017 20:50:09 -0700 Subject: [PATCH] clientbot: block attempts from virtual clients to change to an existing nick (#535) --- protocols/clientbot.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/protocols/clientbot.py b/protocols/clientbot.py index 3e7190d..b26b1c5 100644 --- a/protocols/clientbot.py +++ b/protocols/clientbot.py @@ -253,6 +253,13 @@ class ClientbotWrapperProtocol(IRCCommonProtocol): self.send('NICK :%s' % newnick) # No state update here: the IRCd will respond with a NICK acknowledgement if the change succeeds. else: + assert source, "No source given?" + # Check that the new nick exists and isn't the same client as the sender + # (for changing nick case) + nick_uid = self.nick_to_uid(newnick) + if nick_uid and nick_uid != source: + log.warning('(%s) Blocking attempt from virtual client %s to change nick to %s (nick in use)', self.name, source, newnick) + return self.call_hooks([source, 'CLIENTBOT_NICK', {'newnick': newnick}]) self.users[source].nick = newnick