diff options
author | Nick Thomas <nick@gitlab.com> | 2018-08-13 15:07:18 +0300 |
---|---|---|
committer | Jose Vargas <jvargas@gitlab.com> | 2018-08-24 21:42:13 +0300 |
commit | 61dce108f66739bebbc56a1a1bdd0752d502656e (patch) | |
tree | cf97c24b6aef990b66097a7b957fc619b4d43b50 /lib/gitlab | |
parent | 2d6c1c61191f3b6a390a04ff90ed3514d9eda30b (diff) |
Merge branch 'sh-block-link-local-master-11-2-port' into 'security-11-2'
Block link-local addresses in URLBlocker (11.2 port)
See merge request gitlab/gitlabhq!2460
Diffstat (limited to 'lib/gitlab')
-rw-r--r-- | lib/gitlab/url_blocker.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/gitlab/url_blocker.rb b/lib/gitlab/url_blocker.rb index 38be75b7482..3b483f27e70 100644 --- a/lib/gitlab/url_blocker.rb +++ b/lib/gitlab/url_blocker.rb @@ -31,6 +31,7 @@ module Gitlab validate_localhost!(addrs_info) unless allow_localhost validate_local_network!(addrs_info) unless allow_local_network + validate_link_local!(addrs_info) unless allow_local_network true end @@ -89,6 +90,13 @@ module Gitlab raise BlockedUrlError, "Requests to the local network are not allowed" end + def validate_link_local!(addrs_info) + netmask = IPAddr.new('169.254.0.0/16') + return unless addrs_info.any? { |addr| addr.ipv6_linklocal? || netmask.include?(addr.ip_address) } + + raise BlockedUrlError, "Requests to the link local network are not allowed" + end + def internal?(uri) internal_web?(uri) || internal_shell?(uri) end |