Avoid trying to send an ANS_KEY request to unreachable nodes.
We could have a REQ_KEY coming from a node that is not reachable; either
because DEL_EDGEs have overtaken the REQ_KEY, or perhaps if TunnelServer
is used and some nodes have a different view of reachability.
Nowadays all operating systems tinc runs on should support IPv6, so we
can rely on inet_pton() and inet_ntop() to convert IPv4 and IPv6
addresses. Use this instead of our own parsing code.
The old function could get confused by short-hand IPv6 notation (using ::)
and mistake them for MAC addresses. The new code is more strict; it will
correctly handle all short-hand addresses, and will return an error when
an address has trailing garbage instead of ignoring it.
Guus Sliepen [Thu, 11 Oct 2018 17:47:15 +0000 (19:47 +0200)]
Remove the call to RAND_load_file().
It might have been necessary for some very old version of OpenSSL, but
the currently minimum required version for tinc will do a proper
initialization of its PRNG automatically. LibreSSL of course does the
right thing too, and its RAND_load_file() is just a dummy.
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.