Rails security: Redirection
17 Jan 2011
Knowledge
Redirection could lead attacker to create a self-contained attack or forward the user to a trap web site by sending an unsuspicious link into an external site e.g. http://www.example.com/site/redirect?to=www.attacker.com
Some simple countermeasures are
- If you redirect to an URL, check it with a whitelist or a regular expression
- Avoid using redirect_to(params[:some_param])
- Do not allow the user to supply (parts of) the URL to be redirected to
