A phishing message can carry its link only as a QR code in an image
("quishing"), where the URL checks never look: they read the subject and
text parts. Requested in community t/292.
With the new x:SpamSettings scanQrCodes setting on (off by default), the
URL analysis reads QR codes in the message's images and puts each web link
it finds through the same checks as the message's other links (DNSBLs,
redirectors, homographs, IP hosts, URL rules), at a new location qr_code,
so a rule can tell a link came from a QR code. A message with such a link
gets QR_CODE_URL, scored 0.0 in the bundled rules (3.0.2-inbuxa.2): a QR
code alone isn't a spam sign, and an administrator can give it a score.
What's read (crates/spam-filter/src/analysis/qr.rs):
- image parts, whatever their declared type, and data: images in HTML,
sniffed from the bytes as PNG, JPEG, GIF or WebP; nothing else
- at most 4 images per message, each at most 4 MB and 16 megapixels (the
size comes from the header, before anything is decoded) and at least
64 px a side; decoding has image's allocation limits set
- images over 1600 px are scaled down before they're scanned
- no image is started after 1 s; at most 10 links, http and https only
- decoding runs on a blocking thread
New dependencies: image 0.25 (png, jpeg, gif, webp only; no default
features) and rqrr 0.11 (no default features, fed greyscale pixels).
Both are permissive ((MIT OR Apache-2.0); rqrr also ISC), as are the 16
crates they bring.
SpamSettings is stored at version 1 with the setting after every existing
field; settings stored before read back with scanning off.
Test: qr.rs unit tests (a link read from a PNG and from a JPEG flyer, none
from a JPEG with no code, a data: URL, the size and format caps, only web
links kept, links kept once); the antispam url test reads a code in an
image part, in an octet-stream attachment and in a data: URL, each giving
QR_CODE_URL plus SUSPICIOUS_URL from the IP link's URL check, and nothing
for a photo with no code; a registry test for the stored versions.
Fixes #401
Bundled spam filter rules
spam-filter-rules.json.gz holds the server's default spam rules. The server
embeds it (crates/common/src/manager/spam_rules.rs) and loads it whenever no
other rules source is configured, so a release scores mail with the rules it
was tested with, offline and with nothing to fetch. The rules URL setting
stays an operator override.
The file started as the published rules of
spam-filter v3.0.2. Since
2026-10-28 the fork maintains it here: spam-filter's later releases follow
upstream's 1.0 server (its AI_* tag names, its lookup settings), which this
server doesn't use, so they aren't taken in. BUNDLED_SPAM_RULES_VERSION
names the release the rules started from and the fork's revision of them,
for example 3.0.2-inbuxa.1.
The v3.0.2 rules are dual-licensed MIT or Apache-2.0, Copyright (C) 2024,
Stalwart Labs LLC; the fork takes them under MIT, with the notice in
THIRD-PARTY.md.
They include the scores for the AI classifier's tags (LLM_*, 3.0 for the
high-confidence spam categories, −3.0 for legitimate), which match
docs/spec/features/ai-spam-classification.md.
Changes since v3.0.2
| Revision | Change |
|---|---|
inbuxa.1 |
Scores for the DKIM2 result tags the server already emits (crates/spam-filter/src/analysis/dmarc.rs): DKIM2_ALLOW −0.2, DKIM2_REJECT 1.0, and DKIM2_NA, DKIM2_PERMFAIL, DKIM2_TEMPFAIL 0.0. The values are spam-filter v3.0.3's. |
inbuxa.2 |
QR_CODE_URL 0.0: the tag the URL checks add when a message's images hold a QR code with a web link (#401, crates/spam-filter/src/analysis/qr.rs). A QR code alone isn't a spam sign; its link is scored by the URL checks it goes through, at location qr_code. The tag is listed so an administrator can give it a score. |
Changing the rules
- Edit the JSON (
gunzip -cit; it's one line, keys in their original order) and write it back compact, then compress it without a name or timestamp so the file is reproducible:gzip -n -9. - Bump the revision in
BUNDLED_SPAM_RULES_VERSIONandBUNDLED_SPAM_RULES_APPLIED(spam_rules.rs), and add a row above. - Run the antispam test (
STORE=RocksDb RUST_MIN_STACK=16777216 cargo test -p tests --lib -- smtp::inbound::antispam::antispam --exact) and fix expectations the change affects, knowingly.
On the next start each server loads the new version once. Loading only adds rules and tags that are missing; it never changes an existing one, so an operator's own adjustments survive.