Skip to content

Insecure SSL Setting in Rails Application

Description

The Rails application has an insecure SSL setting, which can lead to improper certificate validation and make the application vulnerable to man-in-the-middle attacks.

Examples

Insecure Code

ruby
Rails.application.configure do
  config.force_ssl = false
end

Secure Code

ruby
Rails.application.configure do
  config.force_ssl = true
  config.ssl_options = { secure_cookies: true, hsts: { subdomains: true } }
end

Remediation

Enable SSL and set secure cookies and HSTS to true. For example, add the following configuration to the Rails application: config.force_ssl = true, config.ssl_options = { secure_cookies: true, hsts: { subdomains: true } }

Rule Details

FieldValue
IDCODE-0639
CategoryInsecureConfig
SeverityHIGH
CWECWE-295
ConfidenceHIGH
ImpactHIGH
LikelihoodHIGH
ExploitabilityEASY
Tagsssl, tls, certificate validation
OWASPN/A

References