Skip to content

Independent cybersecurity briefing

Latest

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

Bug Bounty Write Ups

The Referer Header That Redirected OAuth Tokens

A 2016 Airbnb bounty shows how a convenience redirect plus login CSRF can turn strict OAuth settings into account takeover

Adam Hale, ZeroDay Times editorBy Adam Hale3 min read

Still life for “The Referer Header That Redirected OAuth Tokens”: a magnifier and a sealed envelope, walnut desk, Desk 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.

Airbnb locked its OAuth redirect URIs down to an exact list, and tokens still walked out the door. Arne Swinnen showed that a post-login redirect driven by the HTTP Referer header, combined with a forgeable login request, could deliver Facebook and Google OAuth tokens to an attacker’s page. Airbnb fixed both issues in August 2016 and paid a $5,000 bounty.

Disclaimer: * Educational and defensive use only. Airbnb fixed both issues in 2016. This article intentionally omits reproduction details.*

Vulnerability Overview

  • Type: Open redirect in an OAuth callback chained with login CSRF, leading to OAuth token theft
  • CWE (analytical mapping, not from the source): CWE-601, CWE-352
  • CVE: Not reported
  • Severity/CVSS: Not reported. Bounty: $5,000 (source-reported)

What Happened (high level)

Identity providers had already closed the classic route: no wildcard redirect URIs, and a server-side check that the redirect URI was not tampered with during code exchange. Airbnb’s registered callbacks were a fixed list of its own localized domains.

The weak point sat inside Airbnb. When a user who was already logged in completed an OAuth round trip, the callback sent them “back” to wherever the Referer header of the initiating request pointed. A Referer is set by whichever page triggers the request, so an attacker’s page controls it.

Two more ingredients made it practical. The OAuth login start endpoint accepted a cross-site GET, so a victim could be silently logged into their own account, planting the attacker-controlled return address. Once that session existed, any later OAuth round trip followed the same redirect, even one requesting tokens in the URL fragment, which browsers carry across redirects. The callback URI itself never changed, so provider-side checks passed.

The result, per Swinnen: an authorization code usable to log in on the website, and a provider access token that Airbnb’s mobile app accepted for login.

Impact

Any victim already signed in to Facebook or Google with a linked Airbnb account could lose their account by visiting one page. That exposes bookings, messages, payment methods and identity documents. The attack was generic across both identity providers, not tied to one app’s misconfiguration.

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

1. Never derive redirects from the Referer. Store an internal return path server-side at flow start and accept only relative paths from an allowlist.

2. Make login start a state-bound, same-site action. Reject cross-site requests to OAuth initiation, and bind state to a pre-session cookie the attacker cannot set.

3. Reject unexpected response types. If the callback expects a code, a flow carrying fragment tokens is an anomaly; terminate it instead of redirecting.

4. Don’t accept bare provider access tokens as mobile login. Use PKCE and a backend code exchange so a stolen token is not a session.

# Pseudocode: callback redirect that ignores Referer entirely
ALLOWED_RETURN_PREFIXES = ("/trips", "/inbox", "/account")
def start_oauth(request):
    if request.headers.get("Sec-Fetch-Site") == "cross-site":
        raise Rejected("cross-site login start")
    rp = request.args.get("return_to", "/")
    if not (rp.startswith("/") and not rp.startswith("//")
            and rp.startswith(ALLOWED_RETURN_PREFIXES)):
        rp = "/"
    flow = new_flow(state=random_token(), return_path=rp,
                    response_type="code")
    bind_to_presession_cookie(request, flow)
    return redirect(provider_auth_url(flow))
def oauth_callback(request):
    flow = load_flow_for_presession(request, request.args.get("state"))
    if flow is None or "code" not in request.args:
        raise Rejected("invalid or unexpected flow")   # no redirect on failure
    complete_login(flow, request.args["code"])
    return redirect(flow.return_path)                 # never Referer

Key Takeaways

  • Exact-match redirect URIs protect the provider hop, not your own redirects after it.
  • Login CSRF matters: forcing a victim into their own account can be the setup step.
  • Any header the browser lets other sites influence is attacker input.

Credit & Sources

Research by Arne Swinnen: Authentication bypass on Airbnb via OAuth tokens theft (22 June 2017; reported 4 June 2016, fixed 18 August 2016). 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]