Bind an OAuth state parameter to the sign-in that started it
An OAuth callback needs to belong to the sign-in flow that started it. Otherwise, a response from another flow can be mistaken for the user's own.
npm install --save-dev @sitecmd/cli
npx sitecmd audit .
The CLI runs on your computer or in your CI, and your code stays there.
What it finds on a demo project
In hand-written sign-in flows, the CLI points out callbacks that never check state and code exchanges that send neither a PKCE verifier nor a client secret.
SiteCMD CLI 2.0.0
Demo project: OAuth callback route
npx sitecmd audit .
SiteCMD Code Scan - .
Checked: November 9, 2026
Framework: Express
Issues: 2 total | critical 0 | high 2 | medium 0 | low 0
High (2)
- [Security · security] No recognized OAuth state binding in manual callback - src/routes/oauth-callback.js:8
- [Security · security] No recognized PKCE or client authentication in manual code exchange - src/routes/oauth-callback.js:13
Your code passes? Now watch your site.
Validate the OAuth state parameter on the callback
If you use state to bind the flow to the browser, generate a one-use value tied to the session that started it and check it on return. Don't complete the flow if the value is missing, changed or reused. RFC 9700 sets out the CSRF requirements.
Follow the PKCE flow from challenge to code exchange
PKCE sends a challenge with the authorization request and the matching verifier when exchanging the code. Use the S256 challenge method and keep the verifier tied to that sign-in attempt. A copied authorization code alone shouldn't complete the exchange. RFC 7636 defines how it works.
Frequently asked questions
Does the PKCE flow replace OAuth state?
RFC 9700 allows PKCE to provide CSRF protection if you've confirmed the authorization server supports it and correctly tied the flow to the browser. State can also carry return context that needs protection from tampering. Follow your OAuth library's complete flow rather than removing a parameter on its own.
Review the tokens created after the OAuth callback
Website security
Catch leaked API keys and exposed files before someone uses them against you.
JWT decode vs verify
Separate reading a token from deciding whether to trust its claims.
Storing auth tokens: localStorage or cookies
Choose token storage based on script access and requests that carry cookies.