Using the omniauth plugin for Rails to find a user, I get a SQL Injection warning when I run brakeman on the following lines of code:
omniauth = request.env["omniauth.auth"]
user = User.where(omniauth.slice(:provider, :uid)).first
The SQL injection warning is:
Possible SQL injection near line 15: User.where(request.env[“omniauth.auth”].slice(:provider, :uid))
/app/controllers/authentications_controller.rb
How can I avoid this line of code being vulnerable?
You can try something like this