In-depth lesson · technique
OAuth state and CSRF
What every disclosed OAuth state and CSRF report in the index teaches, put together: how it works, how it changed year by year, where it turns up, and things to try. Every point shows the reports it is seen in.
- reports cited in this lesson
- 36
- median public bounty
- $5,000
Overview
What it is and why programs pay for it.
This lesson covers flaws in the state parameter and related CSRF protections in OAuth and single sign-on flows. In a correct flow, the client generates a random, unguessable value per session, sends it with the authorisation request, and checks it when the provider redirects back. When that value is missing, predictable, reused, or not actually enforced, an attacker can bind their own authorisation code or provider account to a victim's session. The evidence shows this across many account-linking and import features, including third-party integrations and project import flows, and in exported Android activities that handle OAuth and SSO redirects.
Programs care because the result is account takeover or unwanted account linking: a victim's account ends up connected to the attacker's provider account, or the attacker's code completes inside the victim's session. It also appears in import flows where a captured callback can be replayed by another user. The reports behind this lesson span 37 items, 36 with summaries and 5 paid, so it is a recurring class rather than a one-off.
It turns up most often in account-linking settings pages, project import flows, and mobile OAuth or SSO redirect handling. The underlying mistakes are consistent: no state parameter at all, a state value that stores a redirect location instead of a token, a predictable value such as a user ID, a check that only tests presence, or a callback that is not bound to the session that started the flow.
Seen in these reports10
-
Medium -
How it works
The mechanics, as the reports show them.
The user starts an OAuth or SSO flow. The client should create a random state value, store it against the user's session, and include it in the authorisation request. The provider authenticates the user and redirects back with a code and the state. The client compares the returned state with the stored one and only then exchanges the code. The flaw appears when any of these steps is skipped or weakened.
The simplest failure is a missing state parameter, so nothing binds the callback to the browser that started the flow. A related failure is a state value that is not per session, so a completed callback can be replayed into another session. In both cases an attacker can obtain a code in their own flow and get a victim's browser to submit it, linking the attacker's provider account to the victim.
A second family is a state parameter that exists but is not a CSRF token. It may store a redirect location, a persistent user ID, or a client-controlled decodable blob that tells client-side JavaScript where to send the code. These values can be edited or guessed, so the check does not protect the flow and may itself become an open redirect or code-leak vector.
A third family is a check that is present but ineffective. The server may accept requests where state is missing, compare only up to a null byte, or skip the check for applications marked trusted. The callback may also be reachable by most authenticated users without validating the caller. Each of these lets a crafted callback complete in the wrong context.
Mobile and redirect-handling code adds another route. An exported activity may republish any received URI as a completed flow without checking state, PKCE verifier, or caller identity. Wildcard-scoped session cookies can also let a subdomain set the session used for the OAuth check, undermining the protection even when a state value exists.
What makes all of this possible is that the authorisation code or token is a bearer credential. If it is not tied to the session that started the flow, whoever can get it submitted in a victim's browser can complete the link. The fix is a random per-session state value that is rejected when missing or mismatched, plus binding the code to the session and validating redirect URIs by exact path.
Seen in these reports15
-
-
$5,580 High -
$3,750
Show 5 moreShow fewer
-
$1,260 -
High -
Medium -
Year by year
3 yearsWhat each year's disclosed reports show, newest first. A year with few reports says less.
| 2014 | 1 |
|---|---|
| 2015 | 2 |
| 2016 | 1 |
| 2019 | 1 |
| 2021 | 3 |
| 2022 | 2 |
| 2024 | 3 |
| 2025 | 10 |
| 2026 | 8 |
-
2026
New this year3
- Supplying the attacker's own URI as the exchange redirect URI in an Android app's login flow to see whether a stolen code can be redeemed appears in the disclosed reports.
- Sending a crafted redirect URI to an exported activity that handles OAuth and SSO redirects to see whether it treats it as a completed login appears in the disclosed reports.
- Registering a redirect URI that matches only the origin of the target domain, then aiming it at an open redirect on that domain to forward the code, appears in the disclosed reports.
Kept working6
- Exported Android activities that handle OAuth and SSO redirects, along with mobile app token exchange, were places where this flaw appeared in the disclosed reports.
- Triggering the OAuth login start endpoint cross-site with the Referer header set to a page the attacker controls, then observing where the user is sent after authentication, worked in the disclosed reports.
-
2025
New this year4
- Changing response_mode to fragment so the authorisation code lands in the URL fragment, combined with an open redirect and a missing state check, first appears in the disclosed reports.
- Testing whether the token endpoint accepts an exchange without a valid client secret and whether it checks the redirect URI against a whitelist appears in the disclosed reports.
- Applications marked trusted by default skipping the CSRF check on the authorisation flow, so a crafted link yields a code without consent, appears in the disclosed reports.
Kept working6
- Hunters chained a missing state check with a second weakness such as an open redirect, a Referer-driven redirect or a cross-site confirmation step in the disclosed reports.
- Checking OAuth requests on a secondary subdomain for a missing state parameter, then sending a login link carrying the attacker's own code to force a victim into the attacker's account, worked in the disclosed reports.
-
2024
Kept working5
- Hunters tested account-linking callbacks by completing the connect step in a victim's browser to see whether the attacker's third-party account bound to the victim, as in the Facebook linking flow in the disclosed reports.
- Comparing state values across two sign-ins in turn revealed predictable state tokens within a time window in the disclosed reports.
Where it is found
3The features and places the reports found it in, most-reported first.
-
Account-linking flows for third-party integrations, such as those on Google Drive, Pinterest, Twitch, Facebook, Bitbucket, GitHub, Salesforce and Google, are places where this flaw appears.
Seen in 8 reports
-
Project import flows and account-linking settings pages are features where this flaw turns up.
Seen in 4 reports
-
Exported Android activities that handle OAuth and SSO redirects, along with mobile app token exchange, are places where this flaw appears.
Technologies in these reports5
Root causes
12The mistakes in the code or configuration behind the reports.
-
The authorisation request was built without a state parameter, so no anti-CSRF token bound the callback to the user's session.
Seen in 1 report
-
No per-session state value tied the authorisation request to the browser that started it, so a completed callback could be replayed into another session.
Seen in 1 report
-
$1,260
-
-
The state parameter was used to store a redirect location instead of a CSRF token, so it could be edited to send the token elsewhere after login.
Seen in 1 report
-
The state parameter was predictable, being identical for all users within a time frame.
Seen in 1 report
-
The authorisation code was not bound to the user's session, so an attacker's code could be injected into a victim's pending flow.
Seen in 1 report
Things to try
The most-reported tests in the largest contexts. Tick what you have tried; ticks stay in this browser and carry over to the full checklist. Test only what a program's scope allows.
ticked in this lesson
Account linking and social connect
of 3 ticked-
Seen in 1 report
State parameter handling and predictability
of 3 ticked-
Seen in 1 report
-
Seen in 1 report
Response type, mode and redirect URI manipulation
of 3 ticked-
Seen in 1 report
-
Seen in 1 report
-
Seen in 1 report
Callback replay and cross-user code reuse
of 3 ticked-
Seen in 1 report
-
$1,260
-
-
Seen in 1 report
Bypasses and variations
4How reports got past filters, encoders and other defences.
-
A comparison that stops at a null byte ignores anything after it, so the state check passes with a modified value.
-
Applications marked trusted by default skip the CSRF check on the authorisation flow, so a crafted link yields a code without consent.
Seen in 1 report
-
$5,580 High
-
-
Weak postMessage listeners or third-party scripts on error pages can leak the URL that still carries the code or token.
Seen in 1 report
-
Initialising the SDK through a crafted URL satisfies its postMessage requirement so the callback can be triggered cross-site.
Seen in 1 report
Payouts
5 paidPublic bounties in US dollars, from the data. 5 of 41 reports show an amount.
- a quarter paid up to
- $3,750
- median
- $5,000
- three quarters paid up to
- $5,580
- highest
- $25k
One in ten paid reports was paid $17k or more.
| Severity | Reports | Paid | Median | Highest |
|---|---|---|---|---|
| High | 2 | 1 | $5,580 | $5,580 |
| Medium | 2 | 0 | None paid | None |
| Low | 1 | 0 | None paid | None |
| Unrated | 36 | 4 | $4,375 | $25k |
Highest-paid reports5
-
$25,000 -
$5,580 High -
$5,000 -
$3,750
-
$1,260
Typical fixes
3How programs fixed it, as the reports describe.
-
Generate a random, unguessable state value per session and reject callbacks where it is missing or does not match.
Seen in 3 reports
-
Bind the authorisation code to the session that started the flow so a code from another session cannot complete it.
Seen in 2 reports
-
Validate redirect URIs by exact path against a whitelist rather than by origin alone.
Tips for beginners
14Advice for a first hunt, drawn from the reports.
-
Start with account-linking settings pages and project import flows. These are the most common places in the evidence, and they are easy to reach with a normal account.
Seen in 3 reports
-
If state is present, look at what it stores. A redirect location, a user ID, or a decodable blob is not a CSRF token and should be reported as such.
Seen in 3 reports
-
First check whether a state parameter is present at all in the authorisation request. A missing state is the simplest finding and the easiest to demonstrate.
-
Compare state values across two logins or two accounts. If the value is the same within a time window, it is predictable and the protection is ineffective.
-
Test whether the server actually rejects a missing or modified state. Some servers check presence but accept requests where it is absent, and some comparisons stop at a null byte.
Guides and techniques
The best explainers, cheat sheets and technique posts on OAuth state and CSRF, from around the web.
-
The Current Landscape of OAuth AttacksUnit 42 surveys current OAuth attack techniques, giving researchers a structured map of redirect, consent and token abuse patterns.
Explainer unit42.paloaltonetworks.com
-
The Bug Bounty Playbook: OAuth Callback and Redirect ManipulationPlaybook for finding OAuth flaws through callback and redirect URI manipulation in bug bounty targets.
Technique medium.com
-
SSO Gadgets: Escalate (Self-)XSS to ATOExplains how to escalate XSS, even self-XSS with login CSRF, to account takeover by abusing OAuth2 and OIDC SSO gadgets.
Technique security.lauritz-holtmann.de
-
OAuth 2.0 Authentication VulnerabilitiesPortSwigger explains OAuth 2.0 flows and the common implementation flaws that let attackers hijack accounts.
Explainer portswigger.net
-
The Bug Bounty Playbook: Authentication BypassA playbook of common authentication bypass patterns and testing steps for bug bounty hunters.
Cheat sheet medium.com
Keep learning
Where this lesson fits, and what to read next.
The whole class
Related techniques
How this is made: our model read every listed OAuth state and CSRF report in the index (our own summary where we have one, otherwise the title and the platform's label), listed the patterns, and merged them. Each point was kept only if the reports it cites exist, are listed and belong here; payouts are computed from the data, not written by the model. Read the originals before relying on a point. Generated 28 Nov 2026 from 37 reports. All OAuth state and CSRF reports.