FIX(Server): Unauthenticated connections no longer add to user count

This commit fixes both issues discussed in #4277 which were related to
the fact that any socket connection was allocated an ID and marked as
a user. This bug allowed for a malicious user to lock out all users of
a server regardless of server password usage. This change simply moves ID
allocation to after a connection is marked as Authenticated.

FIXES: #4277
This commit is contained in:
Lucas Toole 2021-03-02 08:24:29 -06:00
parent 3e567732b5
commit eabfbab403
2 changed files with 3 additions and 7 deletions

View File

@ -379,7 +379,10 @@ void Server::msgAuthenticate(ServerUser *uSource, MumbleProto::Authenticate &msg
{ {
QWriteLocker wl(&qrwlVoiceThread); QWriteLocker wl(&qrwlVoiceThread);
uSource->uiSession = qqIds.dequeue();
uSource->sState = ServerUser::Authenticated; uSource->sState = ServerUser::Authenticated;
qhUsers.insert(uSource->uiSession, uSource);
qhHostUsers[uSource->haAddress].insert(uSource);
} }
mpus.set_session(uSource->uiSession); mpus.set_session(uSource->uiSession);

View File

@ -1450,16 +1450,9 @@ void Server::newClient() {
} }
ServerUser *u = new ServerUser(this, sock); ServerUser *u = new ServerUser(this, sock);
u->uiSession = qqIds.dequeue();
u->haAddress = ha; u->haAddress = ha;
HostAddress(sock->localAddress()).toSockaddr(&u->saiTcpLocalAddress); HostAddress(sock->localAddress()).toSockaddr(&u->saiTcpLocalAddress);
{
QWriteLocker wl(&qrwlVoiceThread);
qhUsers.insert(u->uiSession, u);
qhHostUsers[ha].insert(u);
}
connect(u, SIGNAL(connectionClosed(QAbstractSocket::SocketError, const QString &)), this, connect(u, SIGNAL(connectionClosed(QAbstractSocket::SocketError, const QString &)), this,
SLOT(connectionClosed(QAbstractSocket::SocketError, const QString &))); SLOT(connectionClosed(QAbstractSocket::SocketError, const QString &)));
connect(u, SIGNAL(message(unsigned int, const QByteArray &)), this, connect(u, SIGNAL(message(unsigned int, const QByteArray &)), this,