1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-06-25 20:26:38 +02:00
Commit Graph

2778 Commits

Author SHA1 Message Date
Bram Matthys ce47440abd Make config_detect_duplicate() externally accessible. Fix some coverity warnings,
mostly with regards to memory leaks if duplicate config directives are used.
Eg using allow::password twice in the same allow block, or using
link::outgoing::tls-options twice in the same link block. Unusual stuff.
2025-01-26 13:23:32 +01:00
Bram Matthys 42caa34b5c Fix small memory leak if running in DEBUGMODE (mostly for me :D). 2024-12-11 18:25:55 +01:00
Bram Matthys 1f57a606a4 Make binarytohex() from src/misc.c available and use it in certfp code. 2024-11-27 12:37:27 +01:00
Bram Matthys 6c98f7224a Always try to maintain chronological order in chat history, and optimize stuff.
Previously if a new history item was added (because someone sent a message)
we would always append at the end of chat history buffer of the channel.
Now we put the message at the position decided by the "time" message tag,
which could be at the end but also slightly before that.
* Upside: should result in a consistent chat history on all servers
* Downside: if your server time is off for several seconds then it
  could look a little weird. Then again, it would already have looked weird
  in real live chat with timestamps and when replaying chat history probably.

Also add some simple optimizations: in the log line object we now have direct
pointers to the msgid and time strings, so the code doesn't need to do a
find_mtag() all the time. This should lower CPU usage during log playback
and also makes things more simple in the source code.

I did some testing with various history injection variants but this needs
more extensive testing.
2024-11-27 10:34:07 +01:00
Bram Matthys 47e81fe7d3 Set version to 6.1.10-git 2024-11-24 09:46:21 +01:00
Bram Matthys e782748b40 ** UnrealIRCd 6.1.9.1 ** 2024-11-21 19:30:01 +01: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 7b0228a2c8 ** UnrealIRCd 6.1.9 ** 2024-11-20 11:17:58 +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
Bram Matthys 08435a5674 Bump version to 6.1.9-git 2024-11-17 09:55:05 +01:00
Bram Matthys 18b171a071 Some more missing include/windows/setup.h defines.
+#define HAS_ASN1_TIME_diff
+#define HAS_SSL_CTX_SET_MIN_PROTO_VERSION
+#define HAS_SSL_CTX_SET_SECURITY_LEVEL
+#define HAS_X509_check_host
+#define HAS_X509_get0_notAfter

In practice, this only adds that we now do certificate expiry checks
and give warnings, like on *NIX.

The HAS_X509_check_host is good because then OpenSSL/LibreSSL code is
used instead of the one we have from cURL and the ssl conservatory.
To be honest I wanted to rip out this fallback completely at first,
but let's do that in next major version of UnrealIRCd and not during
an existing series.

The HAS_SSL_CTX_SET_* would have given an admin the option to downgrade
to TLSv1.0 or TLSv1.1 but LibreSSL no longer builds with these since
LibreSSL 3.8.1, which is sensible, so... no actual change there.
I'll document the behavior in the docs (wiki), though.

Also the previous claim in b653c68df0 with
regards to what curves were actually enabled in our LibreSSL UnrealIRCd 6
builds was incorrect, an hour ago I claimed X448 would show up as an extra,
but that is not the case (that was with OpenSSL). The correct statement is:
"This also meant the default curves that were offered were up to LibreSSL,
 which meant the following list in practice:
  Elliptic curves offered:     prime256v1 secp384r1 X25519
 Instead of:
  Elliptic curves offered:     prime256v1 secp384r1 secp521r1 X25519"

So it was only missing secp521r1. Nothing major.
2024-11-09 12:55:15 +01:00
Bram Matthys b653c68df0 Fix error on Windows when trying to set set::tls::ecdh-curves.
"[error] ecdh-curves specified but your OpenSSL/LibreSSL library does not
 support setting curves manually by name. Either upgrade to a newer library
 version or remove the 'ecdh-curves' directive from your configuration file"

This also meant the default curves that were offered were up to LibreSSL,
which meant the following list in practice:
 Elliptic curves offered:     prime256v1 secp384r1 secp521r1 X25519 X448
Instead of:
 Elliptic curves offered:     prime256v1 secp384r1 secp521r1 X25519

Not that X448 is considered bad, it just didn't match what we claimed in
the docs at https://www.unrealircd.org/docs/TLS_Ciphers_and_protocols

Fixed by: #define HAS_SSL_CTX_SET1_CURVES_LIST
2024-11-09 12:01:47 +01:00
Bram Matthys 30b9f66f71 ** UnrealIRCd 6.1.8.1 ** 2024-10-17 18:30:07 +02:00
Bram Matthys 33276fb2ee ** UnrealIRCd 6.1.8 ** 2024-10-11 07:22:51 +02:00
Bram Matthys 665dd8584a ** UnrealIRCd 6.1.8-rc1 ** 2024-09-27 10:19:18 +02:00
Bram Matthys 7d37795353 Don't list security groups by default, add 'public <yes|no>'
* [Security group blocks](https://www.unrealircd.org/docs/Security-group_block)
  are now hidden in lists by default. If you want the security group to be shown
  in things like `MODE #channel +b ~security-group:x` (which shows a list)
  then you need to use `public yes;`. The default security groups
  like known-users, webirc-users, etc. are public by default.
2024-09-23 13:11:24 +02:00
Bram Matthys 7dc3c230a7 Now that we support $variables, add set::oper-vhost so you can set a default
vhost for opers, such as: set { oper-vhost $operclass.admin.example.net; }

If the oper has an oper::vhost then that one will override.

https://www.unrealircd.org/docs/Set_block#set::oper-vhost
2024-09-20 17:54:39 +02:00
Bram Matthys 9a2d54cd01 Support $variables in oper::vhost (for variables see previous commit)
Eg: vhost "$operlogin@$operclass.example.net";

Also add potentially_valid_vhost() function which can be used in
config code to ignore invalid $vars. Then at runtime you use the
real valid_vhost() function after variable expansion by
unreal_expand_string().
2024-09-20 17:26:16 +02:00
Bram Matthys 4557036cd6 Move unreal_expand_string() to an efunc so all code can access it
and use it not only from vhost { } block code but also for like
blacklist::reason.

This so the same variables with the same names are available at
those places.

Supported are:
$nick, $username, $realname, $ip, $hostname, $server, $account,
$operlogin, $operclass, $country_code (xx for unknown),
$asn (0 for unknown).
2024-09-20 17:13:23 +02:00
Bram Matthys 55c04d9887 vhost: move struct as well, reorder and document. 2024-09-20 14:51:50 +02:00
Bram Matthys fe751fdc9d Move all vhost { } block handling to vhost module.
* Convert to use module-based config handling
* Split part of VHOST command into do_vhost() for later
* Use AppendListItem instead of AddListItem so they are in config-order.
  This is not really important atm but will matter later if we go auto.
* No other code changes at this point
2024-09-20 14:45:52 +02:00
Bram Matthys c39d763e00 Move 416 lines from src/misc.c to src/modules/quit.c: exit_client() etc.
This so if there is ever an issue, we can hot-patch it. This affects
exit_client(), exit_client_fmt(), exit_client_ex(), banned_client(),
and various (internal) help functions.

This also means you cannot call these functions during TEST/INIT (eg
during REHASH) since the 'quit' module which provides these modules
may not be loaded yet. I don't think that's a situation/problem but
this needs some more testing.
2024-09-15 17:45:25 +02:00
Bram Matthys 2ef39497c7 Similar to previous commit, move maxperip stuff from core to module.
This was in src/hash.c, src/list.c and src/modules/stats.c.
Now all in src/modules/nick.c... or should this go into a new module?

Again, this needs some more testing, like previous commit.
2024-09-14 20:18:22 +02:00
Bram Matthys 710afe7cc7 Move throttling code from src/hash.c to src/modules/connect-flood.c
Better to have this all in one place. Though, must admit, the
config checking is still in src/conf.c and a bit of a hassle to move.

Some testing may be wise to see if everything still works ;)
2024-09-14 19:55:43 +02:00
Bram Matthys fdfe5ba482 Remove raw_client_ip() since we now have client->rawip. 2024-09-14 19:19:21 +02:00
alice 255dfe6bf7 Fix redefinition of struct RPCClient within struct.h, which occurs if you have an old compiler. (#296)
Reported in https://bugs.unrealircd.org/view.php?id=6469 by hughmungus
2024-09-10 14:31:33 +00:00
Bram Matthys ee1d6818b4 Add +b/+e/+I ~inherit:#channel to inherit channel bans from another channel
Several notes:
* This only checks on-JOIN (not on nick change, message, etc)
  for performance reasons
* If the #channel in ~inherit:#channel also contains ~inherit
  entries then those are not processed (no recursion and no looping)
* Only a limited number of ~inherit entries is permitted.
  This will be moved to set:: items in a future commit so you
  can set different amounts for +b/+e/+I ~inherit.
* This is work in progress, UnrealIRCd or the entire world could explode
* Documentation will follow later

Developers:
* Sadly, clean_ban_mask() needed to be changed to have two more
  parameters, 'ban_type' and 'channel' were added at different positions.
  This because the module needs the ban type (EXBTYPE_BAN, EXBTYPE_EXCEPT,
  EXBTYPE_INVEX) and channel because it rejects based on number of
  existing ~inherit entries in the channel... and while is_ok() is called
  for local clients and has all this information, for services clients
  is_ok() is not called so the only way to reject the +beI is through
  xxx_conv_param() which comes from clean_ban_mask().
2024-09-07 21:02:15 +02:00
Bram Matthys 4f3e524602 Add function set_client_ip() and call HOOKTYPE_IP_CHANGE there if needed.
This to replace the scattered IP setting. It is very important to always
use set_client_ip() from this point. Everywhere!

Also, in addition to client->ip, this adds client->rawip that contains
the IP in network byte order. In older UnrealIRCd versions we always had
the raw IP but not the IP as a string, so we moved to IP as a string,
but it can be useful to have both in terms of optimizations.
Of course, then the client->ip and client->rawip always need to 100% match,
hence the set_client_ip().

This also changes IsIPV6() to do A BUGFIX, it changes it from:
* if local user is the user connected over IPv6? Otherwise, does it have ':' in the IP?
To:
* check if the IPv6 flag is set (which is set if IP contains ':')
This may seem insignificant but it means that for spoofed IP addresses,
such as WEBIRC or transparant proxy, we use the correct transport.
Previously, if the proxy was IPv6 then even if the spoofed user was using
IPv4, the ident check would still be tried over IPv6. That sort of fun.
From now in, in such a situation client->local->socket_type will be
SOCKET_TYPE_IPV6 but since client->ip (and rawip) will contain IPv4
the IsIPV6() will actually return false, as it should be.

Also, in the HOOKTYPE_IP_CHANGE, enforce that if HOOK_DENY is returned,
the the user is killed by dead_link(). The user must be killed because
that is what we expect, and you cannot use exit_client() because from
some code paths that would be too much freed structures / hassle,
as a comment in src/modules/connect-flood.c correctly states:
/* There are two reasons why we can't use exit_client() here:
 * 1) Because the HOOKTYPE_IP_CHANGE call may be too deep.
 *    Eg: read_packet -> webserver_packet_in ->
 *    webserver_handle_request_header -> webserver_handle_request ->
 *    RunHook().... and then returning without touching anything
 *    after an exit_client() would not be feasible.
 * 2) Because in HOOKTYPE_ACCEPT we always need to use dead_socket
 *    if we want to print a friendly message to TLS users.
 */
2024-07-20 12:22:26 +02:00
Bram Matthys 191e6ac162 Bump version to 6.1.8-git 2024-07-20 11:53:47 +02:00
Bram Matthys a686254540 ** UnrealIRCd 6.1.7.1 ** 2024-07-18 10:25:06 +02:00
Bram Matthys b39b953b8e Add debugging code to trace source of io.BUG_FD_SETSELECT_OUT_OF_RANGE (fd=-2). 2024-07-18 08:10:49 +02:00
Bram Matthys 4ab1a4d128 ** UnrealIRCd 6.1.7 ** 2024-07-16 12:36:53 +02:00
Bram Matthys 33e9b65ce4 ** UnrealIRCd 6.1.7-rc1 ** 2024-07-13 09:46:03 +02:00
Bram Matthys e5e000508e UNIX sockets: show in boot screen and properly when adding/removing listen block
Was previously shown as like :0 when removing/adding a listen block
with a UNIX socket. Now shows the file, as you would expect.

And in the boot screen it was like:
[info] IPv4: 127.0.0.1:6697(TLS), 127.0.0.1:6667
[info] IPv6: *:6667, *:6697(TLS)
And now also:
[info] Unix Sockets: /home/unrealircd/unrealircd/data/rpc.socket
2024-07-13 08:11:54 +02:00
Bram Matthys 1b4f987ab7 Move displaying of ASN in WHOIS to separate RPL_WHOISASN (569)
This is the numeric that the inspircd third party module uses
https://github.com/inspircd/inspircd-contrib/blob/master/4/m_asn.cpp
and it does not seem taken at
https://defs.ircdocs.horse/defs/numerics.html or
https://www.alien.net.au/irc/irc2numerics.html

This also means AS displaying is now separately configured via
set::whois-details::asn. By default only IRCOps can see it.
2024-07-12 12:17:39 +02:00
Bram Matthys f33a0d2c1b Add initial ASN support:
* Including default download via unrealircd.org
* Shown in WHOIS - currently in RLP_WHOISCOUNTRY, not sure
  if that is correct.
* Shown in connect notices [asn: XYZ] [asname: BLAH BLAH]
* Shown in json user expansion (JSON logging and JSON-RPC)
* Only via geoip_classic at the moment
* Structs and serializing in geoip_base done
* Extbans not added yet
2024-07-12 10:31:52 +02:00
Bram Matthys 9cc2918d5f Make set::spamfilter::except a Mask item
* [set::spamfilter::except](https://www.unrealircd.org/docs/Set_block#set::spamfilter::except)
  is now a [Mask item](https://www.unrealircd.org/docs/Mask_item) instead of
  only a list of exempted targets. A warning is created to existing users
  along with a suggestion of how to use the new syntax. Technically, this is
  not really new functionality as all this was already possible via
  the [Except ban block](https://www.unrealircd.org/docs/Except_ban_block)
  with type spamfilter, but it is more visible/logical to have this also.
2024-07-06 10:09:35 +02:00
Bram Matthys e03a5dfd5f Support ::destination and ::exclude-destination in security groups / mask items
at selected places (there needs to be explicit code in place to handle this).
At the moment it is supported at two places only:
* For spamfilters (was already possible via crules via ::rule with
  a destination('xyz') but now non-crule destination "#xyz"; works as well, eg:
  spamfilter {
          ...
          except {
                  destination "#main";
          }
  }
  Note that if you want to exempt a destination in all spamfilters,
  we already have set::spamfilter::except for that!
* In restrict commands for like channel-message and such:
  set {
          restrict-commands {
                  channel-message {
                          except {
                                  connect-time 600;
                                  destination "#test";
                          }
                  }
           }
  }

Allow passing a crule_context via user_allowed_by_security_group_context()
and make user_allowed_by_security_group() call that.

Actually document spamfilter::except online in the docs (yeah you
won't see it in this commit, just mentioning...)

And yeah, by now i wonder if we should really call it crule_context
since it is more like a security group matching context, but.. whatever.
2024-07-06 09:16:53 +02:00
Bram Matthys a804b24150 Add set::hide-killed-by which shortens the quit to "Killed (Reason)".
* New option [set::hide-killed-by](https://www.unrealircd.org/docs/Set_block#set::hide-killed-by):
  We normally show the nickname of the oper who did the /KILL in the quit message.
  When set to `yes` the quit message becomes shortened to "Killed (Reason)".
  This can prevent oper harassment.

Suggested by PeGaSuS in https://bugs.unrealircd.org/view.php?id=6425
2024-07-06 08:12:11 +02:00
Bram Matthys 0b7162f3cf Free old operclass blocks on REHASH (memory leak)
This wasn't caught by Address Sanitizer because we simply never removed
it from the linked list, and thus it was a reachable pointer.

Found this bug when adding the rpc-class { } stuff.
2024-07-05 11:11:13 +02:00
Bram Matthys b9de933378 Similar to oper and operclass, this adds an rpc-class block.
This so you can restrict the JSON Methods that can be called, eg:

rpc-class limited {
    privileges {
        server { list; get; }
        channel { list; get; }
        user { list; get; }
    }
}

rpc-user xyz {
    match { ip 127.0.0.1; }
    password "test";
    rpc-class limited;
}

NOTE: This is work in progress
1) Things are NOT yet fully contained, as i need to lock down
   rpc.add_timer still :)
2) Some more work, eg rpc.info would be nice to show some
   information about the restriction (??)
3) Need to fix a memory leak
4) Possibly more
2024-07-05 10:21:45 +02:00
Bram Matthys bc7c69dd20 Make ban user::mask and require authentication::mask a Mask item. Finally.
As requested in
https://bugs.unrealircd.org/view.php?id=6159 by PeGaSuS
https://bugs.unrealircd.org/view.php?id=6319 by BlackBishop
https://bugs.unrealircd.org/view.php?id=6397 by Valware

The mask item https://www.unrealircd.org/docs/Mask_item
means you can use all the power of mask items and security groups and
multiple matching criteria.

This requires a bit more testing as username/hostname are NULL now
so some code paths may have to be adjusted. The function call to add
server bans has changed too. And, really need to check that soft bans
are not broken... because they might be ;D
2024-06-30 19:06:37 +02:00
Bram Matthys f6643f283c Support spamreport::url for type central-spamreport too.
This so you can get the same spamreport data to your own custom system.
It works similar to set::central-blocklist::url but then on a
spamreport { } basis which is better, since then you can still
submit to UnrealIRCd central spamreport too.

So you can have two blocks:
spamreport unrealircd { type central-spamreport; }
spamreport custom { type central-spamreport; url 'https://www.example.org/xyz'; }

And then a /SPAMREPORT or 'report;' action will report it to BOTH.

Requested by Chris
2024-06-26 14:01:13 +02:00
Bram Matthys 5e46692bb2 Bump version to 6.1.7-git 2024-06-14 10:00:37 +02:00
Adrian Sandu 2c49668db8 Add option set::tls::certificate-expiry-notification (#286)
This way you can disable the check and notification about TLS certificate expiring. The check is (still) on by default.
2024-06-14 07:57:33 +00:00
alice a77ff1f2c8 Fix OPEROVERRIDE_VERIFY option. (#278)
Reported by hnj in https://bugs.unrealircd.org/view.php?id=6418

Appears to have been introduced as part of the 6.x refactor of secret/private channel modes in 8066c13876

Also adjust message for ERR_OPERSPVERIFY to include channel name.
This is to correspond closer to other similar numerics around this area, as well as agreeing with the definition within modern.
2024-06-14 07:22:19 +00:00
Bram Matthys dd2242b6a8 ** UnrealIRCd 6.1.6 **
The release will be published tomorrow (2024-06-14).
2024-06-13 19:14:28 +02:00
Bram Matthys f2c92ee4b0 ** UnrealIRCd 6.1.6-rc1 ** 2024-06-07 18:22:48 +02:00
Bram Matthys 3c3d8a5605 Add user_matches_extended_server_ban() which works similar to
match_user_extended_server_ban except that it works by name/value.

This can then be used by crules or in other mods, like:
user_matches_extended_server_ban(client, "country", "NL");

If the performance impact isn't too bad (of the extra work) then
this prevents duplicate code in the handler for things like
that: account, country, certfp, and whatever we add in the future..
2024-05-20 08:54:53 +02:00