Skip to content

Commit

Permalink
Fix guard against DNS rebinding attacks (mastodon#16095)
Browse files Browse the repository at this point in the history
  • Loading branch information
noellabo authored and chrisguida committed Feb 26, 2022
1 parent 876c257 commit 602d279
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions config/initializers/1_hosts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
host = ENV.fetch('LOCAL_DOMAIN') { "localhost:#{port}" }
web_host = ENV.fetch('WEB_DOMAIN') { host }

alternate_domains = ENV.fetch('ALTERNATE_DOMAINS') { '' }
alternate_domains = ENV.fetch('ALTERNATE_DOMAINS') { '' }.split(/\s*,\s*/)

Rails.application.configure do
https = Rails.env.production? || ENV['LOCAL_HTTPS'] == 'true'
Expand All @@ -15,7 +15,7 @@
config.x.use_s3 = ENV['S3_ENABLED'] == 'true'
config.x.use_swift = ENV['SWIFT_ENABLED'] == 'true'

config.x.alternate_domains = alternate_domains.split(/\s*,\s*/)
config.x.alternate_domains = alternate_domains

config.action_mailer.default_url_options = { host: web_host, protocol: https ? 'https://' : 'http://', trailing_slash: false }

Expand All @@ -30,6 +30,6 @@
unless Rails.env.test?
config.hosts << host if host.present?
config.hosts << web_host if web_host.present?
config.hosts << alternate_domains if alternate_domains.present?
config.hosts.concat(alternate_domains) if alternate_domains.present?
end
end

0 comments on commit 602d279

Please sign in to comment.