open-redirect
A redirect to a location a request chose.
- Group
- Code
- Runs
- Runs under ur scan:
ur scan --rule open-redirect - Level
- warning
- Reads
- Every file
- Fix
- None: the safe form depends on what the value is meant to be
Why
The response redirects to a URL taken from the request, so a link to this site can send whoever follows it anywhere, such as to a page that imitates this one. Redirect only to paths of this site, or to hosts on a fixed list.
The fix, as Ur suggests it: redirect to a fixed path or an allowed host.
For agents
Never redirect to a URL taken from a request; redirect to a path of the site or a host on a fixed list.
Example
app/controllers/sessions_controller.rbclass SessionsController < ApplicationController
def create
session[:user_id] = User.authenticate(params[:email], params[:password]).id
redirect_to params[:return_to]
end
end
$ ur scan --rule open-redirect
warning[open-redirect]: `params`, a request parameter, reaches `redirect_to`
--> ./app/controllers/sessions_controller.rb:4:5 method `create`
= step 1: ./app/controllers/sessions_controller.rb:4:17 `params`, a request parameter,
= hint: redirect to a fixed path or an allowed host
= see: Securing Rails Applications, 4.1 Redirection, Rails Guides (2025-10-01), https://guides.rubyonrails.org/security.html#redirection
scanned 1 file (no framework recognized)
open-redirect: 1 high, 0 medium
1 finding and 0 of medium confidence
Source
Securing Rails Applications, 4.1 Redirection, Rails Guides (2025-10-01).