Software delivery

OAuth 2.0 Security Best Practices Checklist

OAuth security depends on the client type, authorization server, redirect mechanism and how tokens are used. Use this checklist to review an implementation against the current OAuth 2.0 Security Best Current Practice, RFC 9700, and the applicable protocol specifications. It is a review aid, not a security certification or substitute for testing the deployed system. The separate PKCE implementation guide focuses on flow mechanics; this checklist covers broader threat controls.

Define the decision before opening a tool

Start by writing the question this work must answer. For this task, collect Client type, registered redirect URIs, authorization codes, PKCE verifier and challenge, state binding, scopes and token storage. A small representative sample is more useful than a large export nobody can interpret. Note the date range, source and any recent changes so later comparisons are honest.

  • Name the decision and owner
  • Collect a representative sample
  • Record assumptions and recent changes

Make the smallest safe change

The next action is to Use exact registered redirect URIs; require PKCE for public clients and appropriate confidential clients; bind state to the initiating session; keep tokens out of URLs and choose storage appropriate to the client and threat model. Work from the underlying cause where possible instead of applying a cosmetic fix to each symptom. Keep a short change log with the page, campaign, component or workflow affected so the team can roll back or investigate later.

  • Prioritize the highest-impact cause
  • Test in a safe environment when available
  • Publish one clearly documented change

Validate what actually changed

Test mismatched redirect and state, code replay, token exposure and recovery paths against current provider guidance. Validation should reflect the original question and include the user path, not only a dashboard metric. If the evidence is inconclusive, record that outcome and choose a narrower follow-up rather than overstating success.

  • Re-test the affected path
  • Compare against the recorded baseline
  • Decide the next step from evidence

Bind authorization responses to the initiating transaction

Use Authorization Code Flow and protect the authorization response against injection and cross-site request forgery. Bind state to the user's browser and authorization transaction when relying on it; validate it once and reject unexpected or replayed values. OpenID Connect clients must generate and verify nonce where applicable. PKCE can provide transaction binding when correctly supported and enforced by the authorization server; do not assume a client-only check is sufficient.

  • Use a single-use state value and compare it with the initiating session
  • Bind and validate OIDC nonce when the flow uses it
  • Reject unsolicited, mismatched and replayed authorization responses

Require PKCE and prefer the S256 challenge method

Public clients must use PKCE under RFC 9700; confidential clients are also advised to use it. Generate a high-entropy verifier for each authorization request, send its S256 challenge, and verify the same transaction's verifier during code exchange. Do not use the plain method where S256 is available. Confirm that the authorization server enforces verifier checks and rejects an invalid or missing verifier rather than treating PKCE as decorative client metadata.

  • Create a fresh verifier for each authorization transaction
  • Send code_challenge_method=S256 and the derived challenge
  • Test that an incorrect verifier causes token exchange to fail

Validate redirect URIs and avoid open redirectors

Register and compare redirect URIs exactly, following the applicable client profile. Do not accept untrusted wildcard hosts, attacker-controlled return parameters or redirects that can forward authorization responses elsewhere. Native applications have defined loopback redirect exceptions; those are not a general exemption for web clients. An authorization code returned to the wrong endpoint can be intercepted or injected into another session.

  • Reject unregistered scheme, host, path and query variants
  • Test encoded delimiters, alternate hosts and open redirect routes
  • Apply only the documented native-app loopback exception where relevant

Use appropriate flows and protect tokens

Avoid the resource-owner password credentials grant; it exposes user credentials to the client. Do not use implicit token delivery where an authorization-code-based flow is available. Keep client secrets out of browser and native public-client code. Store tokens with controls appropriate to the platform, minimize scopes and lifetime, and prevent access tokens from appearing in URLs, logs or analytics. Resource servers should validate issuer, signature, expiry and intended audience according to the token profile.

  • Use authorization code with PKCE for interactive public clients
  • Keep tokens out of URLs, browser logs and client-visible secrets
  • Validate token issuer, expiry, scope and audience at the resource server

Detect refresh-token replay and test negative cases

For public clients, refresh tokens need sender-constraining or rotation with reuse detection; confidential-client refresh tokens must remain restricted to the designated client. A concrete test is to exchange a refresh token, reuse the previous token, and verify the server detects replay and applies its documented revocation response. Also test wrong state, wrong PKCE verifier, altered redirect URI, expired code and audience mismatch. Record expected rejection behavior without placing live tokens in reports.

  • Test rotation or sender-constraining behavior for the client type
  • Confirm replay and invalid-code requests are rejected
  • Capture sanitized evidence and resolve findings with the authorization-server owner

Questions to keep in view

Who should own oauth 2.0 security best practices and checklist?

Assign one accountable owner, while involving the people who manage the affected content, campaigns, code or customer workflow.

How quickly will this show results?

Timing varies with the system, traffic and external platform processing. Validate the implementation first, then monitor the relevant signal over an appropriate period.

Does PKCE replace state?

Not universally. RFC 9700 describes when PKCE can provide CSRF protection, but relying on it requires correct transaction binding and authorization-server support. Use and validate state where the chosen flow requires it.

Is an OAuth checklist a penetration test?

No. It helps structure a review but cannot establish security without examining the actual client, server configuration, deployment and threat model.

Where are PKCE implementation details covered?

See the separate OAuth2 PKCE flow implementation guide for code challenge and verifier mechanics. This checklist focuses on wider flow and token protections.