Authentication and API security

Validate OAuth redirect URIs exactly

Prevent open redirects and authorization-code leakage by matching OAuth redirect URIs against registered values. Loose prefix or substring comparisons can allow an attacker-controlled host or path to receive authorization responses. Redirect URIs are part of the protocol security boundary, not ordinary navigation input. Security controls depend on client type, data sensitivity and deployment context; verify provider and standards guidance before production changes.

Threat model and trust boundaries

Loose prefix or substring comparisons can allow an attacker-controlled host or path to receive authorization responses. Redirect URIs are part of the protocol security boundary, not ordinary navigation input.

  • Identify actors, assets and trust boundaries
  • Choose controls that address the stated threat
  • Test failure behavior and recovery paths

Implementation approach

Register complete HTTPS callback URIs where possible, compare normalized values using the provider's rules, and never append arbitrary redirect destinations from query parameters. Keep local development exceptions separate from production registrations.

  • Confirm the responsible owner
  • Apply the change to a representative case
  • Document decisions and exceptions

Practical example

A callback allowlist accepts https://app.example/callback but rejects https://app.example.attacker.test/callback and /callback/extra when they are not registered.

  • Reproduce the starting situation
  • Apply the described approach
  • Check the user-facing result

Verification and follow-up

Run negative tests for user-info syntax, alternate ports, encoded delimiters, trailing paths and host suffix tricks; inspect provider configuration for stale callbacks.

  • Test expected and failure cases
  • Compare with the recorded baseline
  • Agree the next review date and owner

Questions to keep in view

When should a team use this authentication and api security guide?

Prevent open redirects and authorization-code leakage by matching OAuth redirect URIs against registered values.

What should be checked before rollout?

Run negative tests for user-info syntax, alternate ports, encoded delimiters, trailing paths and host suffix tricks; inspect provider configuration for stale callbacks.