]> git.ipfire.org Git - thirdparty/rspamd.git/log
thirdparty/rspamd.git
36 hours ago[Feature] Add UUID v7 column support to ClickHouse plugin 5890/head
Vsevolod Stakhov [Sun, 15 Feb 2026 10:03:00 +0000 (10:03 +0000)] 
[Feature] Add UUID v7 column support to ClickHouse plugin

Add TaskUUID column with Delta compression codec for efficient storage
of time-ordered UUID v7 values generated natively by Rspamd.

- Add enable_uuid setting (default: false)
- Add TaskUUID UUID CODEC(Delta, LZ4) column to schema
- Add migration from schema version 9 to 10
- Collect UUID via task:get_uuid() when enabled

Delta compression is effective for UUIDv7 due to its 48-bit millisecond
timestamp prefix ensuring monotonic ordering.

37 hours ago[Test] Add functional tests for structured metadata exporter
Vsevolod Stakhov [Sat, 14 Feb 2026 22:47:30 +0000 (22:47 +0000)] 
[Test] Add functional tests for structured metadata exporter

2 days ago[Test] Add unit tests for structured formatter features
Vsevolod Stakhov [Sat, 14 Feb 2026 21:43:22 +0000 (21:43 +0000)] 
[Test] Add unit tests for structured formatter features

2 days ago[Feature] Add zstd compression option to structured formatter
Vsevolod Stakhov [Sat, 14 Feb 2026 21:26:24 +0000 (21:26 +0000)] 
[Feature] Add zstd compression option to structured formatter

2 days ago[Feature] Use detected MIME types for attachments in structured formatter
Vsevolod Stakhov [Sat, 14 Feb 2026 21:22:52 +0000 (21:22 +0000)] 
[Feature] Use detected MIME types for attachments in structured formatter

2 days ago[Feature] Sync UUID v7 random portion with Log-Tag header
Vsevolod Stakhov [Sat, 14 Feb 2026 19:17:22 +0000 (19:17 +0000)] 
[Feature] Sync UUID v7 random portion with Log-Tag header

When an MTA provides a Log-Tag header that overrides the pool UID,
patch the task UUID's random portion (bytes 8-15) to stay in sync.
Uses a fast hash of the tag to derive the bytes while preserving
the UUID v7 variant bits.

2 days ago[Feature] Add structured formatter to metadata_exporter
Vsevolod Stakhov [Sat, 14 Feb 2026 15:35:59 +0000 (15:35 +0000)] 
[Feature] Add structured formatter to metadata_exporter

Add a 'structured' output format that emits rich msgpack metadata
including UUID correlation, extracted text, base64-encoded attachment
and image content, URLs, and reply detection. Uses task:get_uuid()
for cross-system correlation instead of generating UUIDs in Lua.

2 days ago[Feature] Add native UUID v7 per task with Lua binding
Vsevolod Stakhov [Sat, 14 Feb 2026 15:35:51 +0000 (15:35 +0000)] 
[Feature] Add native UUID v7 per task with Lua binding

Generate a UUID v7 (time-ordered, RFC 9562) natively in C at task
creation time. The task's log UID is derived from the UUID's random
portion so that UID and UUID are always correlated.

- rspamd_uuid_v7() in util.c: 48-bit ms timestamp + crypto-random bits
- task_uuid[37] field in rspamd_task, populated in rspamd_task_new()
- task:get_uuid() Lua method for plugin access

3 days ago[Fix] Preserve UNSCORED flag when config defines symbol without score
Vsevolod Stakhov [Fri, 13 Feb 2026 17:18:39 +0000 (17:18 +0000)] 
[Fix] Preserve UNSCORED flag when config defines symbol without score

When rspamd_config_add_symbol was called for an existing symbol without
a score (NAN), line 1811 unconditionally replaced all flags, clearing
RSPAMD_SYMBOL_FLAG_UNSCORED. This caused Lua-registered scores to be
ignored: if a symbol appeared in config (e.g. groups.conf) without a
score, the UNSCORED flag was lost, and the Lua score-setting block in
lua_config_register_symbol_from_table was skipped, leaving score at 0.

Now flags are updated correctly in both cases:
- Real score provided: flags fully replaced with UNSCORED cleared
- NAN score: flags updated but UNSCORED preserved from existing symbol

Also initialize score to NAN in lua_config_set_metric_symbol to avoid
passing uninitialized stack garbage to rspamd_config_add_symbol.

3 days ago[Feature] Add dual-mode HTML fuzzy: template matching + phishing detection
Vsevolod Stakhov [Fri, 13 Feb 2026 16:47:13 +0000 (16:47 +0000)] 
[Feature] Add dual-mode HTML fuzzy: template matching + phishing detection

When html_ignore_domains is enabled, generate two HTML fuzzy commands per
part: a template command (domains ignored) and a domain-sensitive command
(domains included). If the template matches but domains don't, the new
FUZZY_HTML_PHISHING symbol fires, detecting reused HTML templates with
swapped phishing links.

3 days ago[Fix] Load fuzzy_html_phishing rule in main rules loader
Vsevolod Stakhov [Fri, 13 Feb 2026 14:25:35 +0000 (14:25 +0000)] 
[Fix] Load fuzzy_html_phishing rule in main rules loader

3 days ago[Fix] Fix custom tokenizer UAF and improve CJK fuzzy detection
Vsevolod Stakhov [Fri, 13 Feb 2026 14:09:59 +0000 (14:09 +0000)] 
[Fix] Fix custom tokenizer UAF and improve CJK fuzzy detection

Fix use-after-free in custom tokenizer integration: when tokens were
shallow-copied from a custom tokenizer result, cleanup_result would free
per-token normalized/stemmed/unicode strings while the copies still
referenced them. Now copy these strings into the mempool before cleanup.

Improve fuzzy hash generation for CJK (Japanese/Chinese/Korean) text:
- Lower shingle word count threshold by 3x for CJK languages (64→21,
  floor 32→12) since CJK morphemes carry higher semantic density
- Boost text_multiplier by 3x for CJK to compensate for 3-byte UTF-8
  characters, allowing short CJK emails to pass the min_bytes gate

Previously, short Japanese phishing emails (~50 chars, ~20 words) would
generate zero fuzzy hashes — failing both the word count gate for shingles
and the byte length gate for direct hash.

3 days ago[Fix] Use class_name as Redis label for multiclass Bayes without class_labels config
Vsevolod Stakhov [Fri, 13 Feb 2026 10:58:25 +0000 (10:58 +0000)] 
[Fix] Use class_name as Redis label for multiclass Bayes without class_labels config

get_class_label() fell through to the legacy "S"/"H" fallback when
class_labels hash table was NULL, even when an explicit class_name
(e.g. "cold_marketing") was set on the statfile. Since all non-binary
classes have is_spam=FALSE, every class mapped to "H", causing:
- All tokens stored under the same Redis hash field "H"
- All learn counters going to learns_ham
- Classification returning identical data for all classes
- Mempool runtime caching collisions (all saved under key _H)

Fix: check class_name with !is_spam_converted before the S/H fallback
so explicit multiclass configs use their actual class name as the Redis
label, while legacy binary configs (auto-converted from spam=true/false)
still use "S"/"H".

Also fix controller learn log to show actual class name instead of
always "spam"/"ham".

3 days ago[Rework] Rewrite fuzzy_html_phishing rule with proper config awareness
Vsevolod Stakhov [Fri, 13 Feb 2026 10:11:25 +0000 (10:11 +0000)] 
[Rework] Rewrite fuzzy_html_phishing rule with proper config awareness

Rewrite fuzzy HTML phishing mismatch detection to read fuzzy_check
config at load time and only check symbols from rules that have
html_shingles enabled. Fix broken virtual symbol registration by
registering callback first and linking virtuals via parent id.
Skip registration entirely when no rules have html_shingles.

3 days ago[Fix] Resolve composite references in inverted index for fast path
Vsevolod Stakhov [Fri, 13 Feb 2026 07:37:27 +0000 (07:37 +0000)] 
[Fix] Resolve composite references in inverted index for fast path

When the inverted index fast path collects potentially active composites,
it scans symbols already in the scan result. Composite symbols are not
yet in the scan result at that point, so composites referencing other
composites as atoms were never activated and silently failed to fire.

Fix by resolving composite references at index build time: recursively
collect leaf (non-composite) atoms and propagate dependent composites
to those atoms' index entries. Also refactor atom name parsing into a
shared helper to reduce duplication.

3 days ago[Fix] Remove check for non-existent fuzzy_result mempool variable
Vsevolod Stakhov [Fri, 13 Feb 2026 07:24:50 +0000 (07:24 +0000)] 
[Fix] Remove check for non-existent fuzzy_result mempool variable

The fuzzy_result mempool variable is never set by fuzzy_check, so the
early return was always triggered, making the phishing mismatch check
a no-op. The actual logic uses get_symbols_all() which works correctly.

3 days ago[Feature] Add ignore_link_domains option for HTML fuzzy rules
Vsevolod Stakhov [Fri, 13 Feb 2026 07:23:20 +0000 (07:23 +0000)] 
[Feature] Add ignore_link_domains option for HTML fuzzy rules

Allow HTML fuzzy shingles to match purely on structure (tag skeleton +
classes) by stripping link domains from structural tokens. Domain hashes
are still computed separately for the metadata fields. A separate cache
key suffix (_nd) prevents cross-contamination with normal hashes.

4 days ago[Fix] Handle native boolean values in lua_util.toboolean()
Vsevolod Stakhov [Thu, 12 Feb 2026 17:35:32 +0000 (17:35 +0000)] 
[Fix] Handle native boolean values in lua_util.toboolean()

toboolean() only handled string and number inputs, falling through to
the error branch for native Lua booleans and always returning false.
This broke the fuzzy_check "checks" configuration block since UCL
converts boolean values to native Lua booleans, and apply_checks_overrides
in lua_fuzzy.lua passes them through toboolean() via bool_opt().

Fixes: #5775
4 days ago[Minor] Try to fix CC issue with tabs
Vsevolod Stakhov [Thu, 12 Feb 2026 16:27:21 +0000 (16:27 +0000)] 
[Minor] Try to fix CC issue with tabs

4 days agoMerge pull request #5885 from rspamd/vstakhov-lua-perl-utils
Vsevolod Stakhov [Thu, 12 Feb 2026 10:42:43 +0000 (10:42 +0000)] 
Merge pull request #5885 from rspamd/vstakhov-lua-perl-utils

[Feature] Rewrite rspamd_stats.pl and mapstats.pl as rspamadm Lua subcommands

4 days ago[Fix] Fix issues in logstats/mapstats from code review 5885/head
Vsevolod Stakhov [Thu, 12 Feb 2026 10:00:14 +0000 (10:00 +0000)] 
[Fix] Fix issues in logstats/mapstats from code review

- Shell-quote paths in io.popen() to prevent injection
- Fix typo: correllations -> correlations in JSON output
- Pre-compile ignored symbol regexes instead of recompiling per call
- Deduplicate score change output logic in logstats
- Use native rspamd_ip equality instead of string comparison in mapstats

5 days ago[Fix] Use fuzzy group and options instead of hardcoded symbol names for phishing...
Vsevolod Stakhov [Wed, 11 Feb 2026 12:19:39 +0000 (12:19 +0000)] 
[Fix] Use fuzzy group and options instead of hardcoded symbol names for phishing detection

Detect text/html fuzzy matches by checking the symbol group ('fuzzy')
and parsing the type from symbol options (flag:hash:prob:type) rather
than pattern-matching on symbol names that may not exist.

5 days ago[Test] Add functional tests for logstats and mapstats
Vsevolod Stakhov [Wed, 11 Feb 2026 11:06:54 +0000 (11:06 +0000)] 
[Test] Add functional tests for logstats and mapstats

Robot Framework tests covering:
- logstats: JSON output, text output, symbol filter, alpha_score
  warning, stdin mode, scan time display
- mapstats: map loading, inline comments for plain/IP/regexp maps,
  match counts, regexp matching

Includes test data: sample log files, plain/IP/regexp map files,
and a minimal multimap config.

5 days ago[Fix] Fix missing inline comments in mapstats output
Vsevolod Stakhov [Wed, 11 Feb 2026 09:54:30 +0000 (09:54 +0000)] 
[Fix] Fix missing inline comments in mapstats output

rspamd_regexp_search() truncates captures at the first unmatched
optional group, so when the score group was absent the comment
group was lost. Extract comments with Lua patterns before passing
the line body to rspamd_regexp.

5 days ago[Minor] Add colored output and TTY-aware progress to logstats/mapstats
Vsevolod Stakhov [Wed, 11 Feb 2026 09:25:31 +0000 (09:25 +0000)] 
[Minor] Add colored output and TTY-aware progress to logstats/mapstats

Gate spinner and ANSI escape codes behind isatty() so piped output is
clean. Add ansicolors to logstats (Ham/Spam/Junk labels, symbol names,
actions, warnings, summary) and mapstats (map status, match counts,
unmatched warnings).

5 days ago[Minor] Warn when symbols are filtered by alpha_score
Vsevolod Stakhov [Wed, 11 Feb 2026 09:12:10 +0000 (09:12 +0000)] 
[Minor] Warn when symbols are filtered by alpha_score

5 days ago[Minor] Handle blank lines in mapstats maps
Alexander Moisseev [Wed, 11 Feb 2026 06:41:23 +0000 (09:41 +0300)] 
[Minor] Handle blank lines in mapstats maps

Replace regex-based empty line detection with Lua pattern matching
to correctly identify and preserve blank lines instead of treating
them as syntax errors.

5 days ago[Minor] Use positional argument for log file in logstats/mapstats
Vsevolod Stakhov [Wed, 11 Feb 2026 09:05:50 +0000 (09:05 +0000)] 
[Minor] Use positional argument for log file in logstats/mapstats

6 days ago[Fix] Fix broken ip_within in mapstats: parse CIDR and use apply_mask return value
Vsevolod Stakhov [Tue, 10 Feb 2026 20:47:10 +0000 (20:47 +0000)] 
[Fix] Fix broken ip_within in mapstats: parse CIDR and use apply_mask return value

rspamd_ip.from_string rejects '/' in CIDR notation, so strip the mask
before parsing. Also apply_mask returns a new IP object rather than
modifying in place, so capture the return values.

6 days ago[Feature] Rewrite rspamd_stats.pl and mapstats.pl as rspamadm Lua subcommands
Vsevolod Stakhov [Tue, 10 Feb 2026 20:10:43 +0000 (20:10 +0000)] 
[Feature] Rewrite rspamd_stats.pl and mapstats.pl as rspamadm Lua subcommands

Add rspamadm logstats and rspamadm mapstats commands that replace the
Perl utility scripts utils/rspamd_stats.pl and utils/mapstats.pl.

- lua_log_utils.lua: shared library for log format detection, timestamp
  conversion, compressed file handling, directory scanning, and progress
  spinner
- logstats.lua: full port of rspamd_stats.pl with all options including
  symbol filtering, bidirectional symbols, groups, correlations, score
  multipliers, time range filtering, and JSON output via UCL
- mapstats.lua: full port of mapstats.pl using native rspamd_config for
  multimap access, rspamd_regexp for regex maps with full flag support,
  and rspamd_ip for IP/CIDR matching (no external dependencies)

6 days ago[Test] Add unit tests for ring hash consistent upstream hashing
Vsevolod Stakhov [Tue, 10 Feb 2026 15:00:22 +0000 (15:00 +0000)] 
[Test] Add unit tests for ring hash consistent upstream hashing

Verify consistency, distribution, weight-scaling, stability, and
except-parameter behaviour of the Ketama-style ring hash introduced
in 4ea750466.

6 days ago[Rework] Replace broken Jump Hash with Ring Hash (Ketama) for consistent upstream...
Vsevolod Stakhov [Tue, 10 Feb 2026 14:52:30 +0000 (14:52 +0000)] 
[Rework] Replace broken Jump Hash with Ring Hash (Ketama) for consistent upstream hashing

Jump Consistent Hash (Lamping & Veach 2014) only handles bucket
addition/removal at the end of the range.  When an upstream in the
middle failed, the old code rehashed with mum_hash_step and retried
up to 20 times, which destroyed the consistency property: keys that
mapped to the dead node were redistributed randomly instead of
deterministically, and didn't return when the node recovered.

Replace with a Ketama-style ring hash:
- Each alive upstream gets MAX(weight,1)*100 virtual nodes on a
  sorted hash ring (keyed by name, order-independent).
- Lookup is a binary search: O(log(n*v)) instead of O(ln n) * retries.
- When an upstream fails, only its ~1/n fraction of keys slide to the
  next ring point — true minimal disruption.
- When it recovers, the same keys return — true consistency.
- The 'except' parameter walks forward on the ring instead of rehashing.
- Ring is rebuilt lazily (dirty flag set on active/inactive transitions).

6 days agoMerge pull request #5884 from rspamd/vstakhov-ssl-server
Vsevolod Stakhov [Tue, 10 Feb 2026 14:30:51 +0000 (14:30 +0000)] 
Merge pull request #5884 from rspamd/vstakhov-ssl-server

Implement HTTPS server support for workers

6 days agoMerge pull request #5883 from moisseev/webui
Vsevolod Stakhov [Tue, 10 Feb 2026 14:18:20 +0000 (14:18 +0000)] 
Merge pull request #5883 from moisseev/webui

[Minor] Update RequireJS to 2.3.8

6 days agoMerge pull request #5870 from moisseev/mapstats
Vsevolod Stakhov [Tue, 10 Feb 2026 14:18:09 +0000 (14:18 +0000)] 
Merge pull request #5870 from moisseev/mapstats

[Feature] Add mapstats utility for multimap statistics analysis

7 days ago[Fix] Fix proxy mirror SSL/keepalive config parsing and remove duplicate keepalive... 5884/head
Vsevolod Stakhov [Mon, 9 Feb 2026 15:33:24 +0000 (15:33 +0000)] 
[Fix] Fix proxy mirror SSL/keepalive config parsing and remove duplicate keepalive block

Add missing ssl and keepalive option parsing to mirror config parser,
and remove duplicate keepalive parsing block in upstream config parser.

7 days ago[Test] Add SSL server functional tests
Vsevolod Stakhov [Mon, 9 Feb 2026 14:35:01 +0000 (14:35 +0000)] 
[Test] Add SSL server functional tests

Add functional tests for HTTPS server support in the
merged test suite. Tests cover controller and normal
worker SSL endpoints plus plain HTTP coexistence.

7 days ago[Feature] Auto-detect SSL from bind sockets, remove ssl = true option
Vsevolod Stakhov [Mon, 9 Feb 2026 14:34:47 +0000 (14:34 +0000)] 
[Feature] Auto-detect SSL from bind sockets, remove ssl = true option

Instead of requiring a separate `ssl = true` worker option, automatically
detect SSL need by checking if any bind socket has the ssl flag. Emit an
error if SSL bind sockets are configured but ssl_cert/ssl_key are missing.

7 days ago[Fix] Fix bind line parsing to use stripped bind_line for SSL suffix
Vsevolod Stakhov [Mon, 9 Feb 2026 11:54:04 +0000 (11:54 +0000)] 
[Fix] Fix bind line parsing to use stripped bind_line for SSL suffix

When parsing bind lines with " ssl" suffix, the suffix was stripped from
cnf->bind_line but the original unstripped str was passed to
rspamd_parse_host_port_priority, causing parse failures.

7 days ago[Feature] Implement HTTPS server support for workers
Vsevolod Stakhov [Mon, 9 Feb 2026 10:44:36 +0000 (10:44 +0000)] 
[Feature] Implement HTTPS server support for workers

Wire up server-side SSL/TLS for HTTP workers, building on the recently
added rspamd_ssl_accept_fd() infrastructure. This enables HTTPS for
controller, normal, and proxy workers with per-bind-address granularity.

Configuration: `bind_socket = "*:11335 ssl"` plus `ssl_cert` and
`ssl_key` worker options.

- Add rspamd_init_ssl_ctx_server() for server SSL_CTX with cert+key
- Parse trailing " ssl" suffix in bind_socket lines
- Propagate is_ssl flag through bind conf to listen sockets
- Add rspamd_http_connection_accept_ssl() for async SSL handshake
- Fix write_message_common to handle server-side SSL responses
- Add SSL support to HTTP router (set_ssl, handle_socket_ssl)
- Wire up SSL in controller, normal worker, and proxy worker
- Add rspamd_worker_is_ssl_socket() utility for fd-to-SSL lookup

7 days ago[Minor] Add CLAUDE.md with development guidelines
Vsevolod Stakhov [Mon, 9 Feb 2026 09:16:29 +0000 (09:16 +0000)] 
[Minor] Add CLAUDE.md with development guidelines

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
7 days ago[Feature] Add SSL server-side accept support
Vsevolod Stakhov [Sun, 8 Feb 2026 19:25:44 +0000 (19:25 +0000)] 
[Feature] Add SSL server-side accept support

Add rspamd_ssl_accept_fd() function for server-side SSL handshakes:
- Mirrors existing rspamd_ssl_connect_fd() but for accepting connections
- Adds ssl_conn_init_accept state for server-side SSL state machine
- Handles SSL_accept() with proper WANT_READ/WANT_WRITE event handling

This enables SSL-capable server implementations (e.g. SMTP proxy with STARTTLS).

8 days agoMerge pull request #5880 from rspamd/vstakhov-check-v3
Vsevolod Stakhov [Sun, 8 Feb 2026 19:30:44 +0000 (19:30 +0000)] 
Merge pull request #5880 from rspamd/vstakhov-check-v3

Add /checkv3 multipart scan endpoint

8 days ago[Test] Add v3 compression and proxy forwarding tests 5880/head
Vsevolod Stakhov [Sun, 8 Feb 2026 14:21:09 +0000 (14:21 +0000)] 
[Test] Add v3 compression and proxy forwarding tests

Add C++ unit tests for zstd per-part compression round-trip
(serialize and iov paths), mixed compressed/uncompressed parts,
and body_iov segment writability for in-place encryption.

Add Robot functional tests for /checkv3 through the proxy,
both direct multipart and rspamc with zstd compression.

8 days ago[Fix] protocol: Handle shared memory and whole-body compression for v3 proxy path
Vsevolod Stakhov [Sun, 8 Feb 2026 14:20:45 +0000 (14:20 +0000)] 
[Fix] protocol: Handle shared memory and whole-body compression for v3 proxy path

When the proxy forwards /checkv3 requests to a local upstream, it uses
shared memory (GET + Shm headers) instead of sending the body inline.
The v3 request handler only read from chunk/len parameters which are
empty in this case. Add Shm/Shm-Offset/Shm-Length header handling to
read the body from the shared memory segment.

Additionally, the proxy may compress the entire response body with zstd
before forwarding to the client. The v3 client finish handler parsed
multipart directly from the compressed body_buf. Add whole-body
decompression (matching the v2 handler) before multipart parsing.

8 days ago[Feature] protocol: Zero-copy piecewise writev for v3 multipart responses
Vsevolod Stakhov [Sun, 8 Feb 2026 12:18:16 +0000 (12:18 +0000)] 
[Feature] protocol: Zero-copy piecewise writev for v3 multipart responses

Add body_iov support to the HTTP message layer so the write path can use
writev with multiple iovec segments instead of a single contiguous buffer.
The v3 multipart response now builds its boundary/header strings and data
pointers as separate iovecs, avoiding extra copies of the UCL result and
rewritten message body. The cryptobox encryption path handles multiple body
segments via encryptv_nm_inplace seamlessly.

8 days ago[Feature] protocol: Add v3 multipart response parsing for proxy and body decompression
Vsevolod Stakhov [Sun, 8 Feb 2026 10:13:40 +0000 (10:13 +0000)] 
[Feature] protocol: Add v3 multipart response parsing for proxy and body decompression

Proxy forwarding now handles multipart/mixed responses from /checkv3:
parse result+body parts, decompress zstd, detect msgpack, and forward
rewritten body to milter. Self-scan v3 populates conn->results for
milter and Lua comparison scripts. rspamc client decompresses zstd
body parts returned by the server.

9 days ago[Refactor] protocol: Deduplicate v2/v3 request and reply handling
Vsevolod Stakhov [Sat, 7 Feb 2026 21:04:44 +0000 (21:04 +0000)] 
[Refactor] protocol: Deduplicate v2/v3 request and reply handling

Extract shared helpers to eliminate duplicated logic between
rspamd_protocol_handle_headers (v2) and rspamd_protocol_handle_metadata (v3),
as well as between rspamd_protocol_http_reply and rspamd_protocol_http_reply_v3.

Request-side helpers: rspamd_protocol_set_from_envelope,
rspamd_protocol_set_ip, rspamd_protocol_set_settings_id,
rspamd_protocol_set_log_tag, rspamd_protocol_add_mail_esmtp_arg,
rspamd_protocol_add_rcpt_esmtp_arg.

Reply-side helpers: rspamd_protocol_update_history_and_log,
rspamd_protocol_update_stats, rspamd_protocol_get_rewritten_body.

9 days ago[Feature] rspamc: Add --msgpack flag for v3 protocol
Vsevolod Stakhov [Sat, 7 Feb 2026 15:55:53 +0000 (15:55 +0000)] 
[Feature] rspamc: Add --msgpack flag for v3 protocol

Add --msgpack option to rspamc that sends metadata as msgpack instead
of JSON and requests msgpack responses when using --protocol-v3.

The client serializes metadata via UCL_EMIT_MSGPACK, sets the metadata
part Content-Type to application/msgpack, and sends Accept:
application/msgpack so the server returns results in msgpack format.

Add functional tests for rspamc v3 with zstd compression, httpcrypt
encryption, msgpack metadata, and encrypted+msgpack combinations.

9 days ago[Fix] protocol: Pass v3 Content-Type as mime_type parameter
Vsevolod Stakhov [Sat, 7 Feb 2026 15:54:55 +0000 (15:54 +0000)] 
[Fix] protocol: Pass v3 Content-Type as mime_type parameter

The v3 reply builder was adding Content-Type (multipart/mixed with
boundary) as an HTTP header via rspamd_http_message_add_header, while
setting ctype=NULL for rspamd_http_connection_write_message. With NULL,
the HTTP library defaults to "text/plain", so the client never saw the
multipart Content-Type and fell through to plain UCL parsing.

Fix by returning the Content-Type string (pool-allocated) from
rspamd_protocol_http_reply_v3 and passing it as the mime_type parameter
directly. Also fix the same pattern in rspamd_proxy.c.

Update v3 error test expectations from 400 to 500 to match the existing
error code mapping formula (500 + err_code % 100).

9 days ago[Fix] Add missing includes for Linux/GCC build
Vsevolod Stakhov [Sat, 7 Feb 2026 13:34:27 +0000 (13:34 +0000)] 
[Fix] Add missing includes for Linux/GCC build

Add <cctype> for std::tolower and <string> for std::string
in multipart_form.cxx. These are transitively included on
macOS/clang but not on Linux/GCC.

9 days ago[Test] Add MIME-in-message tests for /checkv3
Vsevolod Stakhov [Sat, 7 Feb 2026 13:33:24 +0000 (13:33 +0000)] 
[Test] Add MIME-in-message tests for /checkv3

Verify that messages with their own MIME structure (multipart/alternative,
multipart/mixed with attachments) are preserved intact when wrapped in
the outer form-data envelope. Unit tests confirm inner MIME boundaries
don't confuse the outer parser; functional tests confirm end-to-end
symbol detection (R_PARTS_DIFFER, MIME_HTML_ONLY) works via /checkv3.

9 days ago[Test] Add tests for /checkv3 multipart endpoint
Vsevolod Stakhov [Sat, 7 Feb 2026 12:23:37 +0000 (12:23 +0000)] 
[Test] Add tests for /checkv3 multipart endpoint

C++ unit tests (23 cases): multipart form parser, response builder,
and round-trip serialization. Robot Framework functional tests (6 cases):
GTUBE scan, metadata handling, settings_id, and error cases for missing
parts and malformed boundaries. Python helpers for building and parsing
multipart/form-data requests and multipart/mixed responses.

9 days ago[Feature] Add v3 request validation and use safe UCL parser flags
Vsevolod Stakhov [Sat, 7 Feb 2026 12:22:22 +0000 (12:22 +0000)] 
[Feature] Add v3 request validation and use safe UCL parser flags

Enforce max 2 parts (metadata + message) in /checkv3 multipart requests,
returning HTTP 400 for malformed requests with extra parts. Switch UCL
parser to UCL_PARSER_SAFE_FLAGS to disable macros/includes in untrusted
metadata input.

9 days agoMerge branch 'master' into vstakhov-check-v3
Vsevolod Stakhov [Sat, 7 Feb 2026 11:19:47 +0000 (11:19 +0000)] 
Merge branch 'master' into vstakhov-check-v3

9 days ago[Fix] tests: Update URL expectation to match percent-encoded spaces
Vsevolod Stakhov [Sat, 7 Feb 2026 09:57:57 +0000 (09:57 +0000)] 
[Fix] tests: Update URL expectation to match percent-encoded spaces

After 9f3a41069 URL tostring re-encodes spaces as %20, so the
functional test must expect the encoded form.

9 days ago[Minor] Update RequireJS to 2.3.8 5883/head
Alexander Moisseev [Sat, 7 Feb 2026 09:27:34 +0000 (12:27 +0300)] 
[Minor] Update RequireJS to 2.3.8

10 days ago[Test] Add MIME_HTML_ONLY test for multipart/mixed with html and non-text attachment
Vsevolod Stakhov [Fri, 6 Feb 2026 18:16:03 +0000 (18:16 +0000)] 
[Test] Add MIME_HTML_ONLY test for multipart/mixed with html and non-text attachment

Add test case for multipart/mixed containing text/html + application/zip
to ensure MIME_HTML_ONLY fires when HTML is the only text part alongside
a non-text attachment.

10 days ago[Fix] lua_content: Move PDF ligature substitutions from string unescape to text handler
Vsevolod Stakhov [Fri, 6 Feb 2026 17:42:55 +0000 (17:42 +0000)] 
[Fix] lua_content: Move PDF ligature substitutions from string unescape to text handler

StandardEncoding/MacRomanEncoding ligature substitutions (e.g. byte 0xAD -> 'ffl')
were applied to all PDF strings including /URI annotation values. This corrupted
soft hyphens (U+00AD) in URLs, preventing the URL parser from detecting zero-width
space obfuscation and setting the ZW_SPACES flag.

Move ligature substitutions to text_op_handler where they belong, so they only
apply to rendered text content (Tj/TJ operators), not to dictionary string values.

10 days ago[Feature] arc: Add trusted_authserv_id option for reuse_auth_results
Vsevolod Stakhov [Fri, 6 Feb 2026 15:31:46 +0000 (15:31 +0000)] 
[Feature] arc: Add trusted_authserv_id option for reuse_auth_results

Allow configuring which Authentication-Results header to trust when
reuse_auth_results is enabled, by matching the authserv-id field.

Closes #5881

10 days ago[Fix] lua_url: Re-encode control characters and spaces in URL tostring
Vsevolod Stakhov [Fri, 6 Feb 2026 15:11:44 +0000 (15:11 +0000)] 
[Fix] lua_url: Re-encode control characters and spaces in URL tostring

The URL parser (rspamd_url_decode) decodes percent-encoded sequences
like %20 back to literal characters in the internal representation.
When tostring() returned these decoded URLs, spaces and control chars
would break subsequent re-parsing (e.g., in url_redirector redirect
chains and Redis cache round-trips). Fix by re-encoding characters
<= 0x20 on serialization, matching browser behavior: decode internally
for matching, re-encode on copy.

10 days ago[Fix] re_cache: Always use charset-converted content for SARAWBODY matching
Vsevolod Stakhov [Fri, 6 Feb 2026 11:22:07 +0000 (11:22 +0000)] 
[Fix] re_cache: Always use charset-converted content for SARAWBODY matching

Use utf_raw_content (charset-converted UTF-8 with HTML tags preserved)
for all SARAWBODY patterns, regardless of /u flag presence. The previous
approach used utf_content (which strips HTML tags on HTML parts) and only
for classes containing /u patterns, leaving non-/u patterns matching
against raw bytes in the original charset.

This prevents trivial bypass of SA rawbody rules via exotic encodings
like UTF-16 and ensures consistent matching across PCRE and Hyperscan.
Falls back to transfer-decoded parsed content only when charset
conversion failed.

10 days agoMerge pull request #5871 from KIT-CERT/fix_ratelimits
Vsevolod Stakhov [Fri, 6 Feb 2026 10:17:38 +0000 (10:17 +0000)] 
Merge pull request #5871 from KIT-CERT/fix_ratelimits

fix dynamic bucket-specific rate-limits

10 days agoMerge pull request #5874 from rspamd/vstakhov-proxy-balancing
Vsevolod Stakhov [Fri, 6 Feb 2026 10:17:15 +0000 (10:17 +0000)] 
Merge pull request #5874 from rspamd/vstakhov-proxy-balancing

Feature: Token bucket load balancing for proxy upstreams

10 days ago[Test] upstream: add token bucket unit tests 5874/head
Vsevolod Stakhov [Fri, 6 Feb 2026 09:26:39 +0000 (09:26 +0000)] 
[Test] upstream: add token bucket unit tests

15 doctest test cases covering token bucket load balancing:
basic selection, cost formula, token return/penalty, least-loaded
preference, except parameter, exhaustion fallback, fair distribution,
custom config, empty list, null safety, large messages, multiple
inflight, mixed success/failure, and generic API fallback.

10 days ago[Fix] upstream: fix stale heap_idx in token bucket
Vsevolod Stakhov [Fri, 6 Feb 2026 09:25:17 +0000 (09:25 +0000)] 
[Fix] upstream: fix stale heap_idx in token bucket

The intrusive heap swaps entire structs during swim/sink, making
up->heap_idx stale after any heap modification. The update function
would silently skip updates when the cached index pointed to a
different upstream, breaking load distribution across backends.

Fix by falling back to linear search on cache miss and refreshing
heap_idx after every heap update. Also add underflow warning for
double-return detection and improve API documentation.

10 days agoMerge branch 'master' into vstakhov-proxy-balancing
Vsevolod Stakhov [Fri, 6 Feb 2026 08:07:36 +0000 (08:07 +0000)] 
Merge branch 'master' into vstakhov-proxy-balancing

11 days ago[Feature] Add /checkv3 multipart scan endpoint
Vsevolod Stakhov [Thu, 5 Feb 2026 22:00:00 +0000 (22:00 +0000)] 
[Feature] Add /checkv3 multipart scan endpoint

Implement a new /checkv3 endpoint that uses multipart/form-data for
requests and multipart/mixed for responses. Metadata (from, rcpt, ip,
settings, etc.) is sent as a structured JSON/msgpack part instead of
HTTP headers. The response includes a "result" part and an optional
"body" part for rewritten messages.

New C++ multipart parser and response builder with C bridge functions.
Per-part zstd compression support. Client-side support via rspamc
--protocol-v3 flag. Proxy self-scan path updated for v3.

11 days ago[Refactor] fuzzy storage: split helper code (#5875)
Vsevolod Stakhov [Thu, 5 Feb 2026 15:38:07 +0000 (15:38 +0000)] 
[Refactor] fuzzy storage: split helper code (#5875)

11 days agoMerge pull request #5878 from moisseev/webui
Vsevolod Stakhov [Thu, 5 Feb 2026 14:52:20 +0000 (14:52 +0000)] 
Merge pull request #5878 from moisseev/webui

[Fix] WebUI: Allow computing fuzzy hashes without writable storages

11 days ago[Fix] Fix printf format specifiers found by clang-plugin
Vsevolod Stakhov [Thu, 5 Feb 2026 14:05:32 +0000 (14:05 +0000)] 
[Fix] Fix printf format specifiers found by clang-plugin

11 days ago[Fix] clang-plugin: add null check for struct type in check_struct_type
Vsevolod Stakhov [Thu, 5 Feb 2026 14:04:57 +0000 (14:04 +0000)] 
[Fix] clang-plugin: add null check for struct type in check_struct_type

11 days ago[Fix] clang-plugin: suppress noisy remarks and fix SANITIZER macro conflict
Vsevolod Stakhov [Thu, 5 Feb 2026 13:10:54 +0000 (13:10 +0000)] 
[Fix] clang-plugin: suppress noisy remarks and fix SANITIZER macro conflict

11 days ago[Fix] clang-plugin: fix build with modern LLVM/Clang
Vsevolod Stakhov [Thu, 5 Feb 2026 13:07:03 +0000 (13:07 +0000)] 
[Fix] clang-plugin: fix build with modern LLVM/Clang

11 days ago[Fix] Use %ud instead of %u in rspamd printf format strings
Vsevolod Stakhov [Thu, 5 Feb 2026 12:44:03 +0000 (12:44 +0000)] 
[Fix] Use %ud instead of %u in rspamd printf format strings

11 days ago[Fix] re_cache: Use debug level for missing Lua backend during config
Vsevolod Stakhov [Thu, 5 Feb 2026 09:47:44 +0000 (09:47 +0000)] 
[Fix] re_cache: Use debug level for missing Lua backend during config

During config initialization (configtest, startup), there's no event
loop available so the Lua backend cannot be initialized. This is
expected behavior - use debug level when try_load=true to avoid
noisy warnings during configtest.

11 days ago[Test] Add test cases for MIME_HTML_ONLY with malformed multipart
Vsevolod Stakhov [Thu, 5 Feb 2026 09:23:54 +0000 (09:23 +0000)] 
[Test] Add test cases for MIME_HTML_ONLY with malformed multipart

Add tests for edge cases that caused a segfault when multipart/related
has no children or contains only non-text content:

- alternative-nested-rfc822.eml: multipart/alternative with HTML and
  related containing only image (no text), plus nested message/rfc822
- alternative-empty-related.eml: multipart/alternative with malformed
  related that has no proper MIME children

These test cases verify the NULL check fix for mp->children.

11 days ago[Fix] message: Add NULL check for mp->children in alternative detection
Vsevolod Stakhov [Thu, 5 Feb 2026 09:17:47 +0000 (09:17 +0000)] 
[Fix] message: Add NULL check for mp->children in alternative detection

The multipart children array can be NULL in some edge cases. Add NULL
checks before accessing mp->children->len to prevent segfault in
rspamd_mime_part_find_text_in_subtree() and related code paths.

11 days ago[Fix] re_cache: Use debug level for startup hyperscan load failures
Vsevolod Stakhov [Thu, 5 Feb 2026 09:14:22 +0000 (09:14 +0000)] 
[Fix] re_cache: Use debug level for startup hyperscan load failures

During worker startup, a "best-effort" synchronous hyperscan load is
attempted before hs_helper has finished compiling. When files don't
exist yet, the "no valid expressions" message was logged at info level,
which is noisy and misleading since this is expected startup behavior.

Changed to use debug level when try_load=true (startup probe), while
keeping info level for actual failures. Workers will receive async
notifications when hs_helper finishes compiling.

11 days ago[Fix] WebUI: Allow computing fuzzy hashes without writable storages 5878/head
Alexander Moisseev [Thu, 5 Feb 2026 09:06:48 +0000 (12:06 +0300)] 
[Fix] WebUI: Allow computing fuzzy hashes without writable storages

11 days ago[Fix] re_cache: Respect disable_hyperscan option in loading functions
Vsevolod Stakhov [Thu, 5 Feb 2026 08:58:53 +0000 (08:58 +0000)] 
[Fix] re_cache: Respect disable_hyperscan option in loading functions

Add checks for disable_hyperscan at the start of hyperscan loading
functions to prevent database loading when the option is set.

Previously, hyperscan databases would still be loaded even with
disable_hyperscan = true, causing unnecessary I/O and memory usage.

11 days ago[Fix] re_cache: Use charset-converted content for UTF-8 SARAWBODY patterns
Vsevolod Stakhov [Thu, 5 Feb 2026 08:53:07 +0000 (08:53 +0000)] 
[Fix] re_cache: Use charset-converted content for UTF-8 SARAWBODY patterns

When SARAWBODY regexp class contains UTF-8 patterns (/u flag), use
utf_content (charset-converted UTF-8 with HTML preserved) instead of
parsed content. This allows Unicode patterns like \x{200b} to match
correctly.

For non-UTF patterns, continue using parsed content with raw mode
for backward compatibility with raw byte matching.

This fixes "bad utf8 input for JIT re" errors when using Unicode
patterns in rawbody rules on non-UTF-8 encoded messages.

12 days ago[Fix] re_cache: Always use raw mode for SARAWBODY regexps
Vsevolod Stakhov [Wed, 4 Feb 2026 18:44:18 +0000 (18:44 +0000)] 
[Fix] re_cache: Always use raw mode for SARAWBODY regexps

The parsed content is transfer-decoded (base64/QP) but NOT charset-converted,
so it may contain non-UTF-8 data even when IS_TEXT_PART_UTF is true.

Using dynamic raw flag based on IS_TEXT_PART_UTF was incorrect because that
flag indicates whether utf_content is valid UTF-8, not whether parsed content
is valid UTF-8.

Bug introduced in 0d62dd6513 (1.8.3), this restores the original behavior of
always treating SARAWBODY content as raw.

12 days ago[Feature] re_cache: Improve hyperscan loading log messages
Vsevolod Stakhov [Wed, 4 Feb 2026 17:06:40 +0000 (17:06 +0000)] 
[Feature] re_cache: Improve hyperscan loading log messages

- Show regexp count alongside class count (e.g., "4662 regexps (42/42 classes)")
- Display loaded/total classes ratio for partial loads (e.g., "38/42 classes")
- Log missing classes with reasons (not cached, empty data, load failed)
- Add consistent logging to async loading path
- Include class type and type_data in missing class messages for easier debugging

12 days ago[Fix] Use rspamd printf format specifiers instead of GNU
Vsevolod Stakhov [Wed, 4 Feb 2026 15:10:00 +0000 (15:10 +0000)] 
[Fix] Use rspamd printf format specifiers instead of GNU

Fix format strings in hs_cache_backend.c and re_cache.c to use rspamd's
custom printf specifiers:
- %uz for gsize (unsigned size_t), not %z
- %ud for unsigned int, not %u

The GNU format specifiers cause crashes on some platforms.

12 days ago[Fix] lua_magic: avoid misdetecting HTML with embedded SVG as SVG
Vsevolod Stakhov [Wed, 4 Feb 2026 14:50:35 +0000 (14:50 +0000)] 
[Fix] lua_magic: avoid misdetecting HTML with embedded SVG as SVG

Add svg_format_heuristic that checks for HTML markers (<!DOCTYPE html>,
<html>, <head>, <body>, <meta>) before the <svg> tag position. If HTML
markers are present, skip SVG detection and let the text heuristic
properly classify the content as HTML.

Add functional test with HTML containing embedded SVG (should detect as
HTML) and standalone SVG (should still detect as SVG).

12 days ago[Fix] Hyperscan cache: use Lua backend for sync loading, load on worker startup
Vsevolod Stakhov [Wed, 4 Feb 2026 13:48:00 +0000 (13:48 +0000)] 
[Fix] Hyperscan cache: use Lua backend for sync loading, load on worker startup

Two issues addressed:

1. Sync loading now uses Lua backend exclusively instead of duplicating
   file loading logic in C. The Lua backend handles files, compression,
   and future backends (redis, http) uniformly.

2. Workers now proactively load hyperscan on startup after Lua backend
   is initialized. This fixes a race condition where workers spawned
   after hs_helper broadcasts HYPERSCAN_LOADED would never receive the
   notification and run without hyperscan acceleration.

Changes:
- Add rspamd_hs_cache_lua_load_sync() and rspamd_hs_cache_lua_exists_sync()
  to call Lua backend's sync methods from C
- Remove duplicated C file loading code from re_cache.c (zstd decompress,
  file path checking) - Lua backend handles this
- rspamd_re_cache_load_hyperscan() now requires Lua backend
- Workers try sync load on startup (best-effort, falls back to PCRE)

12 days ago[Fix] Rework alternative parts detection
Vsevolod Stakhov [Wed, 4 Feb 2026 12:02:06 +0000 (12:02 +0000)] 
[Fix] Rework alternative parts detection

13 days agoconvert tabs to spaces 5871/head
Konstantin Zangerle [Tue, 3 Feb 2026 16:28:19 +0000 (17:28 +0100)] 
convert tabs to spaces

13 days ago[Fix] R_PARTS_DIFFER: handle multipart/related in alternative
Vsevolod Stakhov [Tue, 3 Feb 2026 16:11:15 +0000 (16:11 +0000)] 
[Fix] R_PARTS_DIFFER: handle multipart/related in alternative

13 days agofix linter errors
Konstantin Zangerle [Tue, 3 Feb 2026 16:04:55 +0000 (17:04 +0100)] 
fix linter errors

13 days ago[Feature] proxy: enable token bucket load balancing by default
Vsevolod Stakhov [Tue, 3 Feb 2026 11:52:18 +0000 (11:52 +0000)] 
[Feature] proxy: enable token bucket load balancing by default

Add token_bucket configuration to the default upstream in worker-proxy.inc
with sensible defaults (max_tokens=10000, scale=1024, base_cost=10).

13 days ago[Feature] proxy: implement token bucket load balancing for upstreams
Vsevolod Stakhov [Tue, 3 Feb 2026 11:42:27 +0000 (11:42 +0000)] 
[Feature] proxy: implement token bucket load balancing for upstreams

Add weighted load balancing algorithm that considers message size and
current backend load when selecting upstreams. Each upstream has a token
pool that gets depleted proportionally to message size and replenished
when requests complete successfully.

- Add RSPAMD_UPSTREAM_TOKEN_BUCKET rotation type
- Implement min-heap based selection for O(log n) upstream selection
- Reserve tokens proportional to message size (base_cost + size/scale)
- Return tokens on success (restores available) or failure (lost)
- Fall back to least-loaded upstream when all are token-exhausted
- Add UCL configuration: token_bucket { max_tokens, scale, min_tokens, base_cost }

13 days ago[Fix] R_PARTS_DIFFER: also handle parts without words
Vsevolod Stakhov [Tue, 3 Feb 2026 10:14:26 +0000 (10:14 +0000)] 
[Fix] R_PARTS_DIFFER: also handle parts without words

The previous fix only handled truly empty parts. This also handles
the case where a part has content but no extractable words (e.g.,
6 bytes of whitespace in text/plain vs 142 words in text/html).

Now check if exactly one part has normalized_hashes with words,
regardless of whether parts are marked as empty.

2 weeks ago[Fix] R_PARTS_DIFFER: handle empty alternative parts
Vsevolod Stakhov [Mon, 2 Feb 2026 14:27:16 +0000 (14:27 +0000)] 
[Fix] R_PARTS_DIFFER: handle empty alternative parts

Previously, R_PARTS_DIFFER only triggered when both text/html and
text/plain parts had content. When one part was empty (e.g., empty
HTML with non-empty plain text), the distance was never calculated.

Now detect when exactly one part is empty and treat it as 100%
difference, which will trigger R_PARTS_DIFFER with maximum score.

2 weeks agofix dynamic bucket-specific rate-limits
Konstantin Zangerle [Mon, 2 Feb 2026 13:38:46 +0000 (14:38 +0100)] 
fix dynamic bucket-specific rate-limits

2 weeks ago[Minor] Fix security issues and add security documentation 5870/head
Alexander Moisseev [Mon, 2 Feb 2026 08:36:55 +0000 (11:36 +0300)] 
[Minor] Fix security issues and add security documentation

- Fix command injection in configdump(): use list form open() instead of
backticks with string concatenation
- Fix ReDoS in ProcessLog(): escape regex metacharacters in symbol names
with \Q...\E when matching against log symbols
- Add SECURITY CONSIDERATIONS section to POD documenting trust assumptions
for map files, configuration, and log files

2 weeks ago[Feature] Add mapstats utility for multimap statistics analysis
Alexander Moisseev [Mon, 2 Feb 2026 07:57:00 +0000 (10:57 +0300)] 
[Feature] Add mapstats utility for multimap statistics analysis

Introduce a new utility to analyze Rspamd logs and count matches for
multimap module patterns. This helps identify ineffective map entries
and optimize multimap configurations.

Features:
- Parse file-based multimap configurations from rspamadm configdump
- Load and validate map files with support for:
  * IP/CIDR patterns (IPv4/IPv6)
  * Regular expressions with PCRE flags (imsxurOL)
  * Plain string patterns (domains, hostnames, etc.)
  * Full-line and inline comments
- Process Rspamd logs (plain or compressed: bz2, gz, xz, zst)
- Match log entries against map patterns
- Generate statistics report grouped by map source files
- Show match counts and comments for each pattern
- Report unmatched symbol values for debugging

Installation:
- Added to CMake install rules (installs as 'mapstats')
- Added to RPM spec file
- Debian packaging works automatically via CMake

Usage:
mapstats -l /var/log/rspamd/rspamd.log
mapstats -l /var/log/rspamd -n 5        # Last 5 rotated logs
mapstats -l /var/log/rspamd --start 2024-01-01 --end 2024-01-31

Requirements:
- Perl 5.14+
- JSON::PP (core module)
- NetAddr::IP (optional, for type=ip maps only)

2 weeks ago[Fix] worker_util: add hyperscan handlers to controller
Vsevolod Stakhov [Sun, 1 Feb 2026 16:00:05 +0000 (16:00 +0000)] 
[Fix] worker_util: add hyperscan handlers to controller

Controller was missing hyperscan/multipattern/regexp_map hot-swap
handlers, causing it to stay on ACISM fallback while normal workers
switched to hyperscan.

2 weeks ago[Fix] multipattern: fix TLD pattern matching after hyperscan hot-swap
Vsevolod Stakhov [Sun, 1 Feb 2026 15:52:56 +0000 (15:52 +0000)] 
[Fix] multipattern: fix TLD pattern matching after hyperscan hot-swap

The hyperscan TLD pattern suffix (?:[^a-zA-Z0-9]|$) was consuming the
boundary character, causing match length to be one character too long.
This broke URL detection in url_tld_end() after workers hot-swapped
from ACISM to hyperscan.

Root cause: For input "adobesign.github.io/?u=xxx":
- ACISM pattern ".github.io" -> match length 10, p points to "/"
- Hyperscan pattern "\.github.io(?:[^a-zA-Z0-9]|$)" -> match length 11,
  p points to "?" (one past expected)

url_tld_end() checks if *p == '/' which failed for hyperscan.

Fix: Remove suffix from hyperscan TLD patterns and add boundary checking
in rspamd_multipattern_hs_cb(), mirroring what ACISM callback already does.
This ensures consistent match length between both backends.