Prevent a MITM from forcing a NULL cipher for UDP (CVE-2018-16758)
If a man-in-the-middle has intercepted the TCP connection it might be
able to force plaintext UDP packets between two nodes for up to
a PingInterval period.
The authentication protocol allows an oracle attack that could
potentially be exploited. This commit contains several mitigations:
- Connections are no longer closed immediately on error, but put in
a "tarpit".
- The authentication protocol now requires a valid CHAL_REPLY from the
initiator of a connection before sending a CHAL_REPLY of its own.
- Only a limited amount of connections per second are accepted.
- Null ciphers or digests are no longer allowed in METAKEYs.
- Connections that claim to have the same name as the local node are
rejected.
Maximilian Stein [Mon, 15 Jan 2018 23:45:38 +0000 (00:45 +0100)]
Fix SEGFAULT when trying to connect to IPv6 peer in non-IPv6 environment
Using my tinc setup I observe spurious SEGFAULTs in the daemon process.
My configuration comprises a proxy (type exec) and the peer's address is
given by its domain name. The domain resolves to both IPv4 and IPv6.
As IPv6 is not working in my environment, all connection attempts to the
resolved IPv6 addresses fail. Sometimes, after such a failure, the
segfault occurs.
Apparently, the issue is caused by a use after free due to failing to
reset a pointer.
Guus Sliepen [Sat, 6 Jan 2018 15:58:54 +0000 (16:58 +0100)]
Make systemd service file handling identical to tinc 1.1.
This removes hardcoded paths from systemd unit files, and sets the default
systemd unit path to ${libdir}/systemd/system. The configure option is now
renamed to --with-systemd[=PATH]. These changes now also ensure that
make distcheck runs without any errors.
Guus Sliepen [Sat, 16 Dec 2017 21:44:57 +0000 (22:44 +0100)]
Don't use SOL_IP and SOL_IPV6.
These macros do not exist on all platforms, instead one should use
IPPROTO_IP and IPPROTO_IPV6. This fixes a bug on macOS where the
IPV6_V6ONLY flag would not be applied and could result in IPv4 sockets
not working.
Guus Sliepen [Sat, 4 Nov 2017 13:17:27 +0000 (14:17 +0100)]
Support autoconf's --runstatedir option.
Put the PID file in @runstatedir@ instead of @localstatedir@/run. This
requires autoconf 2.70, which is not released yet, so add a fallback to
use @localstatedir@/run if @runstatedir@ is not set.
Guus Sliepen [Wed, 11 Oct 2017 18:02:22 +0000 (20:02 +0200)]
Handle tun/tap device returning EPERM or EBUSY.
Often when tun/tap is used any errors during setup will be confuse tinc
and it will then assume it is an Ethertap device. Try to avoid this by
checking errno after a failed TUNSETIFF; if it's EPERM or EBUSY then
we can be sure it was not an Ethertap device, and we should report an
error instead.
Guus Sliepen [Sun, 8 Oct 2017 19:37:19 +0000 (21:37 +0200)]
Fix some "make distcheck" errors.
The only issue left is the installation of systemd service files, which
is done to a custom data directory. Make distcheck calls install without
DESTDIR it seems, but running "make install" manually works fine.
Guus Sliepen [Sat, 7 Oct 2017 15:46:52 +0000 (17:46 +0200)]
Convert sizeof foo to sizeof(foo).
While technically sizeof is an operator and doesn't need the parentheses
around expressions it operates on, except if they are type names, code
formatters don't seem to handle this very well.
Guus Sliepen [Tue, 27 Jun 2017 21:36:52 +0000 (23:36 +0200)]
Don't forget about outgoing connections on host file read errors.
If the host config file for an outgoing connection cannot be read, or if
it doesn't contain any Address, don't forget about the ConnectTo, but go
straight to MaxTimeout seconds for retries.
Guus Sliepen [Sun, 28 May 2017 10:42:25 +0000 (12:42 +0200)]
Set KillMode=mixed in the systemd service file.
This ensures only the main process is sent the SIGTERM, and not anything
else that might have started in the same control group, including the
tinc-down script.
This is important for multi-homed users that want to ensure the source
address of outgoing TCP connections is the same as the address that tinc
is listening on.
Binding is done automatically if there is exactly one listening address
for a given address family.
Guus Sliepen [Sat, 29 Oct 2016 20:10:32 +0000 (22:10 +0200)]
Really fix byte budget calculation.
We want to use the underlying cipher's block length, but if it's a stream
mode this will be 1. In that case, use the IV length. Ensure we never get
a budget that cannot be stored in a 64 bits integer.
Thanks to Wessel Dankers for helping getting this right.
Guus Sliepen [Sat, 29 Oct 2016 13:24:34 +0000 (15:24 +0200)]
Use AES256 and SHA256 by default, also for the meta-connections.
At the start of the decade, there were still distributions that shipped
with versions of OpenSSL that did not support these algorithms. By now
everyone should support them. The old defaults were Blowfish and SHA1,
both of which are not considered secure anymore.
The meta-protocol now always uses AES in OFB mode, but the key length
will adapt to the one specified by the Cipher option. The digest for the
meta-protocol is hardcoded to SHA256.
Guus Sliepen [Sun, 5 Jun 2016 13:23:07 +0000 (15:23 +0200)]
Preserve IPv6 scope_id in edges.
When creating an edge after authenticating a peer, we copy the address
used for the TCP connection, but change the port to that used for UDP.
But the way we did it discarded the scope_id for IPv6 addresses. This
prevented UDP communication from working correctly when connecting to a
peer on the same LAN using an IPv6 link-local address.
Thanks to Rafał Leśniak for pointing out this issue.
Use devname() if available to support devfs cloning on BSD.
Some BSD flavors allow opening /dev/tun and/or /dev/tap, which automatically
create a new tun or tap interface with an unused number. To find out which
number the interface got, you have to call devname() on the device file
that was opened.
The semantics are different from the way Linux's /dev/tun works though.
In particular, after closing the device, the interface will continue to exist.
Restarting tincd would cause the old interface to stay around, and a new
one to be created. One could add a tinc-down script with the following line:
ifconfig $INTERFACE destroy
But that is still no guarantee that restarting tinc will give you the same
interface. So the default tun and tap device will stay /dev/tun0 and /dev/tap0
for all BSD flavors to avoid surprises for existing users.