Open Redirection
Open Redirection
Open Redirection
A redirect happens when the website or web application changes the URL that
is accessed in the client (usually external – internal redirects are usually called
forwards). There are several ways to do this from the back-end. Usually,
redirects are made by sending specific HTTP headers to the client but you can
also create redirects, for example, using JavaScript code.
• Use a list of fixed destination pages. Store their full URLs in a database
table and call them using identifiers as request parameters, not the URLs
themselves. For example, store http://example2.com in the database
table with the identifier 42 and then use the following call to redirect to
example2.com: https://example.com/redirect.php?redir_id=42.
• If you cannot use a fixed list of redirection targets, filter untrusted input
(if you can, using a whitelist, not a blacklist). Make sure to check for
partial strings, for example, http://example.com.evil.com is a valid URL.
Additionally, disallow all protocols except HTTP and HTTPS. Also note,
that despite your best efforts it is possible that attackers may find a way
around your filters.
References
https://www.acunetix.com/blog/web-security-zone/what-are-open-redirects/
https://www.netsparker.com/blog/web-security/open-redirection-
vulnerability-information-prevention/
https://www.neuralegion.com/blog/open-redirect-vulnerabilities/