Skip to content

Commit 28b0144

Browse files
committed
Default host to localhost when in development mode.
* Running Rack apps on 0.0.0.0 in development mode will allow malicious users on the local network (ex: a Coffee Shop or a Conference) to abuse or potentially exploit the app. Safer to default host to localhost when in development mode.
1 parent 7b535cd commit 28b0144

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

lib/rack/server.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,14 @@ def options
185185
end
186186

187187
def default_options
188+
environment = ENV['RACK_ENV'] || 'development'
189+
default_host = environment == 'development' ? 'localhost' : '0.0.0.0'
190+
188191
{
189-
:environment => ENV['RACK_ENV'] || "development",
192+
:environment => environment,
190193
:pid => nil,
191194
:Port => 9292,
192-
:Host => "0.0.0.0",
195+
:Host => default_host,
193196
:AccessLog => [],
194197
:config => "config.ru"
195198
}

0 commit comments

Comments
 (0)