Commit Graph
1296 Commits
Author SHA1 Message Date
Alexey Sokolov 3d96465fc0 Merge pull request #2054 from kitkatt7/zncstring-randomstring-csprng
zncstring: generate RandomString with a CSPRNG instead of rand()
2026-10-19 18:55:42 +01:00
Alhuda Khan 71dd0e0f88 zncstring: use openssl RAND_bytes for RandomString when available 2026-10-18 12:22:56 +05:30
Alexey Sokolov 881de2f4d5 Merge pull request #2053 from kitkatt7/formattime-usec-pad-underflow
utils: fix size_t underflow in FormatTime %f padding
2026-10-18 00:53:43 +01:00
Alhuda Khan 5916955b80 zncstring: generate RandomString with a CSPRNG instead of rand() 2026-10-14 15:10:53 +05:30
Alhuda Khan 16908dc4aa utils: fix size_t underflow in FormatTime %f padding 2026-10-14 11:32:00 +05:30
Alhuda Khan 942e458bf5 cast to unsigned char for ctype calls on signed-char input 2026-10-11 23:54:28 +05:30
RealKindOne d6c2c32de8 Stop ZNC from prepending '#' if missing in join command.
Fixes #1794
2026-09-13 14:20:36 -04:00
Alexey Sokolov 76cdad9e6a Merge branch '1.10.x' 2026-09-13 10:54:57 +01:00
Alexey Sokolov 4b88c64c6e Fix crash while unloading modules
The bug allowed unprivileged users to trigger use-after-free while
unloading modules

Note that the fix requires a slight API change for OnEmbeddedWebRequest:
now the callers (webadmin is the only known caller of it) call it via
DoEmbeddedWebRequest() instead. The modules which implement this hook
need no changes.

CVE-2026-82373

Found by Claude from Anthropic, reported by Ada Logics.
2026-09-12 19:08:21 +01:00
ZNC-Jenkins a63fe12c63 Update translations from Crowdin for bg_BG da_DK de_DE el_GR es_ES fr_FR id_ID it_IT nl_NL pl_PL pt_BR pt_PT ro_RO ru_RU tr_TR 2026-08-18 00:26:44 +00:00
RealKindOne 4fbccd0cc4 Fix MOTD buffering to prevent duplicate 376 messages after rate limiting
Added m_bMotdBegun flag to track MOTD state. MOTD lines (372, 376) are now only
buffered if MOTD has begun (375/422), and 376 itself is not buffered.

The flag is reset on 263 rate limit responses to prevent repeat 376 messages.

Fixes #1460
2026-07-23 04:38:56 -04:00
ZNC-Jenkins b98d7a9389 Update translations from Crowdin for bg_BG da_DK de_DE el_GR es_ES fr_FR id_ID it_IT nl_NL pl_PL pt_BR pt_PT ro_RO ru_RU tr_TR 2026-07-23 00:27:10 +00:00
Alexey Sokolov 7d4879ab26 Cleanup previous PR, add integration test for multiple joins 2026-07-22 09:24:52 +01:00
RealKindOne d2fc5d550a Apply fixes for IsParting() pull request. 2026-07-22 01:58:01 -04:00
RealKindOne a0d58c8fed Add IsParting() flag to track PART commands waiting IRCd response.
Fixes potential desync where ZNC marks channel as parted before server
confirms the PART, which could cause issues if the server never replies.

Add unittests and integration tests.
2026-07-21 03:24:38 -04:00
RealKindOne 3ceae3ad26 Fix part/join not working when a client sends '/cycle' or '/hop' command. 2026-07-20 04:33:04 -04:00
RealKindOne 13268feefe Revert "Revert "Fix JOIN command not joining detached channels on other clients.""
The revert was made by mistake due to misreading of 'znc -D'.

This reverts commit 6d470db241.
2026-07-20 04:25:50 -04:00
ZNC-Jenkins 05ca60e22a Update translations from Crowdin for bg_BG da_DK de_DE el_GR es_ES fr_FR id_ID it_IT nl_NL pl_PL pt_BR pt_PT ro_RO ru_RU tr_TR 2026-07-20 00:26:18 +00:00
Alexey Sokolov 6d470db241 Revert "Fix JOIN command not joining detached channels on other clients."
This reverts commit ba32b092e9.

It broke /hop (/part+/join) due to race with server
2026-07-19 20:35:31 +01:00
ZNC-Jenkins 512d35233b Update translations from Crowdin for bg_BG da_DK de_DE el_GR es_ES fr_FR id_ID it_IT nl_NL pl_PL pt_BR pt_PT ro_RO ru_RU tr_TR 2026-07-03 00:26:28 +00:00
RealKindOne ba32b092e9 Fix JOIN command not joining detached channels on other clients. 2026-07-01 13:59:18 -04:00
ZNC-Jenkins e8fd8ae164 Update translations from Crowdin for bg_BG da_DK de_DE el_GR es_ES fr_FR id_ID it_IT nl_NL pl_PL pt_BR pt_PT ro_RO ru_RU tr_TR 2026-07-01 00:26:19 +00:00
Alexey Sokolov 5bd5ecc5b8 Remove old ssl compatibility code 2026-06-29 19:19:40 +01:00
Ravi Kant Sharma 94bcf919e1 Fix build error with OpenSSL 4 (#2024)
More details here https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1138356
2026-06-29 19:03:27 +01:00
ZNC-Jenkins 2cc7197c38 Update translations from Crowdin for bg_BG da_DK de_DE el_GR es_ES fr_FR id_ID it_IT nl_NL pl_PL pt_BR pt_PT ro_RO ru_RU tr_TR 2026-06-10 00:26:19 +00:00
Alexey Sokolov e7919287fe Merge pull request #2021 from dxbjavid/copy-preserve-mode
fileutils: open Copy() destination at the source's mode
2026-06-09 23:24:33 +01:00
TehPeGaSuS d4f5d5f9e8 Enable SSL by default in znc --makeconf when connecting to servers (#2022)
* Enable SSL by default in ZNC configuration when connecting to servers

* Change default port from 6667 to 6697 in znctest

* Update SSL variable initialization with preprocessor checks

Refactor SSL configuration to use preprocessor directives.

* Fix comment formatting in znc.cpp

Fix extraneous double tab that slipped into the commit
2026-06-09 08:21:01 +01:00
dxbjavid 01678166a8 fileutils: force owner write while copying read-only sources
Opening the destination at the source's exact mode breaks when the
source lacks owner write (e.g. r-xr-xr-x): the create still works but
the overwrite path can't reopen such a destination for writing. Force
owner read+write while copying and let the trailing Chmod() put the
source mode back, which only ever adds owner bits so the group/other
bits stay as restrictive as the source throughout. Add a regression
test covering the restricted-mode and read-only-source cases.
2026-06-09 09:53:57 +05:30
dxbjavid 1701edca5b fileutils: open Copy() destination at the source's mode 2026-05-25 13:08:43 +05:30
Alexey Sokolov a80cf49f5e Merge pull request #2018 from MarkLee131/fix/http-hardening-headers
HTTPSock: emit standard hardening response headers
2026-05-05 00:26:58 +01:00
Alexey Sokolov 663699b617 Merge pull request #2015 from MarkLee131/fix/cstring-empty-input-guards
ZNCString: guard Replace/Split against empty-width arguments
2026-05-04 22:05:49 +01:00
MarkLee131 83e7eefc21 HTTPSock: tighten hardening header defaults
Switch the default Referrer-Policy from same-origin to no-referrer so the
webadmin URL (which can carry user/network names in the path) does not
leak to outbound clicks either.

Drop Pragma: no-cache; it is deprecated and modern intermediaries honor
Cache-Control. Simplify Cache-Control to a single no-store directive,
which on its own already prevents storing per RFC 9111; the previous
no-cache, must-revalidate, max-age=0 tail was HTTP/1.0-era padding.
2026-05-04 20:35:23 +08:00
Alexey Sokolov f35e565637 Merge pull request #2013 from MarkLee131/fix/base64-decode-ub
ZNCString: avoid left shift of negative value in Base64Decode
2026-05-01 22:23:24 +01:00
ZNC-Jenkins e0c573c053 Update translations from Crowdin for bg_BG da_DK de_DE el_GR es_ES fr_FR id_ID it_IT nl_NL pl_PL pt_BR pt_PT ro_RO ru_RU tr_TR 2026-05-01 00:28:00 +00:00
Alexey Sokolov 6186f611b9 Merge pull request #2017 from MarkLee131/fix/checkpass-constant-time
User: use constant-time compare for MD5/SHA256/plain password paths
2026-04-30 08:23:07 +01:00
MarkLee131 f71e021e3b HTTPSock: emit standard hardening response headers
Close #2012.

Add X-Frame-Options: SAMEORIGIN, X-Content-Type-Options: nosniff and
Referrer-Policy: same-origin to every response so webadmin and module
pages are framed/sniff-protected by default. Add no-store Cache-Control
and Pragma: no-cache on dynamic responses so shared workstations can't
replay authenticated pages from browser history. Skip the cache headers
for 304 and for static asset MIME types (image, font, text/css,
application/javascript) that the existing ETag/Last-Modified path on
PrintFile already handles.

Per review feedback: the emitter is a private WriteHardeningHeaders that
writes each line via the socket directly from PrintHeader, not a public
helper returning a temporary VCString. Callers can override a default
value with AddHeader, or suppress one outright with the new public
OmitHardeningHeader(name).

Tests: drive PrintHeader on a CHTTPSock subclass that captures Write()
calls, then assert with gmock matchers (Contains(StartsWith(...))).
2026-04-29 20:29:47 +08:00
MarkLee131 c9d0677e4f Utils: prefer CRYPTO_memcmp in ConstantTimeEquals when OpenSSL is available
Per review feedback on #2017: a hand-rolled byte loop can in principle
be folded back into a short-circuiting compare by an aggressive optimizer.
Use CRYPTO_memcmp under HAVE_LIBSSL since OpenSSL is already a build
dependency for the SHA256 path. For non-OpenSSL builds, mark the
accumulator and pointers volatile and note in a comment that this is
best-effort.
2026-04-29 17:06:49 +08:00
Alexey Sokolov 866303eef0 Merge pull request #2014 from MarkLee131/fix/parseservertime-clamp-range
Utils: reject out-of-range years in ParseServerTime
2026-04-27 01:43:24 +01:00
MarkLee131 20e8f73b03 HTTPSock: extract IsValidHeaderField helper and add tests (#2010) 2026-04-25 17:38:31 +08:00
MarkLee131 f0c3341e35 User,Utils: move ConstantTimeEquals to CUtils and add tests (#2011) 2026-04-25 17:37:33 +08:00
MarkLee131 794ae6cd60 User: use constant-time compare for MD5/SHA256/plain password paths
CString::Equals falls through to strcmp, which short-circuits on the first
differing byte. That leaks the length of the common prefix between the
stored hash (or plain password) and the attacker's guess via response
timing. Argon2id already uses argon2id_verify which is constant-time.

Add a small ConstantTimeEquals helper and use it for the legacy MD5,
SHA256 and plain HASH_NONE branches. No new dependency: the helper is
~10 lines and works on builds without OpenSSL.
2026-04-25 10:39:13 +08:00
MarkLee131 04cf89beec HTTPSock: reject CR/LF in AddHeader name/value
AddHeader wrote its arguments straight into the response stream. No
in-tree caller reaches it with attacker-controlled bytes today, but the
public API is exposed to module authors; one bad caller would be a
header-injection bug. Filter at the entry rather than at every caller.
2026-04-25 10:38:31 +08:00
MarkLee131 514b47cad3 ZNCString: guard Replace/Split against empty-width arguments
CString::Replace with an empty sReplace underflowed 'p += uReplaceWidth - 1'
to SIZE_MAX and then the per-iteration 'p++' brought p back to the same
byte, so the function looped forever appending sWith to the output and
eventually OOMed.

CString::Split with empty sDelim and bAllowEmpty=false spun in the
prefix-skip loops because strncasecmp(p, "", 0) is unconditionally 0 and
p += 0 never advances.

No in-tree caller currently passes the bad argument, but the public
library API should not be a bear trap for module authors. Same shape as
#1994.
2026-04-25 10:38:02 +08:00
MarkLee131 b944299167 Utils: reject out-of-range years in ParseServerTime
cctz::parse into a microseconds time_point internally multiplies the
parsed seconds-since-epoch by 1,000,000 in signed int64. Years past ~292k
overflow, which is UB under UBSan or -ftrapv builds. In plain production
builds the overflow silently wraps and buffer playback shows a garbage
timestamp.

Reject anything with a year longer than 5 digits before calling into
cctz. 5 digits covers every realistic IRCv3 @time tag.
2026-04-25 10:36:53 +08:00
MarkLee131 026b88e2fa ZNCString: avoid left shift of negative value in Base64Decode
base64_table uses the sentinel 0xff for bytes outside the base64 alphabet.
The old code read that through (char), producing signed -1, which made the
three (c << N) expressions in Base64Decode undefined behaviour when the
input contained any invalid byte.

Keep c and c1 as unsigned char so the shifts are well-defined. Reachable
pre-auth via CHTTPSock::ReadLine for the Authorization: Basic value.
2026-04-25 10:34:06 +08:00
jabberwock 94aeaa02bf Message: add bounds check in GetParamsColon when uIdx >= params.size()
Without this check, when uIdx >= m_vsParams.size() and the vector is
non-empty, the subtraction in the clamp condition underflows to SIZE_MAX.
GetParamsSplit() already has the equivalent check at the top of the
function; this brings GetParamsColon() in line with it.

Fixes #1994
2026-03-17 09:39:50 -07:00
TehPeGaSuS 4c0483adfa Use user configured network
Use user configured network on the IRC client connection message example, so it turns from `/server <znc_server_ip> 1025 Admin:<pass>` to `/server <znc_server_ip> 1025 Admin/libera:<pass>`.

Should have done this from the start... 😅
2026-03-10 10:26:35 +01:00
TehPeGaSuS 9cb82dad06 Fix formatting in ZNC connection message
Make IRC client connection example consistent with the line above
2026-03-10 10:02:55 +01:00
Alexey Sokolov ad7bd6d7ee Don't try to join channel which ZNC is already on.
When Goguma connects to ZNC, it joins the joined channels again and
again, triggering flood protection.

Note: even with this fix, the Goguma+ZNC experience is still pretty bad
and requires doing something about repeating chat history
2026-01-26 22:15:23 +00:00
Falk Rund ad6a397ca4 Welcome to 2026
[skip ci]
2026-01-01 13:44:32 +01:00