Fix an open redirect vulnerability with approved destinations

  1. 1

    Use a fixed destination when the flow allows it

    Remove the destination parameter if everyone should land on the same page. If you need several destinations, map a short identifier to an approved address on the server.

  2. 2

    Check the destination when a full address is necessary

    Use a maintained URL parser. Compare the parsed scheme, host and port with the destinations you allow, and limit the path when the flow needs a specific endpoint.

  3. 3

    Reject lookalike and unexpected destinations

    Don't rely on a raw starts-with or ends-with test. Use the validated destination for the redirect, and check that unapproved inputs can't select another site.

Review open redirects in project code as well as live links

The SiteCMD CLI can flag redirects built from user input in project code. Review the validation around each finding to decide which destinations your app should accept.

Frequently asked questions

Is every redirect to another site an open redirect?

No. The problem is letting untrusted input choose a destination the app didn't intend to allow. A fixed, approved external destination serves a different purpose.

  • Website security

    Catch leaked API keys and exposed files before someone uses them against you.

  • CORS

    Review cross-site read permissions without opening private responses to every origin.

  • Redirects

    Choose the right redirect for a move and remove unnecessary steps to the destination.