Skip to content

Independent cybersecurity briefing

Latest

RSS
Breaches, bounties, zero-days, and AI.

Bug Bounty Write Ups

One Missing Anchor, One Flickr XSS

A 2013 Flickr mobile bug shows how an unanchored URL check plus CORS let an outside page inject script

Adam Hale, ZeroDay Times editorBy Adam Hale3 min read

Still life for “One Missing Anchor, One Flickr XSS”: a magnifier and a sealed envelope, warm paper, Flickr mark, signal CASE. [ BUG BOUNTY ] badge.

AI-generated illustration

AI disclosure: This article was drafted with AI assistance as an analytical case study of a public disclosure. It is not my own discovery.

A URL allowlist that only asks “does this string contain our domain?” is not an allowlist. Jack Whitton found that Flickr’s mobile site loaded page content from a path in the URL fragment, validated it with a regex that was not anchored to the start, and rendered the response as HTML. With CORS, that meant an attacker-hosted page could become script running on m.flickr.com.

Disclaimer: * Educational and defensive use only. The researcher reports Flickr fixed the issue. This article intentionally omits reproduction details and payloads.*

Vulnerability Overview

  • Type: DOM-based cross-site scripting via flawed client-side URL validation
  • CWE (analytical mapping, not from the source): CWE-79, CWE-20
  • CVE: Not reported
  • Severity/CVSS: Not reported. Bounty: Not reported

What Happened (high level)

The mobile site was a single-page app of its era: navigation lived in location.hash, and JavaScript fetched the matching page over AJAX and swapped it in.

To stay on its own origin, the loader did two things. It ensured the path began with a slash, and it ran a regex meant to confirm the target was m.flickr.com. The regex was not anchored, so any URL that merely contained the hostname somewhere passed. A protocol-relative URL starting with a double slash also satisfied the “leading slash” rule while pointing at a different host.

Before CORS, a cross-origin AJAX request would simply fail, so the flaw might have looked harmless. Browsers with CORS will complete the request if the remote server opts in with the right response headers, and an attacker controls their own server’s headers. The fetched markup was then written into the page with innerHTML, executing in Flickr’s origin.

Flickr fixed it by anchoring the regex and adding a separate check rejecting double-slash URLs, as Whitton describes.

Impact

The post does not detail impact, but my assessment is standard for XSS: script in m.flickr.com’s origin can act as the logged-in user, reading whatever the mobile site shows them and performing actions they could perform. Delivery needed only a crafted link, since the payload source lived in the URL fragment.

Remediation & Defense-in-Depth (my own analysis)

1. Parse, then compare. Use the URL parser and compare the resolved origin exactly; never regex-match raw strings.

2. Prefer route names over URLs. Map fragment values to an internal route table so arbitrary hosts never enter the fetch.

3. Don’t render fetched HTML with innerHTML. Return data and build DOM safely, or sanitize with a vetted library.

4. Add a strict Content Security Policy. Restrict connect-src to your own origin so the browser refuses foreign fetches even if validation regresses.

// Pseudocode: resolve fragment to a same-origin path before fetching
const ROUTES = new Set(["/photos", "/explore", "/groups", "/settings"]);
function resolveFragment(hash) {
  const raw = decodeURIComponent(hash.replace(/^#/, ""));
  let url;
  try {
    url = new URL(raw, window.location.origin);   // handles "//host" too
  } catch {
    return null;
  }
  if (url.origin !== window.location.origin) return null;  // exact match
  const base = "/" + url.pathname.split("/")[1];
  return ROUTES.has(base) ? url.pathname + url.search : null;
}
async function loadPage(hash) {
  const path = resolveFragment(hash);
  if (!path) return showNotFound();
  const data = await fetch(path, { credentials: "same-origin" }).then(r => r.json());
  renderSafely(data);                               // DOM APIs, no innerHTML
}

Key Takeaways

  • Unanchored regexes and substring checks are not origin validation.
  • CORS changed old assumptions: cross-origin fetches can succeed when the attacker owns the server.
  • Treat any fetched markup as untrusted, even from paths you think you own.

Credit & Sources

Research by Jack Whitton: Abusing CORS for an XSS on Flickr (12 December 2013). Discovered via Awesome-Bugbounty-Writeups index. Facts come from that post; analysis, code and remediation are original suggestions.

First published by Adam Hale on Medium.

Sources

Share

Corrections and tips:[email protected]