Repository navigation
Webmail: block remote CSS fetches when remote images are off - #222
Conversation
With remote images off, only <img src> was rewritten. The sanitizer allows <style> and style attributes, so url(), @import, image-set() and img srcset all still fetched — enough for a sender to collect a read receipt, timestamp, and IP from a reader the UI reported as protected. blockRemoteContent() in sanitize.ts now covers every fetch surface in one pass: remote img src becomes the placeholder pixel, srcset with any remote candidate is dropped, and CSS loses url()/@import/ image-set() targets unless they are data: or cid:. CSS comments and escapes are normalized first so split or escaped spellings cannot smuggle a fetch past the patterns, and the comment/@import passes are linear scanners because the natural regexes backtrack quadratically on crafted input. Closes oblien#220
|
thank you for your support
CSS_IMAGE_SET = /…image-set([^;{}]*/ truncates its span at the first ;/{/} - but those are ordinary characters inside a CSS string token, so the browser parses the whole URL and fetches. Worst part: the realistic data: fallback + remote sibling hits this every time (the ; in ;base64 truncates the span before the remote candidate):
CSS_IMAGE_SET keys on the literal substring image-set(; image\2dset( doesn't match, but the browser resolves \2d→- while building the ident and forms a real image-set( function. (The url() form is safe here - CSS_REMOTE_URL is ident-independent - so only the bare-string form leaks.)
also Correctness (false positives / broken render)
suggested fix :
|
|
Thanks for the feedback, will update the gaps |
Bypasses (review on oblien#222): - image-set() spans are now found by a quote-aware balanced-paren scan instead of a regex ended at ;/{/} — those are ordinary characters inside a string token, so the regex span truncated before a remote candidate (data:…;base64 fallback + remote 2x leaked every time). - Escape decoding now includes \2d (-), so image\2dset( normalizes to image-set( and cannot dodge the ident match. - <img> attributes are walked sequentially instead of regexing src= out of the raw tag, so a decoy src= inside an alt/title value can no longer shield the real remote src. False positives: - Fragment-only url(#grad) is exempt — a same-document lookup, not a fetch. - stripImports skips string contents, so content:"@import" is no longer treated as an at-keyword. - image-set strings are rewritten by a sequential token scan; the regex re-anchored on the closing quote of an exempt string and mangled all-inline sets like image-set("data:a" 1x, "data:b" 2x).
|
Thanks for the sharp review — all six reproduce on the previous revision, and all six are fixed in faa955d. Bypasses:
False positives:
All previous behavior holds (34 checks including your five cases, the original issue repro, adversarial-input timing on the new scanners, and an end-to-end pass through the sanitizer). |
|
perfect, gonna check last time then merge, ty |
|
also are you on x ? would love to know your handle :" |
|
I just DMed you |
8138b1e
into
oblien:feat/bugfix-batch-2026-09-16
With remote images disabled, current webmail still fetches CSS tracking URLs through escaped
url()names/schemes,image-set()string candidates, and CSS-variable substitution. Relative image URLs also bypass its HTTP-only check. This repair updates the existing contributor PR for the current mail server and integrates it into the bug batch in #892.blockRemoteContentremains the single policy entry point after HTML sanitization. It uses the existing parsed HTML tree and a CSS syntax tree, preserving the current XSS protections instead of reinstating style blocks. Fetching URLs and image-set candidates are neutralized; inline attachments, literal text, ordinary layout/color declarations, and inline image-set MIME metadata survive. The srcset scanner preserves commas inside data URLs. CSS variables/attribute substitutions and unparseable styles fail closed while remote images are blocked; explicitly enabling images uses the original sanitized styles.Validation: 77 mail-server regression cases and TypeScript pass; 11 regressions fail against main. An isolated Chromium read-pane probe reproduced four bypasses on main, then confirmed zero network requests with blocking enabled and successful positive controls with images enabled. Tracker requests were intercepted and aborted locally.
Fixes #220 when this reaches main. This PR targets the integration branch, not main.