Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 7502

Show
Ignore:
Timestamp:
09/17/07 11:12:10 (1 year ago)
Author:
david
Message:

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]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/lib/action_controller/request.rb

    r7479 r7502  
    120120    # delimited list in the case of multiple chained proxies; the first is 
    121121    # the originating IP. 
     122    # 
     123    # Security note: Be aware that since remote_ip will check regular HTTP headers, 
     124    # it can be tricked by anyone setting those manually. In other words, people can 
     125    # pose as whatever IP address they like to this method. That doesn't matter if 
     126    # all your doing is using IP addresses for statistical or geographical information, 
     127    # but if you want to, for example, limit access to an administrative area by IP, 
     128    # you should instead use Request#remote_addr, which can't be spoofed (but also won't 
     129    # survive proxy forwards). 
    122130    def remote_ip 
    123131      return @env['HTTP_CLIENT_IP'] if @env.include? 'HTTP_CLIENT_IP'