You should use protection!
This gem protects against typical web attacks. Should work for all Rack apps, including Rails.
Use all protections you probably want to use:
# config.ru
require 'rack/protection'
use Rack::Protection
run MyAppSkip a single protection middleware:
# config.ru
require 'rack/protection'
use Rack::Protection, :except => :path_traversal
run MyAppUse a single protection middleware:
# config.ru
require 'rack/protection'
use Rack::Protection::AuthenticityToken
run MyAppPrevented by:
Rack::Protection::AuthenticityToken(not included byuse Rack::Protection)Rack::Protection::FormToken(not included byuse Rack::Protection)Rack::Protection::JsonCsrfRack::Protection::RemoteReferrer(not included byuse Rack::Protection)Rack::Protection::RemoteToken
Prevented by:
Rack::Protection::EscapedParamsRack::Protection::XssHeader(Internet Explorer only)
Prevented by:
Rack::Protection::FrameOptions
Prevented by:
Rack::Protection::PathTraversal
Prevented by:
Rack::Protection::SessionHijacking
Prevented by:
Rack::Protection::IPSpoofing
gem install rack-protection