← Lab /Security & privacy

Webmail CSS sanitizers can be bypassed to steal tokens and hijack UI

Crafted CSS in email messages can break out of webmail sanitizers to exfiltrate authentication tokens, control browsers, and steal passwords across multiple providers.

Security & privacy PortSwigger Research 6 Aug 2026 Attack Prototype evidence

Published as “CSS:the bomb inside your inbox”

Why it matters

Webmail providers need to tighten CSS sanitization and consider sandboxing email content to prevent data theft and UI hijacking.

Summary

The researcher examined popular webmail clients (Yahoo, AOL, Fastmail, ProtonMail, Gmail, Outlook) and identified discrepancies between CSS sanitizers and browser rendering. By abusing allowed CSS properties, label elements, pseudo-elements, attribute selectors, and font-face tricks, they demonstrated token exfiltration from services like Medium, UI takeover in Outlook, and indirect prompt injection in OpenAI's Atlas browser. The attacks were validated on real-world services, but effectiveness varies by browser and CSP settings.

What they found 3

  1. Outlook contains a bug that allows an email to control its UI via a label element.

    “I found a real bug in Outlook which would enable me to control Outlook's UI from an email message.”

  2. Firefox permits inline style tags and background image requests, enabling token exfiltration via CSS.

    “Firefox allows inline style tags and background image requests.”

  3. CSP blocks @import statements, but Outlook's sanitizer treats the import as part of a media query, allowing it to pass.

    “The deeper understanding is that Outlook's sanitizer thinks the import is part of the media query! This is why it is allowed.”

Caveats 7

  • Chrome rewrites inline style blocks into style attributes, reducing attack surface.
  • Safari drops style tags entirely, preventing the described CSS tricks.
  • Content Security Policy (CSP) blocks external resource requests, thwarting @import-based payloads.
  • Techniques rely on browsers that allow inline style tags (e.g., Firefox); other browsers mitigate the attacks.
  • CSP can block external resource requests, limiting exfiltration via background URLs.
  • Token-brute-forcing works only for 5-character prefixes and suffixes; full 12-character tokens require additional steps.
  • The keylogger approaches depend on allowing select menus and certain CSS selectors (:has, :checked) which may be blocked by stricter sanitizers.

What’s new here 4

  • Label-for attribute abuse to trigger Outlook UI actions from email.
  • Using :before/:after pseudo-elements to hide malicious payloads from the victim while exposing them to AI browsers.
  • Nested attribute selectors to brute-force 12-character tokens with minimal CSS.
  • CSS-based keylogger techniques leveraging selectors like :has and animation-driven font-size changes.