aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2007-09-17 11:12:10 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2007-09-17 11:12:10 +0000
commit4e7dce7e40d490a55d95a7fc697483427f081b0e (patch)
tree798bf4b32b8fa3e3e6f8d39f422c3268037b329d /actionpack/lib/action_controller
parent7cb26b5d2d0ecb4945f01b1aa1d398eb85c9f1a4 (diff)
downloadrails-4e7dce7e40d490a55d95a7fc697483427f081b0e.tar.gz
rails-4e7dce7e40d490a55d95a7fc697483427f081b0e.tar.bz2
rails-4e7dce7e40d490a55d95a7fc697483427f081b0e.zip
Added security notice to Request#remote_ip underlining the fact that its value can be spoofed (and that you should use Request#remote_addr if thats a concern for your application) [Adrian Holovaty]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7502 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller')
-rwxr-xr-xactionpack/lib/action_controller/request.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/request.rb b/actionpack/lib/action_controller/request.rb
index 0f14ede347..602b7602b6 100755
--- a/actionpack/lib/action_controller/request.rb
+++ b/actionpack/lib/action_controller/request.rb
@@ -119,6 +119,14 @@ module ActionController
# falling back to REMOTE_ADDR. HTTP_X_FORWARDED_FOR may be a comma-
# delimited list in the case of multiple chained proxies; the first is
# the originating IP.
+ #
+ # Security note: Be aware that since remote_ip will check regular HTTP headers,
+ # it can be tricked by anyone setting those manually. In other words, people can
+ # pose as whatever IP address they like to this method. That doesn't matter if
+ # all your doing is using IP addresses for statistical or geographical information,
+ # but if you want to, for example, limit access to an administrative area by IP,
+ # you should instead use Request#remote_addr, which can't be spoofed (but also won't
+ # survive proxy forwards).
def remote_ip
return @env['HTTP_CLIENT_IP'] if @env.include? 'HTTP_CLIENT_IP'