Spam filter: decode QR codes in images and check their URLs (quishing) #401

Closed
opened 2026-11-16 15:15:44 +00:00 by jcoffey-dev · 1 comment
Owner

Suggested on the forum (https://community.coffeylabs.org/t/292) by StefanSa. Planned for after 27.1.

Phishing mail increasingly hides the link in a QR code image so URL checks never see it. Today the spam filter only collects URLs from the subject, text and HTML parts and text attachments (crates/spam-filter/src/analysis/url.rs, spam_filter_analyze_url); images aren't decoded at all.

Proposal: decode QR codes in inline images and PNG/JPEG attachments, add the URLs they contain to the URL set with their own location, and let the existing redirector, DNSBL and phishing checks score them, plus a tag for "the message's only link is inside a QR code". A QR code by itself shouldn't add score: invoices, tickets and 2FA setup mail carry them too. Off/on in the spam filter settings, new tags and scores in our bundled rules (3.0.2-inbuxa.N).

Things to settle first:

  • This decodes attacker-supplied images in the SMTP path. Check the size and dimensions before decoding (imagesize is already in the tree), cap the number of images per message, and run the decode off the async workers with a time limit.
  • Crate choice (an image decoder with only the PNG/JPEG features, plus rqrr or rxing); licenses and fuzzing.
  • It won't catch QR codes inside PDFs or drawn with HTML tables or Unicode block characters, which are common ways around exactly this check. Worth deciding whether those are in scope or a later step.
Suggested on the forum (https://community.coffeylabs.org/t/292) by StefanSa. Planned for after 27.1. Phishing mail increasingly hides the link in a QR code image so URL checks never see it. Today the spam filter only collects URLs from the subject, text and HTML parts and text attachments (`crates/spam-filter/src/analysis/url.rs`, `spam_filter_analyze_url`); images aren't decoded at all. Proposal: decode QR codes in inline images and PNG/JPEG attachments, add the URLs they contain to the URL set with their own location, and let the existing redirector, DNSBL and phishing checks score them, plus a tag for "the message's only link is inside a QR code". A QR code by itself shouldn't add score: invoices, tickets and 2FA setup mail carry them too. Off/on in the spam filter settings, new tags and scores in our bundled rules (`3.0.2-inbuxa.N`). Things to settle first: - This decodes attacker-supplied images in the SMTP path. Check the size and dimensions before decoding (`imagesize` is already in the tree), cap the number of images per message, and run the decode off the async workers with a time limit. - Crate choice (an image decoder with only the PNG/JPEG features, plus `rqrr` or `rxing`); licenses and fuzzing. - It won't catch QR codes inside PDFs or drawn with HTML tables or Unicode block characters, which are common ways around exactly this check. Worth deciding whether those are in scope or a later step.
jcoffey-dev added the enhancement
priority
p3
labels 2026-11-16 15:15:44 +00:00
jcoffey-dev self-assigned this 2026-11-16 15:15:44 +00:00
jcoffey-dev added this to the 27.7 milestone 2026-11-16 15:22:45 +00:00
Author
Owner

Thanks to StefanSa for suggesting this in community t/292. Done in #463, and it ships in the next server release candidate.

The spam filter can now read QR codes in a message's pictures (PNG, JPEG, GIF and WebP, attached or as data: images in the HTML) and check each web link in them like the message's other links: blocklists, redirectors, look-alike names and the URL rules. Those links have location qr_code, so a rule can single them out.

  • It's off unless you turn it on, because reading pictures costs some CPU time for each message that has them (a few ms for a bare QR code, around 0.1 s for a full-size phone photo). Turn it on under Settings › Spam filter › Filter settings › Images › Check links in QR codes (scanQrCodes on x:SpamSettings).
  • A message with such a link gets QR_CODE_URL, scored 0 in the bundled rules, since a QR code alone isn't a spam sign. To weigh it anyway, give it a score under Settings › Spam filter › Protection › Scores.
  • Limits: at most 4 pictures per message, each up to 4 MB and 16 megapixels, 1 s and 10 links per message, http and https links only.
  • Not covered: QR codes in PDFs, and ones drawn with HTML tables or text characters.
Thanks to StefanSa for suggesting this in community t/292. Done in #463, and it ships in the next server release candidate. The spam filter can now read QR codes in a message's pictures (PNG, JPEG, GIF and WebP, attached or as `data:` images in the HTML) and check each web link in them like the message's other links: blocklists, redirectors, look-alike names and the URL rules. Those links have `location` `qr_code`, so a rule can single them out. - **It's off unless you turn it on**, because reading pictures costs some CPU time for each message that has them (a few ms for a bare QR code, around 0.1 s for a full-size phone photo). Turn it on under **Settings › Spam filter › Filter settings › Images › Check links in QR codes** (`scanQrCodes` on `x:SpamSettings`). - A message with such a link gets `QR_CODE_URL`, scored 0 in the bundled rules, since a QR code alone isn't a spam sign. To weigh it anyway, give it a score under **Settings › Spam filter › Protection › Scores**. - Limits: at most 4 pictures per message, each up to 4 MB and 16 megapixels, 1 s and 10 links per message, http and https links only. - Not covered: QR codes in PDFs, and ones drawn with HTML tables or text characters.
jcoffey-dev modified the milestone from 27.7 to 27.1 2026-11-19 16:29:46 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: inbuxa/inbuxa-server#401