Join our Newsletter — 33% off our NHI Course
Home› Guides› XS-Leaks Guide: Cross-Site Leak Attacks and Browser Defences
Guide Web & API Security

XS-Leaks Guide: Cross-Site Leak Attacks and Browser Defences

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, edited by Lalit Choda Updated 27 October 2026 11 min read
On this page

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-origin stops attacker pages from getting a usable window handle via window.open(), which framing protection alone does not.
  • SameSite cookies are defence in depth. Strict removes most leaks that rely on authenticated cross-site requests, but Lax still 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:

  1. 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.
  2. 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.
  3. An observable leak channel: something the browser exposes across origins, such as a load or error event, 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

FamilyWhat the attacker observesWhat it can revealPrimary defences
Error eventsWhether an embedded resource fires load or errorLogged-in state, whether a user ID or private URL existsFetch Metadata resource isolation, SameSite cookies, CORP, unguessable tokens in sensitive URLs
Frame countingNumber of frames via window.length on a framed or opened pageWhether a search returned results, page stateCOOP same-origin, frame-ancestors and X-Frame-Options
ID attribute and focusWhether a blur event fires when a URL fragment focuses an elementPresence of account features, for example a "Pro account" buttonFraming protection, rejecting Sec-Fetch-Dest: iframe
Navigations and redirectsWhether a load is redirected, often detected through the attacker's own CSPRole or sign-in state where servers redirect based on itNavigation isolation, avoiding state-dependent redirects; MDN lists no complete defence
Cache probingLoad time or cache state of a resource only some users fetchVisited pages, role-specific assetsPer-user unguessable resource URLs, Cache-Control: no-store, browser cache partitioning
TimingHow long a cross-site request or render takesSize or existence of search resultsResource isolation, constant-shape responses for sensitive queries
postMessageMessages sent with a wildcard targetOrigin to a window the attacker controlsMessage contents directlyExact 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/1234 that 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-Mode and Sec-Fetch-Dest for sensitive endpoints. Bursts of cross-site requests with destinations such as script, image or iframe against 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=Strict versus Lax.
  • 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.

  1. Set SameSite on session cookies: Strict if you can, Lax if you must. With Strict, 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.
  2. Prevent framing: send CSP frame-ancestors 'none' or a specific allowlist, plus X-Frame-Options for older browsers. Browsers that support frame-ancestors ignore X-Frame-Options when both are present, so there is no conflict. See the Clickjacking Guide.
  3. Send COOP: Cross-Origin-Opener-Policy: same-origin on every document. Any value other than unsafe-none places your page in a separate browsing context group when another origin opens it. Where your own pages rely on pop-ups to third parties, use same-origin-allow-popups and review which sites you open.
  4. Send CORP: Cross-Origin-Resource-Policy: same-site or same-origin on resources that should not be embedded by other sites, which stops the browser loading them into attacker pages.
  5. Deploy a Fetch Metadata resource isolation policy: allow requests with no Fetch Metadata headers (older clients), allow Sec-Fetch-Site values same-origin, same-site and none, allow simple GET top-level navigations, exempt endpoints explicitly meant for cross-origin use, and reject the rest. Add Vary: Sec-Fetch-Dest, Sec-Fetch-Mode, Sec-Fetch-Site so caches do not serve the wrong variant. Start in log-only mode, then enforce. See the Fetch Metadata and Resource Isolation Policy Guide.
  6. 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.
  7. 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.
  8. Fix postMessage: always pass an exact targetOrigin, never *, and validate event.origin on receipt.
  9. 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, use same-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

DefenceOWASP ASVS 5.0NIST SP 800-53 Rev 5Other
SameSite cookiesV3.3.2SC-23 Session AuthenticityOWASP XS-Leaks Cheat Sheet
frame-ancestors, X-Frame-OptionsV3.4.6AC-4 Information Flow EnforcementMDN framing protection
COOPV3.4.8SC-39 Process Isolationxsleaks wiki COOP
Resource isolation (Fetch Metadata, CORP)V3.5.8AC-4W3C Fetch Metadata Request Headers
Separate hostnames for separate apps and user contentV3.5.4SC-39CAPEC-462 (search timing) risk reduction
postMessage origin checksV3.5.5AC-4OWASP XS-Leaks Cheat Sheet

Practitioner checklist

  • Session cookies are SameSite=Strict, or Lax with a documented reason.
  • Every authenticated HTML response sends Cross-Origin-Opener-Policy: same-origin (or same-origin-allow-popups where 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 Vary on 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 targetOrigin and receivers check event.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

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

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Researched and written by the NHI Mgmt Group editorial team using AI tools, under the editorial direction of Lalit Choda. Facts are drawn from the sources listed on this page and checked by our automated quality process. Last updated 27 October 2026. Spotted an error? Use our contact page.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM and Agentic AI security. nhimg.org

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick the PDF box to continue.