Commit Graph

314 Commits

Author SHA1 Message Date
Mikkel Krautz
1c8b637cbf Server: rename qlCA to qlIntermediates, to properly reflect its function.
The list doesn't actually contain CA certificates, but intermediates.

So let us name it appropriately.
2017-02-25 23:10:47 +01:00
Mikkel Krautz
a9330a48f7 Revert 91dc3d39f0 ('Move counter variable in processMsg into Opus condition.').
This comit (full SHA-1 is 91dc3d39f0) is
obviously flawed.

So revert it.
2017-02-07 20:03:31 +01:00
Mikkel Krautz
4d6a813e80 Refactor Server::supportsDualStack().
The current implementation tries too hard to avoid duplication
of very few lines of code.

Instead, use two separate code paths, one for Windows, one for
Unix-like sytems.

This makes it more readable, and allows us to handle system-specific
quirks much easier. For example, SOCKET is unsigned on Windows, and
comparing it to -1 technically works (at least for two's complement
machines), but causes a compiler warning for a signed vs. unsigned
comparison.
2017-02-02 00:34:11 +01:00
Mikkel Krautz
91ebb8b0b5 Update tree copyrights to 2017. 2017-01-08 21:05:57 +01:00
Mikkel Krautz
cd8f6b75e0 Refactor LogEmitter from Murmur into its own file in src/.
It's a natural refactoring and it'd be nice to be able to
use LogEmitter in Mumble as well.
2016-12-04 13:26:46 +01:00
Mikkel Krautz
2e6625b191 Murmur: replace all QAtomicInt loads with new QAtomicIntLoad compatibility function.
By using our new portable QAtomicIntLoad function, we ensure compatibility
with both Qt 4 and Qt 5.

Fixes mumble-voip/mumble#2586
2016-10-26 21:31:53 +02:00
Mikkel Krautz
46b5b62781 Murmur: use aiUdpFlag.load() in comparisons to fix Qt <5.2 build.
Fixes mumble-voip/mumble#2420
2016-07-15 00:49:08 +02:00
Mikkel Krautz
c73df62a65 Fix locking in the unknown peer path of UDP receive in Server::run(). 2016-06-24 00:03:12 +02:00
Mikkel Krautz
cb446f1808 Server: convert bUdp to use QAtomicInt for proper synchronization. 2016-06-24 00:03:12 +02:00
Mikkel Krautz
cfb535aa15 Add missing ACL cache lock to Server::processMsg. 2016-06-24 00:03:11 +02:00
Mikkel Krautz
f03b74db2d Add mutex for csCrypt usage in Murmur. 2016-06-24 00:03:11 +02:00
Mikkel Krautz
f260bd1913 Implement correct write locking for addChannel/removeChannel/link/unlink. 2016-06-24 00:03:11 +02:00
Mikkel Krautz
f66b0d34c8 Rename qrwlUsers to qrwlVoiceThread. 2016-06-24 00:03:11 +02:00
Mikkel Krautz
91dc3d39f0 Move counter variable in processMsg into Opus condition. 2016-06-24 00:03:11 +02:00
Mikkel Krautz
77ddc015b0 Move processMsg's 'c' Channel pointer into 'normal speech' code path. 2016-06-24 00:03:11 +02:00
Mikkel Krautz
d6d6f6fa0f Refactor use of 'p' User pointer used in foreach loops.
Improve readability by declaring a local 'User *p' in
each foreach loop.
2016-06-24 00:03:11 +02:00
Mikkel Krautz
f696ddc281 Server: refactor bandwidth check in processMsg. 2016-06-24 00:03:11 +02:00
Mikkel Krautz
3897c794fe Murmur: use non-forceful disconnect when encountering SSL handshake errors on Qt 5.
Due to a regression in Qt 5, we can't use disconnectSocket(true)
to abort a handshake.

Use non-forceful disconnect to work around the Qt 5 bug.

See inline comment for more details.

Fixes mumble-voip/mumble#2334
2016-06-11 01:53:03 +02:00
Mikkel Krautz
54c28d3ee1 src/murmur: update to use LICENSE.header. 2016-05-10 22:42:02 +02:00
James Fraser
68547c9a94 Fix missing whitespace in if statement 2016-04-26 15:56:45 +02:00
Mikkel Krautz
bd8f92b983 Move HTML filtering to a separate shared class.
And touch up some of its code.

LuaMilkshake reports that it is possible to get
Murmur to emit HTML even when allowhtml is false.

For example via "<br />&lt;b&gt;hello world&lt;/&gt;",
which would be translated to "\n<b>hello world</b>"
by the previous HTML filtering code.

Mumble uses QXmlStreamReader to get each token of
an XML document to sanitize it.
Unfortunately, QXmlStreamReader isn't just a tokenizer.
It has a lot of behind-the-scenes XML logic to handle
things such as entities.
Entities definitions are read and handled by the
QXmlStreamReader itself, and are not emitted to a
consumer of QXmlStreamReader. This means that when
QXmlStreamReader gives you a piece of 'text' data,
it will have already translated any entities in the
text and translated them accordingly.
This is why LuaMilkshake's example works.

It is seemingly not possible to get QXmlStreamReader
to avoid handling entities. But I believe we can at
least stop it from allow new entities to be defined.
The original code already did that -- by wrapping
the input XML in a new root tag "<document>". This
ensures that an internal DTD cannot be defined, and
thus that no new entities can be added.

This limits the number of entities we need to
handle, to the small list of default entities
defined by XML: &quot; &amp; &aps; &lt; &gt;.

To ensure that the HTML filter is at least a little
bit effective against these injection attacks, we
ammend the logic of the HTML filter to attmpt to
strip &lt; and &gt; *after* running it through
the original QXmlStreamReader-based filter.
This ensures that no additional HTML elements
can be added via entities.
2016-01-31 11:42:15 +01:00
Mikkel Krautz
58c06f267e Fix Murmur on Windows DoS as described in Mumble-SA-2016-001.
See https://www.mumble.info/security/Mumble-SA-2016-001.txt
for more information.
2016-01-10 14:25:30 +01:00
Mikkel Krautz
33f8448d7c Murmur: allow both bitmasked version and version string when setting 'suggestversion' via RPC.
This commit ensures that a 'suggestversion' is always normalized to a
bitmasked version.

Previously, only a bitmasked 'suggestverson' was allowed.

With this commit, 'suggestversion' may now be either a version string,
or a bitmasked integer value representing the version.

The previous behavior was confusing to users, since the murmur.ini
has always used 'suggestversion' with a version string.

Fixes mumble-voip/mumble#989
2015-12-26 22:03:13 +01:00
Natenom
b5825472f8 Show more information when a banned user connects 2015-12-07 23:55:00 +01:00
Tim Cooper
fea39f2008 Respect maximum channel user limits when joining server
Fixes mumble-voip/mumble#1930
2015-11-28 10:17:22 +01:00
Tim Cooper
4862897a5b Add maximum number of server users to control channel protocol 2015-11-16 22:35:40 +01:00
Stefan Hacker
7b882d0bc5 Fix warnings in murmur/Server.cpp
The main problem here is that Windows uses types incompatible
to Linux in the setsockopt/getsockopt functions.

This patch works around this by defining TU-local macros to wrap
the types and casts.
2015-10-27 00:01:13 +01:00
Mikkel Krautz
8bd3f76a8e Murmur: add support for EDH cipher suites, and for specifying Diffie-Hellman parmeters.
This change allows server admins to specify Diffie-Hellman
parameters for Murmur to use. This is done using the sslDHParams
option in the config file. Diffie-Hellman parameters can also be
set on a per-server basis using the sslDHParams option.

Note: the functionality implemented in this change requires the
QSslDiffieHellmanParameters class in Qt, which has not yet landed
upstream in the Qt 5 'dev' branch. This means that the functionality
discussed in this change will, for now, only work in binaries provided
by the Mumble project, or binaries that are built using our build
environments, and not binaries that link against any released versions
of Qt at present.

This change modifies the default TLS cipher suite string to add
EDH+aRSA+AESGCM, DHE-RSA-AES256-SHA and DHE-RSA-AES128-SHA.

This yields the following ciphers, in TLS/RFC notation:

    TLS_DHE_RSA_WITH_AES_256_GCM_SHA384
    TLS_DHE_RSA_WITH_AES_128_GCM_SHA256
    TLS_DHE_RSA_WITH_AES_256_CBC_SHA
    TLS_DHE_RSA_WITH_AES_128_CBC_SHA

This change also allows Murmur servers to provide forward secrecy
to older clients, such as our own pre-built binaries before 1.2.9.

It also provides forward secrecy for users that use Mumble 1.2.x
versions on Linux distros, and other Unix-like systems. This is
because Mumble 1.2.x on Unix-like systems builds against Qt 4, which
limits the connection to TLS 1.0.

Before this change, Murmur was not able to negotiate an ephemeral
Diffie-Hellman key exchange for those clients. This is now possible.
2015-09-26 22:33:49 +02:00
Tim Cooper
ebf6d23f2b Broadcast RPC-updated welcome text, even when it is empty 2015-07-21 20:48:37 +02:00
Stefan Hacker
d3d6920da9 Fix various warnings in Linux build
This patch fixes various warnings encountered
in the build when using gcc 4.9.
2015-07-04 15:12:49 +02:00
Stefan Hacker
e934c1e648 Fix dual-stack UDP on Windows and improve dual-stack detection
This patch fixes dual-stack UDP on Windows as well as for unsual
Linux configurations by ensuring the UDP sockets we create
inherit their IPV6_V6ONLY sockopt from their corresponding
TCP socket. Previously on systems where IPV6_V6ONLY was enabled
by default (e.g. Windows) we would incorrectly create an
IPv6 only socket even though our TCP socket and the system
are dual-stacked.

The dual-stack detection moved from Meta.h to Server.h into the
SslServer class where it is a better fit. Also modified the function
to instead of querying the value of IPV6_V6ONLY on a test socket
it now tries to actively disable it. While previously dual stack
support was only detected if it was the default configuration for
that system, it should now be detected in all cases. The function
also now performs the same check on Windows socket where the default
actually is to have IPV6_V6ONLY enabled.
2015-06-05 02:08:12 +02:00
Mikkel Krautz
6c96ab468f Use 'QSsl::TlsV1_0' on Qt 5.0 through 5.3 and allow 'QSsl::SecureProtocols' to be used on 5.4.X.
Some configurations of Qt 5.X explicitly disable deprecated
parts of the API, such as 'QSsl::TlsV1'. To allow Mumble to build
on those configurations, we have to use 'QSsl::TlsV1_0' instead,
like we did in the prior to 71e522f4c4.

This commit also fixes an issue where QSsl::SecureProtocols was only
selected on the base 5.4.0 release, and not subsequent patch releases.
2015-03-19 14:45:53 +01:00
Mikkel Krautz
71e522f4c4 Use QSsl::TlsV1_0OrLater on Qt 5.5 or later, and QSsl::SecureProtocols on Qt 5.4.
We upstreamed a patch for adding the self-explanatory
QSsl::TlsV1_0OrLater, QSsl::TlsV1_1OrLater and QSsl::TlsV1_2OrLater
enums to QSsl.

Before this, we had a patch in our Qt 5.4 build (on Windows), that
changed the meaning of QSsl::TlsV1_0 to mean "TLSv1.0 or later".
However, that approach wouldn't work in the real world (some setups
require very specific TLS versions), so it was dropped in favour of
the TlsV1_0OrLater and friends.

Since our patch is in Qt 5.5, it means that we now can use
QSsl::TlsV1_0OrLater in the Mumble tree (ifdef'd to QT_VERSION
>= 0x050500), and not break anything for distros.

For Qt 5.4, we can rely on QSsl::SecureProtocols, because Qt 5.4
deprecated SSLv3. Thus, in Qt 5.4, QSsl::SecureProtocols means the
same thing as TlsV1_0OrLater means in Qt 5.5.

Why do we need TlsV1_0OrLater and friends if we have
QSsl::SecureProtocols? Because we don't have a guarantee that
QSsl::SecureProtocols will keep having TLSv1.0 as its minimum
version. The current Mumble protocol requires TLS 1.0.

If something comes up in the future that makes us abandon TLSv1.0,
we'll still handshake it. Rejection can happen at the Mumble protocol
level instead, providing a better user experience.
2015-03-18 23:23:30 +01:00
Stefan Hacker
c5e427d607 Revert "Use TLS 1.2 when built with Qt 5."
This reverts commit 75843b62a7.
2014-12-26 04:41:22 +01:00
Mikkel Krautz
75843b62a7 Use TLS 1.2 when built with Qt 5. 2014-12-25 23:57:48 +01:00
Mikkel Krautz
78ac46880c Murmur: fix override of TcpSocket::incomingConnection(). it takes a qintptr (and not an int) in Qt 5. 2014-12-25 23:57:21 +01:00
Stefan Hacker
12eb26431f Replace all uses of QT_VERSION_CHECK with explicit version.
Qt4's moc is not able to expand QT_VERSION_CHECK which may lead
to invalid codegen when used for backwards compatibility work.
Replaced all occurances with explicit check against numeric
version which are treated correctly. Even though bad interactions
might be rare we should no longer use this macro as long as we
want to compile with Qt 4. Also see:
http://lists.qt-project.org/pipermail/interest/2013-August/008351.html
2014-08-22 01:55:34 +02:00
main()
dc3b78c914 Add "forceExternalAuth" config option to Murmur
Without this option (or when it's set to false), Murmur's default
authentication will kick in when your external authenticator plugin
crashes and basically allow *anyone* to login and register.

When it's enabled, Murmur will instead return a temporary login
failure to the client.
2014-07-17 20:55:44 +02:00
Mikkel Krautz
84bc19c818 mumble: migrate hardcoded 0x050000 Qt version to the QT_VERSION_CHECK macro. 2013-06-29 16:56:42 +02:00
Mikkel Krautz
5cb337049b mumble, murmur: Qt 5 support for Linux. 2013-06-29 16:56:41 +02:00
Kissaki
b004a4ce0c add a comment, remove an unused variable 2013-06-04 22:38:51 +02:00
Mikkel Krautz
aab9cdcce4 Server::sendMessage: encode the source IP of outgoing UDP packets to match the UDP socket's address family.
Murmur uses the saiTcpLocalAddress field of ServerUser to determine
the correct source address of outgoing UDP packets. On some systems,
such as multi-homed setups, this is important for correct datagram
delivery.

The saiTcpLocalAddress field is initialized when the client first
connects. Its value is extracted from QHostAddress, and then
converted to a sockaddr struct via our own HostAddress class's
toSockAddr method.

HostAddress::toSockAddr is implemented such that any IPv4 address
(including IPv4-mapped IPv6 addresses) will always cause a sockaddr
struct belonging to the AF_INET (IPv4) family to be output. Pure IPv6
addresses will be output as an AF_INET6 sockaddr.

The code that this change touches assumed that it could use the
value of saiTcpLocalAddress directly as the source address in UDP
packets.

This is not always the case. On most systems, Murmur will listen on
[::]:64738 by default, and as such, the address of the server's UDP
socket will be in the AF_INET6 family. Attempting to send packets
with a source address in the AF_INET family using that socket will
cause sendmsg() to return EINVAL on some systems, if not all.

The new code for the sendmsg() code path converts the ServerUser's
saiTcpLocalAddress back into a HostAddress, which, internally, is
fully IPv6. If the input address is IPv4, HostAddress will convert
it to an IPv4-mapped IPv6 address.

When the client's UDP socket is of the AF_INET6 family, we can now
trust that the HostAddress, 'tcpha', is either a real IPv6 address,
or an IPv4-mapped IPv6 address. This allows us to use the 'tcpha'
address regardless of the address family of the saiTcpLocalAddress.
We can simply memcpy it in place.

When the UDP socket is of the AF_INET family, we can only set the
source address if the saiTcpLocalAddress is also AF_INET, or if
it is of the AF_INET6 family and its address is an IPv4-mapped IPv6
address. When a pure IPv6 address is encountered in that path, it is
simply dropped.
2013-06-01 02:54:53 +02:00
Martin von Gagern
d71b2fd04f Ensure that the MAX macro is always defined.
On some systems, none of the (directly or indirectly) included headers does
provide that macro. First reported in https://bugs.gentoo.org/460524
2013-03-27 22:39:58 +01:00
Stefan Hacker
1253532480 setLiveConf for opusthreshold and channelnestinglimit didn't reset on
empty string (#938)
2013-01-10 18:27:59 +01:00
Stefan Hacker
bb76e7aede Fix pre 1.2.4 clients receiving Opus warnings unintentionally.
* Also sent the warning when codec switch decided no switch was necessary
  and Opus wasn't used. Now only sending if Opus is used.
2012-11-28 20:27:42 +01:00
Stefan Hacker
ce83353dbd Make opustreshold and channelnestinglimit accept zero values in setLiveConf. 2012-11-04 18:06:31 +01:00
Stefan Hacker
145d9f96f5 Introduce channel nesting limit (default=10).
Add NestingLimitException to Ice Interface and introduce a new NestingLimit PermissionDenied type.
Addresses #3566322 "ServerDB::deleteServer crashes master"
2012-09-18 17:50:07 +02:00
Stefan Hacker
aa580f392c Trigger codec re-negotiation also on user disconnect and when opusthreshold is set.
- Call recheckCodecVersion on AuthenticatedClient disconnect.
- Make every recheckCodecVersions() call switching to Opus send a message to users only supporting CELT.
2012-08-06 02:29:20 +02:00
Benjamin Jemlich
994e130a9d Murmur: Fix message type detection in Server::processMsg and add a few more comments
Bug found by Rok Kek <rok.kek@gmail.com> which could affect Opus packets.
2012-07-16 19:29:53 +02:00
Benjamin Jemlich
7ec4f6a67c Murmur: Add codec warnings and ignore non-Opus packets if Opus is enabled
Also includes the CELT warning for "broken" clients by Nicos Gollan.
2012-06-08 23:55:56 +02:00