-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix security vulnerability alert CVE-2015-9284
Github issued a security vulnerability alert related to OmniAuth. A Cross-Site Request Forgery vulnerability in the request phase in OmniAuth, allows an attacker to gain full access to a user's account on a site that uses OmniAuth. Not sure how this affects EVE Online's SSO but the fix is straight-forward so let's stay on the safe side. This commit adds CSRF verification during OmniAuth's request phase. See https://nvd.nist.gov/vuln/detail/CVE-2015-9284 See omniauth/omniauth#960 Closes #128
- Loading branch information
Showing
4 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
app/middleware/request_forgery_protection_token_verification.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# See https://github.com/omniauth/omniauth/pull/809 | ||
# | ||
# Provides a callable method that verifies Cross-Site Request Forgery | ||
# protection token. | ||
# | ||
# This class includes `ActionController::RequestForgeryProtection` | ||
# directly and utilizes `verified_request?` method to match the way Rails | ||
# performs token verification in Rails controllers. | ||
# | ||
# If you like to learn more about how Rails generate and verify authenticity | ||
# token, you can find the source code at | ||
# https://github.com/rails/rails/blob/v5.2.2/actionpack/lib/action_controller/metal/request_forgery_protection.rb#L217-L240. | ||
class RequestForgeryProtectionTokenVerification | ||
include ActiveSupport::Configurable | ||
include ActionController::RequestForgeryProtection | ||
|
||
# `ActionController::RequestForgeryProtection` contains a few configurable | ||
# options. As we want to make sure that our configuration is the same as | ||
# what being set in `ActionController::Base`, we should make all out | ||
# configuration methods to delegate to `ActionController::Base`. | ||
config.each_key do |configuration_name| | ||
define_method configuration_name do | ||
ActionController::Base.config[configuration_name] | ||
end | ||
end | ||
|
||
def call(env) | ||
@request = ActionDispatch::Request.new(env) | ||
|
||
unless verified_request? | ||
raise ActionController::InvalidAuthenticityToken | ||
end | ||
end | ||
|
||
private | ||
|
||
attr_reader :request | ||
delegate :params, :session, to: :request | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters