1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-06-12 17:14:46 +02:00
Commit Graph

208 Commits

Author SHA1 Message Date
Bram Matthys f0c0feff4f Set PCRE2 limits explicitly (to more sensible defaults), reported by Link420. 2026-06-05 09:43:22 +02:00
Bram Matthys b46c0f20ab OutgoingWebRequest max_size is now also obeyed for file-backed URL API.
And the defines are more clear now (if .max_size is not set by caller.

DOWNLOAD_MAX_SIZE_MEMORY_BACKED: 1M
DOWNLOAD_MAX_SIZE_FILE_BACKED: 50M

The file-backed is mostly a defense-in-depth measure, so we don't
store infinite amounts of data in a download. Even though, in practice,
these - at least at the moment in unrealircd itself - all come from
trusted paths like remote includes.

In url_unreal.c we do the counting ourselves. In url_curl.c we use the
option CURLOPT_MAXFILESIZE_LARGE but this does not ensure it in all
cases so we still do our own counting as well in that file as well.
2026-05-17 10:30:11 +02:00
Bram Matthys 717c9cbfa5 Fix OOB write on URL callback with 2GB+ response. Add new size limit.
The OOB write did not happen on file-backed downloads, such as remote
includes. It only happened for memory-backed requests, which are only
these 4 in standard UnrealIRCd: centralblocklist, central spam report,
other spamreport blocks (eg to dronebl) and the log block with
destination webhook. All those 4 cases are very likely to be trusted
web servers, given the nature of the data you are sending to them.

The fix was to extend the size fields everywhere to 64 bits. It was
applied to both URL backends: url_unreal.c and url_curl.c.

The new API feature is a 'max_size' in OutgoingWebRequest, which
defaults to 1MB. This is only used for memory-backed responses,
so not for real file downloads. This fixes not only the reported
bug but also the case where a rogue webserver was unbounded in
terms of what response it could send back, potentially filling
up gigabytes of server memory.

Reported by Link420.
2026-04-21 19:46:21 +02:00
Bram Matthys 7b48fdca1a Default TLS groups: use tuple syntax with slash to prefer X25519MLKEM768,
even if it costs an extra round-trip due to HRR (Hello Retry Request).
This is IRC after all, where connections live minutes, hours, days,
so that extra round trip is worth it if it means better security.

The TL;DR is: we try harder to use X25519MLKEM768.

The longer story is as follows:

In TLSv1.3, the client will indicate which groups it supports (eg
a list of 4 items) and which ones it speculates to be used (very
often just 2 items). Some TLS clients may not include X25519MLKEM768
in this initial speculation, but only f.e. X25519 and prime256v1
even though X25519MLKEM768 is communicated via their "supported" list.
Without this patch, we would then settle with one of those 2.
With this patch, we will send a Hello Retry Request, allowing to
use X25519MLKEM768.

This is rare, though, most TLS client implementations that have
X25519MLKEM768 will bet on it to be used (the 2 they bet on is
often X25519MLKEM768 & X25519). That's many browsers like Chrome,
OpenSSL, Go, etc.

GnuTLS usually will do this as well, but under some configurations
it may bet on 2 classic crypto to be used. For that specific (type
of) situation, this patch will help to use X25519MLKEM768.
This can be tested with OpenSSL to simulate such an implementation:
openssl s_client -connect 127.0.0.1:6697 -groups X25519MLKEM768:*X25519
Before this patch, it would result in X25519 (because that is the
speculated group, with the asterisk). After this patch it will
cause X25519MLKEM768 to be used.

The tuple syntax is in 3.5.0+ and our UNREALIRCD_DEFAULT_TLS_GROUPS_PRIMARY
with X25519MLKEM768 also requires 3.5.0+ so this is an easy change.

Oh and, this commit comment is rather long for a 1 byte change :D
2026-03-15 07:06:46 +01:00
Bram Matthys 0729382ba2 Rename ::ecdh-curves to groups and add X25519MLKEM768 to group list.
Post-quantum cryptography (PQC). Release notes will follow later.
2025-07-24 14:47:49 +02:00
Bram Matthys 1b4560218a I think this is the correct fix for incorrect TLS ciphers in 6.1.9.
I was dumb: with an RSA cert you need ECDHE-RSA-* and i had
only included ECDHE-ECDSA-*. Long story short: TLSv1.2 didn't work
if you had an RSA certificate. Reported by BlackBishop, and in
hindsight also by Mi_92. Thanks for the quick reports, this should
be a quick fix :-)
2024-11-21 19:01:38 +01:00
Bram Matthys 492152f9ea Default TLS ciphers: drop support for AES in CBC mode, only allow AES w/GCM.
For reference, the established TLS connections at irc*.unrealircd.org
over the past 6 months were:
  14379 TLSv1.3-TLS_CHACHA20_POLY1305_SHA256
    368 TLSv1.2-ECDHE-ECDSA-AES256-GCM-SHA384
    160 TLSv1.2-ECDHE-ECDSA-CHACHA20-POLY1305
      3 TLSv1.3-TLS_AES_256_GCM_SHA384

There is nobody connecting with AES CBC in those statistics
(ECDHE-ECDSA-AES256-SHA256 and ECDHE-ECDSA-AES128-SHA384)
2024-11-17 13:08:46 +01:00
Bram Matthys cda2bcd930 Fix ecdh-curve X25519 missing when using the defaults.
In config.h we had a:
 #if OPENSSL_VERSION_NUMBER >= 0x10100000L
 #define UNREALIRCD_DEFAULT_ECDH_CURVES "X25519:secp521r1:secp384r1:prime256v1"
 #else
 #define UNREALIRCD_DEFAULT_ECDH_CURVES "secp521r1:secp384r1:prime256v1"
 #endif
...which is fine in theory, but openssl headers are not included at that point,
so OPENSSL_VERSION_NUMBER was not defined.

From now on, we have:
 #define UNREALIRCD_DEFAULT_ECDH_CURVES_PRIMARY "X25519:secp521r1:secp384r1:prime256v1"
 #define UNREALIRCD_DEFAULT_ECDH_CURVES_SECONDARY "secp521r1:secp384r1:prime256v1"
...and we try them in that order. If both fail, we exit with an error (like before).
This because X25519 is not available in OpenSSL before 1.1.0 (so really old)
and may also not be available when running in FIPS mode.
2024-11-17 12:08:23 +01:00
Valerie Liu 132ffa91b2 Get rid of old/unused PASS 2 NickServ hack, SASL exists now.
`NickServ` isn't anywhere in the codebase and doesn't do what it says it does re PASS 2 NickServ
2024-01-23 20:40:46 +00:00
Bram Matthys 64ea1d09d6 Move 'reserved clients' stuff to runtime, since 'ulimit -n' could be lower.
This fixes a bug where if you run ./Config with 'auto' file descriptors,
and then have an unusually low 'ulimit -n' of like 150, you would end up
with a negative amount of file descriptors available for use.

This fix moves it from compile-time setting of reserved fd's to runtime
setting.

All this is wrong, by the way, but that is for another major overhaul,
at least this bug is fixed now :D
2023-12-28 09:00:09 +01:00
Bram Matthys cd1b79d3f7 Fetch Central Spamfilter rules with the API Key via alternate URL.
* The [Central Spamfilter](https://www.unrealircd.org/docs/Central_Spamfilter),
  which provides spamfilter { } blocks that are centrally managed, is
  now fetched from a different URL if you have an Central API key set.
  This way, we can later provide spamfilter { } blocks that build on
  central blocklist scoring functionality, and also don't have to reveal
  the central spamfilter blocks to 100% of the world.
2023-11-27 14:33:00 +01:00
Bram Matthys f2f11a4637 Reserve more file descriptors. Eg when 10.000 are available, reserve 250.
Since 10k+ fd's available is the common situation, this means we then have
250 fd's reserved for non-clients, such as HTTPS callbacks and other things.

Previously:
<1024: reserve 4 fd's
1024+: reserve 8 fd's

Now:
<1024: reserve 8 fd's
1024-2047: reserve 16 fd's
2048-10000: reserve 32 fd's
10000+: reserve 250 fd's
2023-10-25 12:08:52 +02:00
Bram Matthys a04295c588 Add set::dns and increase DNS timeout for DNSBL (3000ms first, then on retry 6000ms).
This is quite a bit higher than client DNS lookups (1500ms first, on retry 3000ms)
and is because some DNSBL are reported to be quite a bit slower than ordinary DNS.
(Maybe just some, but.. the higher timeout does not hurt anyone anyway)

Note that all this has no effect on client handshake times, as DNSBL checks are
done in the background. Only side-effect is that if we do get a "late hit" then
you may now see a kill a few seconds after the client is online (which was actually
already possible before too for quick clients, but.. yeah...)

These settings can be overriden via set::dns, these are the defaults:

set {
        dns {
                client {
                        timeout 1500;
                        retry 2;
                }
                dnsbl {
                        timeout 3000;
                        retry 2;
                }
        }
}

When you REHASH we will check if the values are different than the current
c-ares settings and if so, reinitialize the resolver. Reinitializing the
resolver will destroy outstanding DNS requests, eg DNS lookups for clients
currently connecting, but so be it. Not a super-huge issue since changing
this is rare.

Requested by BlackBishop in https://bugs.unrealircd.org/view.php?id=6306
2023-10-11 19:04:06 +02:00
Bram Matthys f932c21751 Bump MODDATA_MAX_LOCAL_CLIENT from 12 to 24. 2023-06-30 20:34:10 +02:00
Bram Matthys c400e9282e Remove CCM ciphers, which are likely unavailable anyway. 2023-04-27 13:16:15 +02:00
Bram Matthys ee1f8d84a0 Require TLSv1.2 or later and require a modern cipher with forward secrecy.
This also fixes a bug with OpenSSL 3.x where, when the ircd was
configured to still allow old TLSv1.0 / TLSv1.1, it would still
only allow TLSv1.2+.

But, as said, allowing TLSv1.0/TLSv1.1 is now no longer the default.

See release notes for more information or the documentation at
https://www.unrealircd.org/docs/TLS_Ciphers_and_protocols
2022-11-27 17:04:22 +01:00
Bram Matthys ca36a5256c Some text updates UnrealIRCd 5 -> UnrealIRCd 6 2021-10-31 07:20:57 +01:00
Bram Matthys b00743fa79 Bump moddata slots
[skip ci]
2021-09-25 10:24:32 +02:00
Bram Matthys 4cea88645c Modularize member modes (vhoaq).
Still need to clean up a bit after this, but it passes all tests :)
2021-09-13 18:44:18 +02:00
Bram Matthys 13dc17f5dc Code cleanup: remove unused structs and variables. 2021-09-03 21:07:38 +02:00
Bram Matthys 89b9c2ec32 Deal with HTTP redirects, and add DOWNLOAD_MAX_REDIRECTS to include/config.h
which defaults to 2. Make it use this value for both curl and non-curl.
Previously (with curl) it was set to 1, and nobody complained...
2021-08-21 14:05:43 +02:00
Bram Matthys 090fe76739 URL: Make the curl and non-curl implementation use the same timeouts.
These are set in include/config.h to what they already were before:
15 seconds for the connect timeout, 45 for the complete transfer.
2021-08-21 09:37:14 +02:00
Bram Matthys 532a9becda Massive renames of SSL/TLS and SSL to TLS. People should know the term by now :D 2021-08-10 09:07:32 +02:00
Bram Matthys 05aeba9ba9 Get rid of Debug(()) function calls. I never use it anyway. 2021-07-12 18:54:38 +02:00
Bram Matthys e126d924a5 Somehow DEBUGMODE was turned on by last commit, now off again by default. 2021-06-02 19:31:05 +02:00
Bram Matthys 40bc3ef8cc Bump version to 5.2.0-git. This is still work in progress.
Note that we are on the 'unreal52' branch now and have left 'unreal50'
2021-06-02 15:27:14 +02:00
Bram Matthys d4e0ee9431 *NIX: Bump default MAXCONNECTIONS from 8192 to 16384.
That is, when in "auto" mode, which is like for 99% of the users.
NOTE: the sytem may still limit the actual number of FD's to
a lower value, depending on the value of "ulimit -n -H".
2021-02-01 13:27:08 +01:00
Bram Matthys 3f5ea851cb Do a better job at detecting ASan 2019-09-23 08:14:41 +02:00
Bram Matthys 4d277ccef8 Clean up and comment SocketLoop. Also preparations for later. 2019-09-22 14:20:22 +02:00
Bram Matthys ffe5abe30b ModData: moddata_localvar -> moddata_local_variable,
moddata_globalvar -> moddata_global_variable,
and the just-added moddata_localclient -> moddata_local_client
..all this so it's more consistent
2019-09-15 09:47:54 +02:00
Bram Matthys b2f32c1746 Add moddata_localclient(), which is for locally connected clients only.
Make the silence module use this.
2019-09-15 09:26:54 +02:00
Bram Matthys ca2239827e Get rid of NICK_GB2312/NICK_GBK/NICK_GBK_JAP in config.h. I am not aware
of anyone actually using these. So running with this was rather untested
(if it worked at all, which I doubt).
2019-09-09 16:20:26 +02:00
Bram Matthys 7d4b7c2fed Get rid of stricmp/strnicmp (use strcasecmp/strncasecmp) 2019-09-09 16:13:32 +02:00
Bram Matthys 9636f83a2b Always assume POSIX signals (on non-Windows, that is). 2019-09-09 16:08:18 +02:00
Bram Matthys 05af50d1fc Remove some HPUX stuff. We don't support or test this so leaving
this in the source gives a false impression. Also some ULTRIX
stuff (from 1995???).
2019-09-09 15:53:44 +02:00
Bram Matthys 1183e88077 Remove old SunOS / Solaris / AIX code.
And some other outdated things for non-POSIX systems...
2019-09-09 15:46:19 +02:00
Bram Matthys d434cf948b Get rid of bcmp/bcopy/bzero. 2019-09-09 14:41:40 +02:00
Bram Matthys d357ef8957 More config.h cleanups. Lower kill chase time limit from 90 to 30
which seems more reasonable to me.
2019-08-24 19:57:40 +02:00
Bram Matthys 153e38be10 Get rid of "max sendq" ./Config question, which actually was only
setting the default class::sendq that pretty much everyone overrides
in class (isn't this even required? ;D).
Rename to DEFAULT_SENDQ since we have DEFAULT_RECVQ too.
2019-08-24 19:50:39 +02:00
Bram Matthys d19b4e70ad Remove old and broken option SHOW_INVISIBLE_LUSERS 2019-08-24 19:45:26 +02:00
Bram Matthys d06715d9ee REMOTEINC_SPECIALCACHE is no longer optional 2019-08-24 19:41:14 +02:00
Bram Matthys 9e02ca2b3c More FORMAT_STRING() checking, get rid of old (non-)USE_VARARGS stuff.
Fix some more bugs (type differences) when compiling in DEBUGMODE.
2019-08-24 19:37:25 +02:00
Bram Matthys 2a7fc8042d Add new moddata types: MODDATA_LOCALVAR and MODDATA_GLOBALVAR. Untested.
Code using it will soon follow (and then it will be tested :D)
2019-06-28 18:35:37 +02:00
Bram Matthys 5ebd096f16 Initial implementation of message-tags from May 5, 2019.
This also includes buffer modifications to have a larger read buffer
and IRCv3 implementations (partial or not) for:
labeled-response, msgid, server-time, batch and account-tag.

As said, it is the initial and partial implementation.
There are still various FIXME's and TODO's, the API of various
functions may still change (actually that is true for the next
months, even) and some stuff is currently in the core that will
be moved to modules.
2019-05-12 13:46:44 +02:00
Bram Matthys 5c30d1af6d * Badword blocks now use PCRE2 if using regex at all (rare,
usually the fast badwords system is used instead)
* Code deduplication in src/modules/{chanmodes,usermodes}/censor.c
  to src/match.c -- which may be moved later again to efuncs.
* Add --without-tre:
  This means USE_TRE will be enabled by default right now
  but if using --without-tre it will be undef'ed. This so we
  can prepare for the TRE phase-out in 2020.
* Remove include/badwords.h, put contents in include/struct.h
2019-04-05 18:19:23 +02:00
Bram Matthys 6d3a98653e The maximum number of clients (MAXCONNECTIONS) no longer defaults to 1024.
The new question in ./Config now defaults to 'auto' (both for new installs
and for upgrades). You can still specify a manual limit but it is no longer
recommended.
A MAXCONNECTIONS of 'auto' means - at present - that UnrealIRCd will try
to set a limit of 8192. This is quite a bump from the original 1024.
On systems where this is not possible we will simply use the highest amount
possible, such as 4096 on many systems, or 1024.
In fact, we now no longer error when MAXCONNECTIONS is higher than the
'ulimit -n' limit but will adjust ourselves to the limit.
Only if the effective limit is below 100 we will print out a fatal error
since running in such a scenario is highly discouraged.
The reason for this change is that nowadays with drone attacks we may need
to be able to handle more concurrent sockets. Also, many Linux distro's
have a default setting of unlimited or 4096 nowadays, out of the box.

For people packaging UnrealIRCd (not end-users):
The ./configure --with-fd-setsize=xx option was removed and the
optional(!!) --with-maxconnections=xx option has been added.
We recommend you NOT to pass this option. Not passing it means that
the previously mentioned 'auto' mode will be used, which is likely
best for most users.

Module coders:
Although it is unlikely you accessed the 'MAXCLIENTS' variable,
if you did, it is now called 'maxclients' (lowercase) since it is
adjusted at runtime and no longer a macro.
2019-03-25 15:43:26 +01:00
Bram Matthys 4490b8744e Use HAVE_RLIMIT instead of FORCE_CORE. And get rid of error message. 2019-03-24 15:50:56 +01:00
Bram Matthys 9f4296d648 New set::anti-flood::max-concurrent-conversations which configures the
maximum number of conversations a user can have with other users at the
same time. Until now this was hardcoded at limiting /MSG and /INVITE to
20 different users in a 15 second period. The new default is 10 users,
which serves as a protection measure against spambots.
See https://www.unrealircd.org/docs/Set_block#maxcc for more details.
2019-02-04 09:52:08 +01:00
Bram Matthys 7d68ea0570 Update default ciphers, or actually only the ones not providing PFS, by
preferring AES-256 over AES-128 (in contrast to the Mozilla "intermediate"
profile which prefers AES-128). Again, this only affects non-PFS cases, as
all modern clients with PFS already had CHACHA20 and AES-256 negotiated.
The portion of non-PFS clients should only be few percent, if any.
I was actually considering removing non-PFS ciphersuites but it seems a bit
early to do so, at least not without more research on affected clients.
2019-01-11 09:19:44 +01:00
Bram Matthys a7af69b887 Use same ciphersuite as decided earlier. 2018-09-21 09:11:09 +02:00