Course contentsShow
← Security
Lesson 1077 of 3,05222. Web Security - Client-Side and SPA SecurityFree lesson

Cross-Tab and Cross-Origin Storage Attacks

Understanding storage events, cross-tab communication risks, and preventing data leakage across browser contexts.

Cross-Tab and Cross-Origin Storage Attacks

You'll learn how attackers exploit browser storage events and cross-tab communication to leak sensitive data between different browser contexts.


What Are Cross-Tab and Cross-Origin Storage Attacks?

Imagine you're in a busy café where everyone can hear conversations at neighboring tables. Similarly, browsers allow different tabs from the same origin to communicate and share storage changes, creating opportunities for attackers to eavesdrop or manipulate data.

These attacks exploit two primary mechanisms:

Storage Events

When one tab modifies localStorage, the browser fires a storage event in all other tabs from the same origin. An attacker who has compromised even a single tab (through XSS or a malicious browser extension) can:

  • Listen for sensitive data being stored by legitimate tabs
  • Inject malicious data that other tabs will read
  • Trigger actions in other tabs by manipulating shared storage

Think of it like leaving sticky notes on a shared bulletin board—everyone from your office (origin) can read and modify them.

Cross-Origin Storage Probing

While the same-origin policy prevents direct access across origins, attackers can infer information about other origins through:

  • Timing attacks on cache or storage operations
  • Storage quota measurements to detect if data exists
  • Side-channel attacks observing browser behavior

Real-World Risk Scenario

A banking site stores a session token in localStorage. An attacker with XSS on a forum subdomain (forum.bank.com) can't directly access the main site's storage (www.bank.com), but if both use a shared parent domain relaxation or poor isolation, data leakage becomes possible.

Key Takeaway: Storage events enable cross-tab communication within the same origin, creating risks when any single tab is compromised; proper origin isolation and avoiding sensitive data in shared storage are essential defenses.