mirror of
https://github.com/github/codeql.git
synced 2026-05-05 21:55:19 +02:00
Merge pull request #14308 from hmac/hmac-rb-csrf-not-enabled
Ruby: Add a query for CSRF protection not enabled
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
| railsapp/app/controllers/application_controller.rb:5:3:5:22 | call to protect_from_forgery | Potential CSRF vulnerability due to forgery protection being disabled or weakened. |
|
||||
| railsapp/app/controllers/users_controller.rb:4:3:4:47 | call to skip_before_action | Potential CSRF vulnerability due to forgery protection being disabled or weakened. |
|
||||
| railsapp/config/application.rb:15:5:15:53 | call to allow_forgery_protection= | Potential CSRF vulnerability due to forgery protection being disabled or weakened. |
|
||||
| railsapp/config/application.rb:16:5:16:53 | call to allow_forgery_protection= | Potential CSRF vulnerability due to forgery protection being disabled or weakened. |
|
||||
| railsapp/config/environments/development.rb:5:3:5:51 | call to allow_forgery_protection= | Potential CSRF vulnerability due to forgery protection being disabled or weakened. |
|
||||
| railsapp/config/environments/production.rb:5:3:5:51 | call to allow_forgery_protection= | Potential CSRF vulnerability due to forgery protection being disabled or weakened. |
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
| railsapp/app/controllers/alternative_root_controller.rb:1:1:3:3 | AlternativeRootController | Potential CSRF vulnerability due to forgery protection not being enabled. |
|
||||
@@ -0,0 +1 @@
|
||||
queries/security/cwe-352/CSRFProtectionNotEnabled.ql
|
||||
@@ -0,0 +1,3 @@
|
||||
class AlternativeRootController < ActionController::Base
|
||||
# BAD: no protect_from_forgery call
|
||||
end
|
||||
@@ -0,0 +1,3 @@
|
||||
class SubscriptionsController < AlternativeRootController
|
||||
protect_from_forgery with: :exception
|
||||
end
|
||||
@@ -0,0 +1,2 @@
|
||||
class TagsController < AlternativeRootController
|
||||
end
|
||||
@@ -9,7 +9,8 @@ Bundler.require(*Rails.groups)
|
||||
module Railsapp
|
||||
class Application < Rails::Application
|
||||
# Initialize configuration defaults for originally generated Rails version.
|
||||
config.load_defaults 6.0
|
||||
# This defaults version does NOT enable CSRF protection by default.
|
||||
config.load_defaults 5.1
|
||||
|
||||
# BAD: Disabling forgery protection may open the application to CSRF attacks
|
||||
config.action_controller.allow_forgery_protection = false
|
||||
|
||||
Reference in New Issue
Block a user