A page on another site cannot read your responses, but it can often observe enough about them, whether they loaded, how many frames they contain, whether they redirected or came from cache, to learn private facts about your logged-in users. These cross-site leaks (XS-Leaks) are a class of browser side-channel attack, not a single bug, and MDN notes there is no single defence that covers them all. The questions they answer look small: is this person logged in, are they an administrator, does their account contain a given email address. For a health, finance or dating service those answers are the sensitive data. This guide explains how XS-Leaks work at a conceptual level, where they show up, how to detect exposure and which browser and server defences close each family. It is for web developers, application security engineers and penetration testers, and it builds on the Client-Side Security Guide.
Key takeaways
- The same-origin policy is not enough. It blocks reading cross-origin responses, but events, timings, window properties and errors still cross the boundary and can carry one bit of state per probe.
- Isolate by default, open by exception. A Fetch Metadata resource isolation policy that rejects unexpected cross-site subresource requests defeats most error-event, timing and cache-probing leaks at the server.
- COOP closes the window reference. Cross-Origin-Opener-Policy set to
same-originstops attacker pages from getting a usablewindowhandle viawindow.open(), which framing protection alone does not. - SameSite cookies are defence in depth.
Strictremoves most leaks that rely on authenticated cross-site requests, butLaxstill allows top-level navigations, which window-based leaks use. - Some leaks have no complete fix yet. MDN notes that leaking redirects with an attacker-side CSP works even against framing protection, so avoid state-dependent redirects on sensitive endpoints.
How the attack works
MDN defines cross-site leaks as attacks in which an attacker's site derives information about the target site, or the user's relationship with it, using web platform APIs that let sites interact. The victim only has to visit an attacker-controlled page while logged in to the target; the attack runs automatically in the victim's browser, and some techniques need the victim to stay on the page for a while.
Every XS-Leak has the same three ingredients:
- A state-dependent difference: the target responds differently depending on the user's state, for example a 200 versus a 404, one iframe versus none, a redirect versus a page, or a cached versus uncached resource.
- A cross-site inclusion method: the attacker page causes the browser to request the target with the user's cookies, by embedding it as a script, image or frame, opening it in a window or navigating to it.
- An observable leak channel: something the browser exposes across origins, such as a
loadorerrorevent,window.length, focus and blur events, a CSP violation event, or timing.
Each probe typically answers a yes or no question. Repeated across candidate values, for example a list of email addresses in a search box or a range of user IDs, those bits add up to identity or private data. The OWASP cheat sheet describes this as inferring answers to questions about the victim's account from seemingly insignificant information exchanged between sites. When the state difference comes from a search feature, the technique is often called XS-Search, and CAPEC catalogues the timing variant as CAPEC-462 Cross-Domain Search Timing.
Main leak families
| Family | What the attacker observes | What it can reveal | Primary defences |
|---|---|---|---|
| Error events | Whether an embedded resource fires load or error | Logged-in state, whether a user ID or private URL exists | Fetch Metadata resource isolation, SameSite cookies, CORP, unguessable tokens in sensitive URLs |
| Frame counting | Number of frames via window.length on a framed or opened page | Whether a search returned results, page state | COOP same-origin, frame-ancestors and X-Frame-Options |
| ID attribute and focus | Whether a blur event fires when a URL fragment focuses an element | Presence of account features, for example a "Pro account" button | Framing protection, rejecting Sec-Fetch-Dest: iframe |
| Navigations and redirects | Whether a load is redirected, often detected through the attacker's own CSP | Role or sign-in state where servers redirect based on it | Navigation isolation, avoiding state-dependent redirects; MDN lists no complete defence |
| Cache probing | Load time or cache state of a resource only some users fetch | Visited pages, role-specific assets | Per-user unguessable resource URLs, Cache-Control: no-store, browser cache partitioning |
| Timing | How long a cross-site request or render takes | Size or existence of search results | Resource isolation, constant-shape responses for sensitive queries |
| postMessage | Messages sent with a wildcard targetOrigin to a window the attacker controls | Message contents directly | Exact targetOrigin, origin checks on receipt (ASVS 5.0 V3.5.5) |
Where it shows up
- Search and filter endpoints: GET-based search in inboxes, CRMs, ticketing systems and admin consoles, where result count or page structure varies with private data. This is the classic XS-Search target.
- Per-user URLs: profile, avatar and API paths such as
/api/users/1234that return success only for the current user, which an error-event probe can enumerate. - Role-based redirects: admin pages that redirect non-admins to a login or error page.
- Embeddable pages: pages with no framing protection, or with feature-dependent element IDs that respond to URL fragments.
- Window-based flows: OAuth, payment and single sign-on flows that open pop-ups and therefore resist strict COOP, and pages that post data to
window.opener. - Shared domains: user-generated content served on the same site as the application, which weakens SameSite cookies and cache partitioning. The xsleaks wiki recommends serving user content that can make network requests from its own registrable domain (eTLD+1).
Impact
MDN highlights two consequences. First, revealing that someone has an account on a sensitive site, for example one about a medical procedure, can expose them to extortion or retaliation. Second, knowing a user's ID or account status makes follow-up phishing more convincing. For organisations the impact is mainly privacy and regulatory: a leak that confirms a person's use of a sensitive service is a disclosure of personal data. Rate XS-Leaks by the sensitivity of the inferred fact, not by the size of the leak. One bit about a mental health app outranks a full leak of public profile fields. See the Same-Origin Policy and Browser Security Model Guide for the isolation model these attacks bypass.
Detection
XS-Leaks run entirely in the victim's browser, and the requests they cause are ordinary authenticated requests, so detection relies on request context headers and on testing.
- Log Fetch Metadata: record
Sec-Fetch-Site,Sec-Fetch-ModeandSec-Fetch-Destfor sensitive endpoints. Bursts ofcross-siterequests with destinations such asscript,imageoriframeagainst API or search endpoints that are never legitimately embedded are a strong signal. The headers are only sent on HTTPS. - Enumeration patterns: many sequential IDs or search terms from one session in a short window, arriving as cross-site subresource loads rather than XHR from your own front end.
- Report-only isolation: deploy a resource isolation policy that logs rather than blocks, which both finds legitimate cross-site consumers and reveals probing.
- Testing: include XS-Leak checks in web application tests: which sensitive endpoints load cross-site with cookies, whether pages are frameable, whether COOP is set, and whether responses differ in status, frame count or redirect by user state. The Web Application Security Testing Guide covers test planning.
Metrics
- Percentage of authenticated HTML responses carrying COOP and
frame-ancestors(ASVS 5.0 V3.4.6, V3.4.8). - Percentage of sensitive endpoints covered by an enforced resource isolation policy.
- Share of session cookies set with
SameSite=StrictversusLax. - Number of state-dependent redirects on sensitive routes (target zero).
- Cross-site requests rejected per day by the isolation policy, trended to spot probing campaigns.
Prevention and hardening
Both MDN and the OWASP cheat sheet recommend layering several defences, because each closes different families. Apply them in this order, which also suits a phased rollout.
- Set SameSite on session cookies:
Strictif you can,Laxif you must. WithStrict, cross-site requests carry no session, so the target returns the same logged-out response to every probe. Chromium-based browsers treat cookies without the attribute as Lax, but set it explicitly. See the Cookie Security Guide. - Prevent framing: send CSP
frame-ancestors 'none'or a specific allowlist, plusX-Frame-Optionsfor older browsers. Browsers that supportframe-ancestorsignore X-Frame-Options when both are present, so there is no conflict. See the Clickjacking Guide. - Send COOP:
Cross-Origin-Opener-Policy: same-originon every document. Any value other thanunsafe-noneplaces your page in a separate browsing context group when another origin opens it. Where your own pages rely on pop-ups to third parties, usesame-origin-allow-popupsand review which sites you open. - Send CORP:
Cross-Origin-Resource-Policy: same-siteorsame-originon resources that should not be embedded by other sites, which stops the browser loading them into attacker pages. - Deploy a Fetch Metadata resource isolation policy: allow requests with no Fetch Metadata headers (older clients), allow
Sec-Fetch-Sitevaluessame-origin,same-siteandnone, allow simple GET top-level navigations, exempt endpoints explicitly meant for cross-origin use, and reject the rest. AddVary: Sec-Fetch-Dest, Sec-Fetch-Mode, Sec-Fetch-Siteso caches do not serve the wrong variant. Start in log-only mode, then enforce. See the Fetch Metadata and Resource Isolation Policy Guide. - Consider navigation isolation for the most sensitive apps: the xsleaks wiki describes a stricter policy that blocks cross-site navigations to all but allowlisted entry pages. It can break inbound links, so the wiki suggests a confirmation step instead of a hard block.
- Design out the differences: move search to POST behind CSRF protection, return the same status and shape for "not found" and "not yours", avoid redirects that depend on role, and put unguessable per-user tokens in URLs of role-specific assets. For cache-sensitive resources use
Cache-Control: no-store. - Fix postMessage: always pass an exact
targetOrigin, never*, and validateevent.originon receipt. - Separate user content: host user-generated or third-party content on a separate registrable domain so SameSite and cache partitioning treat it as cross-site (ASVS 5.0 V3.5.4).
Browser cache partitioning by top-level site now ships in most browsers, according to the xsleaks wiki, but it does not protect against requests from your own subdomains or window navigations, and applications should not rely on it. Roll back any header that breaks a legitimate flow by relaxing that one header for that one route, not by removing the policy globally. The Security Headers Guide covers COOP, CORP and CSP deployment.
Decision guidance
- Public content sites: COOP, framing protection and SameSite Lax are usually enough; few states are worth leaking.
- Applications holding sensitive personal data: add an enforced resource isolation policy and SameSite Strict, and review every search and redirect for state-dependent differences.
- Sites that must be embedded or open pop-ups: allowlist embedding origins in
frame-ancestors, usesame-origin-allow-popups, and compensate with Fetch Metadata checks on the embedded endpoints. - Large estates: enforce isolation in a shared middleware or at the edge so every service inherits it, with per-route exemptions recorded centrally.
Framework mapping
| Defence | OWASP ASVS 5.0 | NIST SP 800-53 Rev 5 | Other |
|---|---|---|---|
| SameSite cookies | V3.3.2 | SC-23 Session Authenticity | OWASP XS-Leaks Cheat Sheet |
| frame-ancestors, X-Frame-Options | V3.4.6 | AC-4 Information Flow Enforcement | MDN framing protection |
| COOP | V3.4.8 | SC-39 Process Isolation | xsleaks wiki COOP |
| Resource isolation (Fetch Metadata, CORP) | V3.5.8 | AC-4 | W3C Fetch Metadata Request Headers |
| Separate hostnames for separate apps and user content | V3.5.4 | SC-39 | CAPEC-462 (search timing) risk reduction |
| postMessage origin checks | V3.5.5 | AC-4 | OWASP XS-Leaks Cheat Sheet |
Practitioner checklist
- Session cookies are
SameSite=Strict, orLaxwith a documented reason. - Every authenticated HTML response sends
Cross-Origin-Opener-Policy: same-origin(orsame-origin-allow-popupswhere justified). - Pages that need not be embedded send
frame-ancestors 'none'and X-Frame-Options. - Sensitive resources send CORP, and a Fetch Metadata resource isolation policy is enforced with
Varyon the Sec-Fetch headers. - Search, lookup and per-user endpoints return the same status and response shape regardless of private state, and do not redirect based on role.
- Role-specific assets use unguessable per-user URLs or
Cache-Control: no-store. - postMessage calls use an exact
targetOriginand receivers checkevent.origin. - User-generated content is served from a separate registrable domain.
- Web application tests include XS-Leak checks, and cross-site rejections are logged and trended.
Standards and references
- MDN: Cross-site leaks (XS-Leaks)
- OWASP: Cross-site leaks Cheat Sheet
- XS-Leaks Wiki: Cross-site leaks catalogue and defences
- XS-Leaks Wiki: Resource Isolation Policy
- XS-Leaks Wiki: Cross-Origin-Opener-Policy
- W3C: Fetch Metadata Request Headers
- OWASP: Application Security Verification Standard 5.0
- MITRE CAPEC: CAPEC-462 Cross-Domain Search Timing
Related NHI Mgmt Group resources: Client-Side Security Guide · Fetch Metadata and Resource Isolation Policy Guide · Security Headers Guide · Clickjacking Guide · Side-Channel Attacks Guide