Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check forgery setting in all direct subclasses of ActionController::Base #858

Closed

Conversation

jsyeo
Copy link
Contributor

@jsyeo jsyeo commented Apr 4, 2016

This fixes #848. This is the second part to fix #664. Instead of just scanning controllers named ApplicationController, we scan direct subclasses of ActionController::Base instead.

Once we have both this PR and #857 merged, we can close #664. 😉

:confidence => CONFIDENCE[:high],
:file => app_controller.file
if tracker.config.allow_forgery_protection?
warn :controller => name,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want to generate this warning for every controller.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will only generate a warning for a controller that directly inherits from ActionController::Base. Will that be an issue? I would imagine that there may be apps that has more than one controllers that inherits from ActionController::Base. Like say the ApplicationController and AdminController.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's warning about a global setting (that probably no one ever uses), so it doesn't make sense to warn about it for every controller that inherits from ActionController::Base. Actually it doesn't make sense to tie it to a controller at all, but this code was written over five years ago and I didn't know what I was doing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I factored out that check from the .each iteration. One side effect of that is that for the rails3.rb test, we prioritize the warning of CVE20110447 over the missing protect_from_forgery call. See https://github.com/presidentbeef/brakeman/pull/858/files#diff-29d5ade8f0be60f47a3073ebab75b8d4L386. Which kind of makes sense in my opinion because there's no point asking the user to add the call to when rails need upgrading or patching in the first place.

@presidentbeef
Copy link
Owner

Closing, will merge with #953

@jsyeo jsyeo deleted the jsyeo-direct-subclass-actioncontroller branch October 27, 2016 06:00
Repository owner locked and limited conversation to collaborators Mar 10, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CheckForgerySetting Skips Controllers Brakeman does not catch lack of protect_from_forgery in Rails engines
2 participants