25
loading...
This website collects cookies to deliver better user experience
The best way to receive all the security announcements is to subscribe to the Rails Security mailing list. The mailing list is very low traffic, and it receives the public notifications the moment the embargo is lifted.
ActionDispatch
module, a huge part of Rails core, and responsible for routing requests to controllers.config.action_dispatch.default_headers = {
"X-Frame-Options" => "SAMEORIGIN",
"X-XSS-Protection" => "1; mode=block",
"X-Content-Type-Options" => "nosniff",
"X-Download-Options" => "noopen",
"X-Permitted-Cross-Domain-Policies" => "none",
"Referrer-Policy" => "strict-origin-when-cross-origin"
}
"X-Frame-Options" => "SAMEORIGIN",
X-Frame-Options
header with a secure SAMEORGIN
value tells the browser that it should only open URL addresses linking to the same domain in the <iframe />
tags.config.action_dispatch.default_headers['X-Frame-Options'] = "ALLOW-FROM https://apps.facebook.com"
"X-XSS-Protection" => "1; mode=block",
X-XSS-Protection
with value 1;mode=block
enables the built-in Cross-Site Scripting (a type of attack) filter. "X-Content-Type-Options" => "nosniff",
X-Content-Type-Options
with value nosniff
is responsible for blocking a request if its destination is of either style
or script
types and their MIME types do not match. text/html
application/json
"X-Download-Options" => "noopen",
"X-Permitted-Cross-Domain-Policies" => "none",
X-Permitted-Cross-Domain-Policies
with value none
instructs clients such as AdobeAcrobat and Flash to avoid accessing any data from your domain."Referrer-Policy" => "none",
Referrer-Policy
is responsible for controlling how much information should be sent in the Referrer header. This attribute is used to specify the reference information that will be sent to the server when the user clicks on a hyperlink. The strict-origin-when-cross-origin value
:referrer
header to less-secure destinationsContent-Security-Policy
. We can thank this header so we don't get hackers loading external scripts. Rails.application.config.content_security_policy do |policy|
policy.default_src :self, :https
policy.font_src :self, :https, :data
policy.img_src :self, :https, :data
policy.object_src :none
policy.script_src :self, :https
policy.style_src :self, :https
policy.report_uri '/csp-violated'
end
Rails.application.config.content_security_policy_report_only = false
Feature-Policy
header is another security header that Ruby on Rails let us configure, despite still being in the experimental state. RoR does not have documentation on this yet on their official guidelines, because of it's experimental state. ActionDispatch
module is very similar to the CSP one, and the header can be configured in the same manner.Rails.application.config.feature_policy do |policy|
policy.fullscreen :fullscreen
policy.geolocation :geolocation
policy.gyroscope :gyroscope
end
gems
. Each gem contains the code and metafile in the appropriate format (YAML - "Yet Another Markup Language). <img src="http://myrails.com/resource/1/destroy" height=0 width=0 />
Rails.application.configure do
# other config
config.force_ssl = true
end
secure
session [: user_id] = user
cookies[:secure_session]
cookies.signed[: secure_session]
<iframe src="http://examplebank.com/app/transfermoney? amount=2200&attackersAccount">
<input
Name= "authenticity_token"
type= “hidden”
value=”ghtyu7asdvnTojibBNYY67BshjyerUA+81
+ DD=”/>
http://www.example.com/index.php?id=2'
ActionView::Helpers::SanitizeHelper
module.