diff options
author | Thiago Presa <tpresa@gitlab.com> | 2018-10-25 01:05:44 +0000 |
---|---|---|
committer | Thiago Presa <tpresa@gitlab.com> | 2018-10-25 01:05:44 +0000 |
commit | cc571e18d37e7f92fab27663090abefc3fbad11c (patch) | |
tree | 89375fbb29ca55ee9abbf8bf827d6bf5f7b3817f /lib | |
parent | ee40dc3a7f1c3f11fad2fde3be17e4ddd5d87585 (diff) | |
parent | b1d04cf9d58ac461f70a2cbf4df617cc14c3de1c (diff) | |
download | gitlab-ce-cc571e18d37e7f92fab27663090abefc3fbad11c.tar.gz |
Merge branch 'sh-block-other-localhost' into 'master'
Block additional localhost addresses in UrlBlocker
See merge request gitlab/gitlabhq!2487
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/url_blocker.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/gitlab/url_blocker.rb b/lib/gitlab/url_blocker.rb index 7735b736689..86efe8ad114 100644 --- a/lib/gitlab/url_blocker.rb +++ b/lib/gitlab/url_blocker.rb @@ -32,6 +32,7 @@ module Gitlab end validate_localhost!(addrs_info) unless allow_localhost + validate_loopback!(addrs_info) unless allow_localhost validate_local_network!(addrs_info) unless allow_local_network validate_link_local!(addrs_info) unless allow_local_network @@ -86,6 +87,12 @@ module Gitlab raise BlockedUrlError, "Requests to localhost are not allowed" end + def validate_loopback!(addrs_info) + return unless addrs_info.any? { |addr| addr.ipv4_loopback? || addr.ipv6_loopback? } + + raise BlockedUrlError, "Requests to loopback addresses are not allowed" + end + def validate_local_network!(addrs_info) return unless addrs_info.any? { |addr| addr.ipv4_private? || addr.ipv6_sitelocal? } |