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 MyApp
Skip a single protection middleware:
# config.ru
require 'rack/protection'
use Rack::Protection, :except => :path_traversal
run MyApp
Use a single protection middleware:
# config.ru
require 'rack/protection'
use Rack::Protection::AuthenticityToken
run MyApp
Prevented by:
Rack::Protection::AuthenticityToken (not included by use Rack::Protection)Rack::Protection::FormToken (not included by use Rack::Protection)Rack::Protection::JsonCsrfRack::Protection::RemoteReferrer (not included by use Rack::Protection)Rack::Protection::RemoteTokenPrevented by:
Rack::Protection::EscapedParamsRack::Protection::XssHeader (Internet Explorer only)Prevented by:
Rack::Protection::FrameOptionsPrevented by:
Rack::Protection::PathTraversalPrevented by:
Rack::Protection::SessionHijackingPrevented by:
Rack::Protection::IPSpoofinggem install rack-protection