How to fix: OAuth Authorization Request Missing State Parameter
A request made to an OAuth/OIDC authorize endpoint during the scan has both response_type and client_id in its query string (confirming it's a real authorization request, not just a page whose path happens to contain "authorize") but no state parameter. Without a state value the client generates and later verifies, the authorization flow has no CSRF protection.
Why it matters
Without a state parameter binding the authorization response back to the request that started it, an attacker can initiate their own OAuth flow, capture the resulting authorization code or token, and trick a victim into completing it in the victim's browser (a login CSRF). The victim ends up authenticated as the attacker, or with the attacker's account linked to the victim's session, depending on the flow.
The check parses the actual scanned URL's query string on a real OAuth/OIDC authorize endpoint, the same URL-shape technique the PKCE and implicit-grant checks in this scanner use, rather than guessing from page text. response_type and client_id both present confirms this is a genuine authorization request; the absence of state in that same query string is the finding. A state value present elsewhere (a cookie, a hidden form field) is not visible to this check, so this is a signal to verify the flow's real behavior, not a guarantee no CSRF protection exists anywhere in it.
How to fix it
- 1Generate a cryptographically random state value per authorization request and store it server-side (session or signed cookie) before redirecting to the authorize endpoint.
- 2Include that value as the state query parameter on the authorize request.
- 3On the callback, verify the returned state matches the stored value before exchanging the authorization code or accepting the token.
- 4Reject the callback outright if state is missing or does not match.
Code examples
Generate and verify OAuth state
// Before redirecting to the authorize endpoint
const state = crypto.randomBytes(16).toString('hex');
req.session.oauthState = state;
const authorizeUrl = `https://provider.example.com/oauth2/authorize?response_type=code&client_id=${clientId}&state=${state}`;
// On the callback
if (req.query.state !== req.session.oauthState) {
throw new Error('Invalid OAuth state: possible CSRF');
}References
Detected automatically by VulnRadar. The check id is oauth-authorize-missing-state-param, stable across every scan so you can filter or diff on it.
More host validation checks
- HighHost Header Injection Risk
- MediumSymfony Debug Token Header Exposed
- HighHTTP Request Smuggling Indicator
- HighHTTP Basic Authentication Over Non-HTTPS
- MediumASP.NET ViewState Without MAC Protection
- HighCache Poisoning via Unkeyed Headers
- LowSequential Numeric ID in URL (IDOR Risk)
- HighConfirmed Open Redirect via Location Header
Questions
- How severe is OAuth Authorization Request Missing State Parameter?
- VulnRadar rates this medium severity in the host validation category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
- Does VulnRadar check for this automatically?
- Yes. It runs as part of every scan under the check id oauth-authorize-missing-state-param, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does OAuth Authorization Request Missing State Parameter map to?
- It maps to CWE-352. In the OWASP Top 10 it falls under A01:2021.
Missing a check?
The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.