Cross-site leaks are side channels around the same-origin policy. The attacker cannot read the response, but the browser still exposes whether a resource loaded, how long it took, whether a frame was created, or whether a cache entry existed. If that observable bit depends on a secret, the secret can be reconstructed one bit at a time.
Some HTML elements such as images, scripts and stylesheets can load cross-origin without CORS. Their onload and onerror events reveal whether the request succeeded, even though the response body stays unreadable. Search suggestions, redirects, cache behavior, frame counts and error pages can all become boolean oracles. An attacker page automates thousands of queries and combines the bits into a secret, an identity or a private state.
Defenders focus on the response body and forget that the browser exposes metadata around it. The attacker does not need to read the secret; one bit per request is enough.
What is actually at stake?
Before touching a payload, map the assets, the actors and the boundary that is supposed to protect them. A finding only becomes a vulnerability when you can connect the failed boundary to a real asset.
Assets
- Search suggestions that reveal whether a private term exists
- Account recovery and invitation endpoints that reveal identity
- Private documents, avatars and attachments whose existence is sensitive
- Cached pages that reveal the victim's recent activity
- Role, tenant or permission state exposed through response differences
Actors
- Attacker who can run JavaScript on another origin
- Malicious advertisement or third-party widget embedded in a trusted page
- Attacker who can send links to a victim and observe browser behavior
- Automated bot that runs the oracle search at scale
Trust boundaries
- Attacker origin to victim origin
- Browser resource loader to response status
- Response body to observable metadata
- Cache to cross-origin timing
- Victim session to attacker-controlled page
Abuse cases
- Use an image onload to test whether a search prefix matches a private term
- Use a script onload to turn a 200/404 difference into a boolean oracle
- Use a stylesheet load to brute-force a secret character by character
- Use frame counts or window.length to infer whether a page contains a sensitive widget
- Use cache timing to detect whether the victim visited a private URL
Follow the decision, not the payload
Every family has a moment where trusted data becomes an authorization, parsing or state decision. Learn to point at that moment in the request path.
- 01
Depend
A victim endpoint returns a different status, length, timing or resource type depending on a secret or the victim's state.
- 02
Observe
The browser loads the endpoint as an image, script, stylesheet or frame and exposes onload, onerror, timing or frame count.
- 03
Reduce
The attacker maps the observable to one bit: match or miss, exists or absent, visited or not.
- 04
Search
A script tests candidate characters or binary-search branches, repeating measurements to reduce noise.
- 05
Reconstruct
The bits are combined into a secret, identity or private state and exfiltrated to the attacker origin.
XS-Leaks and the browser as a cross-site oracle
XS-Leaks Wiki (xsleaks.dev) and public browser security researchSecurity researchers catalogued a family of cross-site leaks that abused browser-observable differences around the same-origin policy. The XS-Leaks Wiki documents onload, timing, cache, frame-count and error-based channels used against real applications.
Attackers built pages that loaded victim endpoints as images, scripts or stylesheets and used onload/onerror as a boolean. Search suggestions, login state and private resource existence were common targets; some attacks reconstructed identifiers character by character.
Depending on the oracle, an attacker could learn whether a user had an account, whether a private term existed, whether a document was present, or the value of a secret prefix. The leaks often required no user interaction beyond visiting a page.
Applications returned distinguishable responses for sensitive states and did not apply cross-origin isolation headers, so the browser exposed a reliable side channel even though the response body remained unreadable.
Make sensitive responses indistinguishable, apply CORP and COOP, require authorization for every state-dependent response, avoid secrets in URLs and cache keys, and test with onload, timing and cache probes.
Read it as a chain: discovery → failed decision → impact → fix. Then ask which link would have broken earliest.
A repeatable testing sequence
- Find an endpoint whose status, size, timing or frame behavior depends on a secret or on the victim's state.
- Determine which observable the browser exposes cross-origin: onload, onerror, timing, window.length, cache hit or download behavior.
- Build a page that tests one candidate at a time and records the observable bit.
- Automate prefix or binary search and reconstruct the secret without reading any response body.
- Prove the leak with the recovered value and document why each observable bit depended on protected state.
Where smart people get fooled
- A cross-origin fetch that returns an opaque response does not expose the status; a side channel such as an image or stylesheet is needed.
- Timing differences can be noise; repeat measurements and separate the signal from network jitter.
- A 404 page that is the same size as a 200 page may still leak through load timing or cache state.
- CORP, COOP, COEP and fetch metadata can close the channel; verify the actual headers instead of assuming the oracle works.
What would the logs show?
A control is stronger when someone can see it fail. These signals are starting points for a detection rule, not a complete SIEM use case.
- Endpoints returning 200/404 or different content types based on a search prefix or private identifier
- Sensitive pages served without Cross-Origin-Resource-Policy
- High volumes of cross-origin image, script or stylesheet requests to one endpoint from a single client
- Repeated requests with one-character query variations
- Cache hits or timing differences correlated with private state
index=web sourcetype=access_combined | eval probe=if(match(uri, "[?&](q|query|prefix|term)=.{1,12}(&|$)"),1,0) | where probe=1 | stats count values(uri) by clientip, status | where count > 50Fix the decision, then prove it stays fixed
- Make sensitive endpoints return indistinguishable responses for matches and misses, including status, length and timing.
- Send Cross-Origin-Resource-Policy: same-origin and Cross-Origin-Opener-Policy: same-origin on sensitive resources.
- Require authentication and authorization for every state-dependent response, and avoid putting secrets in URLs or cache keys.
- Use fetch metadata and same-site cookies, and test the deployed app with the same onload, timing and cache probes an attacker would use.
app.get('/suggest', (req, res) => {
const match = terms.some((term) => term.startsWith(req.query.q));
if (match) return res.status(200).send('match');
return res.status(404).send('no');
});app.get('/suggest', requireUser, (req, res) => {
const match = terms.some((term) => term.startsWith(req.query.q));
res.setHeader('Cross-Origin-Resource-Policy', 'same-origin');
res.setHeader('Cache-Control', 'private, no-store');
res.setHeader('Vary', 'Cookie');
return res.status(200).json({ suggestions: match ? buildSuggestions(req.query.q) : [] });
});Do not expose a match/miss difference through status, length or timing. Require authorization, apply CORP and COOP, avoid caching personalized responses, and return a uniform response shape.
Regression tests a reviewer would ask for
Match and miss are indistinguishable
GivenA search prefix that matches a private term and one that does not
WhenBoth requests are made by an authenticated user
ThenStatus, length, content type and timing are indistinguishable within measurement noise
Cross-origin resource is blocked
GivenAn attacker origin loads the sensitive endpoint as an image or script
WhenThe browser applies CORP
ThenThe load fails and onerror fires for both match and miss
Authorization is required
GivenAn unauthenticated request to the suggestion endpoint
WhenThe server evaluates the query
ThenThe request is rejected before any secret-dependent branch
No cache side channel
GivenA personalized response to a private URL
WhenThe attacker probes the same URL from another context
ThenThe response is private, no-store and does not reveal a prior visit
What this finding is not
Strong testers kill their own findings before someone else does. These are the shortcuts that turn a real bug into a weak report — or a false alarm into a wasted escalation.
- The endpoint returns the same status, length and timing for matches and misses; a theoretical side channel is not a finding.
- The response is protected by CORP or COOP and the cross-origin element cannot load it.
- The oracle only reveals public data that any unauthenticated user can read directly.
- A timing difference disappears after repeated measurements and cannot distinguish candidates beyond noise.
Terms you should be able to use precisely
- XS-Leak
- A cross-site leak that uses browser-observable metadata to infer information about another origin.
- Opaque response
- A cross-origin response whose body and status are hidden from JavaScript by CORS.
- Boolean oracle
- An endpoint or behavior that reveals one bit, such as match versus miss.
- CORP
- Cross-Origin-Resource-Policy: a header that prevents other origins from loading a resource.
- COOP
- Cross-Origin-Opener-Policy: a header that isolates a browsing context from cross-origin window references.
- Cache probing
- Inferring whether a resource was cached, and therefore visited, by measuring load timing or behavior.
Answer these without reciting a payload
Why can an attacker leak data without reading the response body?
The browser exposes metadata such as load success, timing and frame count around a cross-origin request. If that metadata depends on a secret, it becomes an oracle.
Which headers reduce XS-Leak risk?
Cross-Origin-Resource-Policy limits who can load a resource, COOP isolates window references, and COEP helps enable cross-origin isolation. They complement, not replace, uniform responses and authorization.
How do you test for an XS-Leak safely?
Build a local page that loads the endpoint as an image, script and stylesheet, compare match and miss, and measure timing and cache behavior. Confirm the difference is stable before treating it as a finding.
Can you separate the mechanism from the payload?
Four questions, graded on the server. Answers and explanations are released only after you submit, and signed-in learners keep a best score.
XS-Leaks لا تحتاج قراءة جسم الاستجابة. المتصفح يكشف نجاح تحميل صورة أو سكربت، أو التوقيت، أو عدد الإطارات، فإذا اعتمدت هذه الإشارة على سر يصبح كل طلب بتًا واحدًا. المثال الكلاسيكي: اقتراحات بحث تعيد 200 لبادئة مطابقة و404 لغيرها، فيبني المهاجم السر حرفًا بحرف. الحل: اجعل الردود متطابقة في الحالة والطول والتوقيت، واشترط المصادقة والتفويض، وأضف CORP وCOOP، وامنع تخزين الردود الشخصية، واختبر التطبيق بنفس قنوات onload والتوقيت والكاش.
If the response body is encrypted and unreadable, can the browser still leak a secret through status, size or timing?