Skip to content

Commit f071897

Browse files
authored
Merge pull request rails#44592 from ghiculescu/remote-ip-docs
[docs] RemoteIp improvements
2 parents f3e176c + 60a1cd2 commit f071897

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

actionpack/lib/action_dispatch/middleware/remote_ip.rb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ module ActionDispatch
77
# making the request. It does this by checking various headers that could
88
# contain the address, and then picking the last-set address that is not
99
# on the list of trusted IPs. This follows the precedent set by e.g.
10-
# {the Tomcat server}[https://issues.apache.org/bugzilla/show_bug.cgi?id=50453],
11-
# with {reasoning explained at length}[https://blog.gingerlime.com/2012/rails-ip-spoofing-vulnerabilities-and-protection]
12-
# by @gingerlime. A more detailed explanation of the algorithm is given
13-
# at GetIp#calculate_ip.
10+
# {the Tomcat server}[https://issues.apache.org/bugzilla/show_bug.cgi?id=50453].
11+
# A more detailed explanation of the algorithm is given at GetIp#calculate_ip.
1412
#
1513
# Some Rack servers concatenate repeated headers, like {HTTP RFC 2616}[https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2]
1614
# requires. Some Rack servers simply drop preceding headers, and only report
@@ -24,7 +22,8 @@ module ActionDispatch
2422
# a proxy, because you are hosted on e.g. Heroku without SSL, any client can
2523
# claim to have any IP address by setting the X-Forwarded-For header. If you
2624
# care about that, then you need to explicitly drop or ignore those headers
27-
# sometime before this middleware runs.
25+
# sometime before this middleware runs. Alternatively, remove this middleware
26+
# to avoid inadvertently relying on it.
2827
class RemoteIp
2928
class IpSpoofAttackError < StandardError; end
3029

@@ -114,7 +113,7 @@ def initialize(req, check_ip, proxies)
114113
# proxies, that header may contain a list of IPs. Other proxy services
115114
# set the Client-Ip header instead, so we check that too.
116115
#
117-
# As discussed in {this post about Rails IP Spoofing}[https://blog.gingerlime.com/2012/rails-ip-spoofing-vulnerabilities-and-protection/],
116+
# As discussed in {this post about Rails IP Spoofing}[https://web.archive.org/web/20170626095448/https://blog.gingerlime.com/2012/rails-ip-spoofing-vulnerabilities-and-protection/],
118117
# while the first IP in the list is likely to be the "originating" IP,
119118
# it could also have been set by the client maliciously.
120119
#

0 commit comments

Comments
 (0)