Commit graph

185 commits

Author SHA1 Message Date
William Pitcock
fab6f9e80e libratbox: gnutls: we want to pass F, not F->fd to rb_listen() 2015-12-03 22:38:54 -06:00
William Pitcock
cd492e44b5 libratbox: initial cut at an mbedtls implementation, which will replace openssl and gnutls backends in charybdis 3.6
notably, it presently is lacking CertFP support, but everything else is implemented
2015-12-03 22:32:33 -06:00
William Pitcock
6f57a957b0 libratbox: prepare build system for mbed tls backend 2015-12-03 18:37:32 -06:00
Aaron Jones
0b05d1aad5
[libratbox] Remove an unused random function
Nothing in the Charybdis or libratbox code calls rb_get_pseudo_random
and under OpenSSL it uses RAND_pseudo_bytes() which is both dangerous
and removed in OpenSSL version 1.1.0.
2015-10-25 16:04:57 +00:00
Aaron Jones
25f7ee7dd6
Improve the versions of TLS used for server to server linking
When building against current OpenSSL (<= 1.0.2) or old LibreSSL
(< 2.2.2) the server will use TLSv1.0 only when connecting to other
servers.

This patch corrects that.
2015-10-23 16:08:15 +00:00
Aaron Jones
3ae24413ca
Use new TLS method APIs with new LibreSSL
OpenBSD 5.8 includes LibreSSL 2.2.2, which finally brings the API up to
what they claim it is by implementing the new TLS client and server
method APIs. Therefore, in furtherance of commits a4c8c827 and 1a4e224a
we can build with the new APIs if building against (real) OpenSSL 1.1.0
or LibreSSL 2.2.2.

Reported-by: Juuso Lapinlampi <wub@partyvan.eu>
2015-10-23 16:05:33 +00:00
Jilles Tjoelker
df3de4e913 kqueue: Remove unnecessary cast. 2015-09-13 22:59:03 +02:00
William Pitcock
23e6a59007 Merge pull request #95 from jailbird777/master
Spring cleaning redux
2015-07-06 17:13:50 -05:00
Aaron Jones
1a4e224a4e LibreSSL have far advanced OPENSSL_VERSION_NUMBER beyond the
feature set they support (2.0 even!), deliberately breaking
backward compatibility. Therefore, in order to fix a regression
introduced by commit a4c8c827 with regard to LibreSSL's stupidity,
unconditionally use the old TLS API if building against LibreSSL.
2015-06-25 13:57:07 +00:00
Aaron Jones
cb266283f8 libratbox/openssl: Set explicit cipher list for the client context aswell
This is in furtherance of commits 9799bea4 and 1f384464 and addresses
any potential vulnerability to LogJam <https://weakdh.org/>
2015-05-20 16:41:34 +00:00
Aaron Jones
c86f11da1c Fix regression introduced by previous commit
I really shouldn't copy and paste code.
2015-05-20 10:39:04 +00:00
Aaron Jones
a4c8c82703 Tidy up OpenSSL options code, support new version-agnostic client and server APIs 2015-05-20 02:27:59 +00:00
Jail Bird
29c92cf95f Spring cleaning redux:
- Implemented changes suggested by Jilles
- Remove some unused parameters in functions
- Remove some unused ssl procs
- 63-bit time_t support in TS deltas
- const char * vs char * cleanup
- struct alignment (void *) casts
- signed vs unsigned fixes
- bad memset() call
- Bad LT_MAIN in libratbox
- char -> unsigned char casts for isdigit/isspace/etc calls

Thanks Jilles!
2015-04-20 00:55:20 -05:00
Aaron Jones
614502a63c Generate fingerprints for chained certificates with an unknown root 2015-03-24 05:25:38 +00:00
Aaron Jones
d3806d0503 Use X509_digest() instead of memcpy() to obtain cert fingerprint
This will continue to work even if the OpenSSL developers make the
X509* structure opaque, the current approach will not.
2015-03-24 05:22:25 +00:00
Aaron Jones
1f384464fa Update ciphersuite string to prohibit RC4
This is in accordance with RFC 7465
<https://tools.ietf.org/html/rfc7465>

Also correct the key exchange mechanism strings; these should be
prefixed with 'k'.
2015-03-22 06:14:39 +00:00
William Pitcock
e861902fd9 libratbox: remove RB_PRNG_EGD in its entirety (closes #85) 2015-03-01 01:05:14 -06:00
William Pitcock
4cb0a93d25 libratbox/gnutls: call gnutls_rnd_refresh() to ensure our PRNG is initialized 2015-02-16 17:40:25 -06:00
Attila Molnar
989652e7a8 openssl: Disable session caching 2015-02-09 21:19:09 +01:00
Attila Molnar
6b6a579925 openssl: Disable session tickets 2015-02-09 21:18:32 +01:00
Jilles Tjoelker
7db54a1f97 libratbox: Fix sizeof in two memsets.
This fixes a compiler warning. The necessary fields of the struct sigevent
were initialized so there was no problem.

Submitted by:	Aaron (via IRC)
Reviewed by:	Attila
2015-01-15 23:38:50 +01:00
Jilles Tjoelker
1c864688bb linebuf: Fix possible memory corruption when receiving many CR/LF.
The last byte of balloc.c's block pointer could be changed from 10 or 13 to
0. On amd64, this is not possible. On i386, this is possible and usually
causes a crash soon.
2014-11-05 21:42:35 +01:00
Patrick Godschalk
d072eb2350 Explicitly drop SSLv3 connections (SSL_OP_NO_SSLv3) - might break TLS-capable clients that still depend on SSLv23 handshake 2014-10-26 13:15:30 +01:00
Jilles Tjoelker
8c04f89623 libratbox: Add comment that case fallthrough is deliberate. 2014-09-21 17:44:34 +02:00
Keith Buck
8db50c03e6 BAN: Don't schedule check_klines for 0 seconds in the future.
When receiving bans from a bursting server, if kline_delay is set to 0
(the default), rb_event_addonce will be called to schedule an event for
0 seconds in the future. While this works fine for the fallback
rb_event_run function, the epoll implementation ends up scheduling a
timerfd for the event in the past, which is then never executed.

While fixing this, I also made rb_event_add and rb_event_addonce reject
attempts to add events scheduled for 0 seconds in the future; they're
instead rewritten to run 1 second in the future.
2014-08-17 09:06:01 +00:00
Keith Buck
55abcbb20a Remove trailing whitespace from all .c and .h files.
3134 bytes were removed.
2014-03-03 04:25:47 +00:00
Keith Buck
9e26f0008b libratbox openssl: Don't leak EC_KEY structures. 2014-03-03 01:43:33 +00:00
Keith Buck
1d39324556 Fix a couple more string leaks. 2014-03-02 22:05:30 +00:00
Jilles Tjoelker
ee2d4c2d9d commio: Properly zero a struct msghdr.
This bug is probably not noticeable because all specified fields are
initialized later.
2014-03-02 22:12:19 +01:00
Jilles Tjoelker
e053adc87e commio: Explicitly ignore return value from setsockopt(TCP_DEFER_ACCEPT). 2014-03-02 22:09:08 +01:00
Jilles Tjoelker
6993ae2760 libratbox: Abort if the restart callback returns. 2014-02-28 00:53:13 +01:00
Jilles Tjoelker
3cbcc11195 commio: Add error string for SSL trouble. 2014-02-24 00:06:19 +01:00
Jilles Tjoelker
5ef68b1398 Replace double semicolons with single; place null statement on its own line.
No functional change is intended.
2014-02-23 22:23:34 +01:00
Jilles Tjoelker
899b05d387 balloc: Fix memory leak when get_block() fails. 2014-02-23 22:14:47 +01:00
Keith Buck
784ce5c1cc Remove SSL_OP_NO_COMPRESSION from openssl initialization.
SSL_OP_NO_COMPRESSION was presumably added in an attempt to prevent
information leakage in a manner similar to recent attacks on HTTPS.
However, assuming that IRC is vulnerable to the same class of attacks is
incorrect: the behavior of the IRC protocol (a single long-running
connection) is not the same as that of HTTPS (multiple ephemeral
connections). HTTPS's use of ephemeral connections means that certain
assumptions can be made about the contents of the compression
algorithm's dictionaries and the content exchanged between the client
and server (e.g. the content being nearly the same for each connection),
which is not true for IRC. Additionally, they rely on the attacker being
able to coerce the client into creating many HTTPS connections (and
resending some secret token belonging to the user, along with
attacker-controlled data) each time, none of which is possible with IRC.
Lastly, since compression is no longer performed, this option will
result in leaking the lengths of messages transmitted to and from the
client. This option does reduce CPU utilization on Charybdis servers but
also increases bandwidth consumed.
2014-02-21 09:17:29 +00:00
Jilles Tjoelker
fab79c5d25 libratbox: Fix undefined behaviour advancing pointer beyond end of array.
The C standard does not allow constructing pointers beyond one past the end
of an array. Therefore, if size is an unsigned type (size_t), then
buf + size is never less than buf.

Clang on 32-bit took advantage of the undefined behaviour, causing
segfaults.

Lightly tested.
2014-02-16 16:06:01 +01:00
William Pitcock
bf4e01a427 libratbox: regenerate autotools files 2014-02-08 18:35:24 +00:00
William Pitcock
7aa40f6d2c libratbox/gnutls: add gnutls v3 api compatibility without breaking v2 2014-02-08 18:34:49 +00:00
Jilles Tjoelker
362ef2d9ee openssl: Improve security using options recommanded by Argure.
Note that these are not available in old versions of OpenSSL (like FreeBSD
9.x base OpenSSL), so allow them to be missing.

A side effect may be slightly higher CPU consumption and network traffic.
2014-01-15 22:25:26 +01:00
Jilles Tjoelker
9799bea4a1 openssl: Use cipher list suggested by Argure. 2014-01-15 22:13:47 +01:00
Jilles Tjoelker
cee842a829 openssl: Fix compiler warning. 2014-01-15 22:09:57 +01:00
Jilles Tjoelker
fabc3174fe openssl: Set some sort of session id context.
Without a session id context and if client certificates are used, OpenSSL
fails the handshake if an attempt is made to reuse an old session. Various
clients could not reconnect after a disconnection because of this.

See https://bugzilla.mozilla.org/show_bug.cgi?id=858394#c34 for a bug
report.
2014-01-15 22:04:12 +01:00
William Pitcock
b6e799f5df libratbox/openssl: check that ECDHE is really available on redhat derivatives (closes #43) 2013-11-30 19:55:01 +00:00
Mantas Mikulėnas
320d34a606 libratbox/crypt: fix difference from glibc in sha256_crypt()
rb_crypt() was generating different SHA256 ($5$) hashes than glibc,
making hashes generated with charybdis unusable in ratbox and other
software, and vice versa.
2013-10-23 15:47:28 +03:00
Patrick Godschalk
31d2201519 Have OpenSSL version check use cpp 2013-09-06 20:05:49 +02:00
Patrick Godschalk
81998134b7 Set ECDHE on OpenSSL 1.00+. 2013-09-03 14:16:57 +02:00
Quora Dodrill
97b0e99e2a libratbox/openssl: Fix possible memory leak with SSL certificate fingerprints 2013-08-14 09:54:57 -07:00
Quora Dodrill
f997930e7c Revert "libratbox/openssl: Fix possible memory leak with SSL dertificate fingerprints"
This reverts commit 6ecd598ec0.
2013-08-14 09:54:18 -07:00
Quora Dodrill
6ecd598ec0 libratbox/openssl: Fix possible memory leak with SSL dertificate fingerprints 2013-08-14 09:50:12 -07:00
Antoine Beaupré
e4cf89d403 rerun aclocal to include pkg.m4
this also updates aclocal from 1.11.1 to 1.11.6
2013-07-17 20:26:47 -04:00
Antoine Beaupré
2bd29df9e1 Revert "libratbox: Remove broken gnutls support."
This reverts commit f2d58c6d72.
2013-06-10 12:19:02 -04:00
Antoine Beaupré
608e20b4fa Revert "Remove more gnutls references."
This reverts commit 6a25507e90.
2013-06-10 12:18:43 -04:00
William Pitcock
373d6d79e3 libratbox/crypt: remove blowfish support since it has the stupid advertising clause 2012-09-29 17:28:04 -05:00
William Pitcock
a85566b151 sigio: use siginfo_t instead of struct siginfo, per glibc commit r4efeffc1d5 2012-07-25 10:34:50 -05:00
Aaron Sethman
21acd0961c Disable timerfd/signalfd on openvz, it seems broken
(imported from libratbox r27395 by nenolod)
2012-05-18 21:16:13 -05:00
Jilles Tjoelker
6a25507e90 Remove more gnutls references. 2012-04-18 00:38:44 +02:00
Jilles Tjoelker
271a98feb1 libratbox: Run autoreconf. 2012-04-17 22:35:56 +02:00
Jilles Tjoelker
f2d58c6d72 libratbox: Remove broken gnutls support. 2012-04-17 22:34:11 +02:00
Keith Buck
77444dcc1f gnutls: Fix certfp server link auth. 2012-04-07 21:51:31 +00:00
Keith Buck
3d7890b99c gnutls: Fix ssld crash when executing a SSL connection to another server. 2012-04-07 17:40:22 +00:00
Elly Fong-Jones
2682bc3053 libratbox: use rb_listen(), not listen().
Signed-off-by: Elly Fong-Jones <elly@leptoquark.net>
2012-04-03 01:19:07 -04:00
Jilles Tjoelker
797a29f353 libratbox: Allow defer_accept on FreeBSD.
Note that you must have options ACCEPT_FILTER_DATA in your kernel
configuration or load the accf_data kernel module. The functionality is
not in the GENERIC kernel.
2012-03-20 00:33:31 +01:00
William Pitcock
aa4737a049 libratbox: make defer_accept optional. 2012-03-17 09:48:25 -05:00
William Pitcock
77cb59b319 libratbox: add support for TCP_DEFER_ACCEPT on linux
This allows for some further hardening against synflooding and connection flooding
where no data is actually sent, as the kernel will simply ignore those connections
(well, as far as the ircd is concerned anyway).
2012-03-17 09:16:39 -05:00
Nathan Phillip Brink
422cf3bb86 Detect a potential infinite loop in ./configure in AC_DEFINE_DIR.
Fixes the changes made to AC_DEFINE_DIR in
c74836dc4a.
2012-03-02 01:51:30 +00:00
Nathan Phillip Brink
c74836dc4a Add explicit support for being installed into a system triggered with --enable-fhs-paths.
Add two mechanism for avoiding name-collisions in a system-wide
installation of charybdis. The ssld and bandb daemons, intended to be
directly used by ircd and not the user, install into libexec when
--enable-fhs-paths is set. For binaries which are meant to be in PATH
(bindir), such as ircd and viconf, there is now an option
--with-program-prefix=progprefix inspired by automake. If the user
specifies --with-program-prefix=charybdis, the ircd binary is named
charybdisircd when installed.

Add support for saving the pidfile to a rundir and storing the ban
database in localstatedir instead of in sysconfdir. This is, again,
conditional on --enable-fhs-paths.

Fix(?) genssl.sh to always write created SSL key/certificate/dh
parameters to the sysconfdir specified during ./configure. The
previous behavior was to assume that the user ran genssl.sh after
ensuring that his current working directory was either sysconfdir or a
sibling directory of sysconfdir.
2012-03-01 02:41:09 +00:00
William Pitcock
54bec06e97 Re-libtoolize. 2012-02-04 04:18:48 -06:00
William Pitcock
a949ab1a1c configure: set version to charybdis 3.4.0-dev 2012-02-04 04:14:20 -06:00
Jilles Tjoelker
d74fa5b502 Prefer PATH_MAX to non-standard MAXPATHLEN. 2011-10-28 16:45:18 +02:00
William Pitcock
08d019eb49 libtoolize 2011-05-08 11:20:34 -05:00
William Pitcock
b6d0720c1c configure: Add --with-custom-branding and --with-custom-version options. 2011-05-08 08:55:32 -05:00
Jilles Tjoelker
e732a57bd1 Cope with OPENSSL_VERSION_NUMBER not being a long.
Contrary to the documentation, this is the case on recent FreeBSD at least.
2011-03-20 18:46:32 +01:00
Elizabeth Jennifer Myers
f171dafb59 Add endian test to autoconf and convert crypt to use it. 2011-01-24 21:03:00 -05:00
Elizabeth Jennifer Myers
48dc39f771 Add blowfish to libratbox crypt.
Also change u_int*_t to uint*_t whilst I'm here.
2011-01-17 05:01:11 -05:00
Jilles Tjoelker
af9e5b5ef7 Fix compiler warnings. 2011-01-08 17:40:12 +01:00
Elizabeth Jennifer Myers
08c2568cb9 Add SHA256/SHA512 support to crypt.c and fix up the MD5 component (it seemed to have been broken). In addition, unconditionally use the libratbox crypt. 2011-01-06 01:29:22 -05:00
Jilles Tjoelker
86510a73f9 libratbox: Unbreak compile. 2010-12-15 21:48:26 +01:00
William Pitcock
07e14084eb libratbox: Use the server SSL certificate on outgoing connections. 2010-12-13 22:58:09 -06:00
William Pitcock
56c1612ff3 libratbox: Clean up uses of strcpy(). 2010-11-23 08:52:18 -06:00
William Pitcock
5a241f5466 Autoreconf. 2010-09-28 13:47:23 -05:00
Jilles Tjoelker
918d73d562 openssl: Avoid cutting off OpenSSL errors at 119 chars.
ERR_error_string() is just broken, as it returns at most 119 chars
which means error messages are frequently truncated.
Allow for 511 chars using ERR_error_string_n().
2010-05-09 00:30:51 +02:00
Jilles Tjoelker
74178a388e Fix --disable-balloc.
libratbox r26769
2010-03-05 17:28:47 +01:00
Jilles Tjoelker
2cb7175cfa gnutls: I guess a gnutls_x509_crt_deinit() is needed to avoid memory leak. 2010-02-22 19:16:37 +01:00
William Pitcock
3fe59c99c7 gnutls: Add support for certfp gathering. 2010-02-22 11:13:59 -06:00
Jilles Tjoelker
b2d64e51f0 Fix a memory leak with client certificates. 2010-02-19 16:55:15 +01:00
William Pitcock
7472e54da1 Fix libtool build issue. 2010-02-18 18:11:23 -06:00
William Pitcock
96f4052b50 Run autoreconf. 2010-02-17 23:12:45 -06:00
Jilles Tjoelker
033d16bd2d Add new function rb_get_ssl_certfp() to export-syms.txt. 2010-02-07 20:38:37 +01:00
Jilles Tjoelker
7247337afa Add certfp support to libratbox and ssld.
This lets a user connect with a client certificate, and
passes the certificate's fingerprint to ircd, which
currently just notices it to the user.

A new ssld->ircd message 'F' is used to pass on the
fingerprint.

This is only for OpenSSL for now, not GNUTLS.
2010-01-31 19:04:20 +01:00
Jilles Tjoelker
dcb22e07b9 Fix memory leak and bad error reporting with posix_spawn():
* an initialized posix_spawnattr_t must be destroyed
* posix_spawn() returns an error number instead of setting errno

libratbox trunk r26730
2010-01-22 00:09:56 +01:00
William Pitcock
7083c02121 Run autoreconf. 2010-01-07 16:51:32 -06:00
Jilles Tjoelker
90e960f061 Fix fd passing on FreeBSD/amd64 and possibly Solaris/sparc.
The number of file descriptors in the message was not
determined correctly.
2009-07-10 00:27:01 +02:00
Valeriy Yatsko
ac3b4cb50a Run automake for libratbox. 2008-12-22 12:50:23 +03:00
Valeriy Yatsko
030272f378 Update libratbox. 2008-12-22 12:49:01 +03:00
Valeriy Yatsko
8c5eee4c84 Fix serno.h. 2008-12-22 02:46:26 +03:00
Valeriy Yatsko
00c72a060b Remove .hgignore for serno.h, add serno.h for libratbox. 2008-12-22 02:34:40 +03:00
Jilles Tjoelker
bfa5df1e92 Remove additional wrong declaration for rb_kill(). 2008-12-03 22:57:13 +01:00
Valeriy Yatsko
34f76fdd0f Forgot version.c.SH for libratbox/. 2008-12-03 02:54:08 +03:00
Valeriy Yatsko
3202e24921 Copied libratbox and related stuff from shadowircd upstream. 2008-12-03 02:49:39 +03:00
Valery V Yatsko
5b4e901644 branch merge 2008-08-17 09:33:47 +04:00