← XS-Leaks lesson
Web InfrastructureXS-LeaksAdvanced50 min+150 XP

Cache the Color

The SwiftShip Search Suggestions oracle answers differently for a matching prefix. Report the attacker page to the bot and let it brute-force the protected secret through a cross-site side channel.

“The page could not read the response, but it could tell which character made the image load.”

HTML Living Standard: origin, fetch metadata and resource loadingFetch Standard: opaque responses and CORSRFC 6265: HTTP State Management MechanismOWASP Web Security Testing Guide: client-side testingCWE-203: Observable Discrepancy
The story
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.

Your objective
  • Inspect the oracle response difference
  • Choose a side channel that exposes the difference cross-origin
  • Brute-force the secret one character at a time
  • Capture the flag
Boundary under test

Attacker origin to victim origin

Field guide · request anatomy

Where to look before you type a payload

01Depend

A victim endpoint returns a different status, length, timing or resource type depending on a secret or the victim's state.

02Observe

The browser loads the endpoint as an image, script, stylesheet or frame and exposes onload, onerror, timing or frame count.

03Reduce

The attacker maps the observable to one bit: match or miss, exists or absent, visited or not.

04Search

A script tests candidate characters or binary-search branches, repeating measurements to reduce noise.

Progressive hints

Open one hint at a time. The first two build the model; the last two point at the boundary.

Hint 1

Find the endpoint whose response differs for a matching prefix and observe which cross-origin signal changes.

Hint 2

Images, scripts and stylesheets expose onload and onerror without CORS; choose the element that matches the oracle's response type.

Hint 3

The oracle returns a different response for a matching prefix. Use an stylesheet link and onload/onerror to test one character at a time from XS-.

Hint 4 · near the answer

Report the attacker page to the bot; it automates the search and posts the recovered secret to /collect.

Guided workbench

Observe → Hypothesize → Test → Prove → Explain

This is the same loop a reviewer expects in a report. Your draft stays in this browser; nothing is submitted until you choose to export it.

0/15steps complete
Observe0/3
Hypothesize0/3
Test0/3
Prove0/3
Explain0/3

Evidence log

Write for a reviewer who was not in the room. Every claim needs a request, response or state change behind it.

Preview the evidence report
# Lab evidence report — Cache the Color

- Family: XS-Leaks
- Lab ID: web-xsleaks-color-cache
- Date: 2026-12-05

## Workflow

### Observe

- [ ] Open "Cache the Color" and record the entry point, the HTTP method and the role you are given.
- [ ] List every parameter, header, cookie and object identifier the normal flow exposes.
- [ ] Save a baseline response: status, body shape, timing and the fields that change by user.

### Hypothesize

- [ ] Name the server decision that protects the entry point, and the evidence it should use.
- [ ] Use the clue as a constraint, not an answer: Use a stylesheet link as the oracle and brute-force the secret one character at a time from the attacker origin.
- [ ] Predict the exact status, body or state change that would prove the decision is missing.

### Test

- [ ] Start from the baseline and change one value: the oracle's cross-site onload/onerror difference.
- [ ] Keep the request replayable; vary encoding, method or identifier location only after the first result.
- [ ] Capture the full request and response for the winning attempt, including the flag.

### Prove

- [ ] Capture the flag and name the exact foreign object, role or state change it proves.
- [ ] Repeat from a clean session and confirm the result is not cached or stale.
- [ ] State impact precisely: what data or action did you actually obtain?

### Explain

- [ ] State the root cause without naming the payload: which decision failed?
- [ ] Name the control that prevents recurrence and the layer where it belongs.
- [ ] Write one regression test that fails before the fix and passes after it.

## Evidence

### Target and baseline

_Not recorded._

### Hypothesis

_Not recorded._

### Winning request

_Not recorded._

### Proof

_Not recorded._

### Root cause

_Not recorded._

### Control and regression test

_Not recorded._

## Analyst conclusion

The proof demonstrates the missing control above. The regression test should fail against the vulnerable behavior and pass after remediation.
Solution and debrief
Locked until you capture the flag.

The full request, the reasoning and the debrief unlock after a successful capture. That is deliberate: struggle first, then consolidate.

What a reviewer will ask

False positives to rule out

  • 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.

Regression tests to name

  • Match and miss are indistinguishable: Status, length, content type and timing are indistinguishable within measurement noise
  • Cross-origin resource is blocked: The load fails and onerror fires for both match and miss
  • Authorization is required: The request is rejected before any secret-dependent branch
The defender's move
  • 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.
See the secure-code pattern and all 4 regression tests →
الخلاصة

XS-Leaks هي قنوات جانبية حول سياسة same-origin. المهاجم لا يقرأ جسم الاستجابة، لكنه يرى نجاح تحميل صورة أو سكربت أو ورقة أنماط، أو فرق التوقيت، أو عدد الإطارات. إذا اعتمدت هذه الإشارة على سر، يمكن إعادة بناء السر بتًا بعد بت. الحل: اجعل الردود متطابقة للمطابقة وعدمها، وأضف CORP وCOOP، واشترط المصادقة والتفويض، واختبر التطبيق بنفس أدوات onload والتوقيت والكاش.