diff options
author | Jan Provaznik <jprovaznik@gitlab.com> | 2018-11-02 07:56:03 +0000 |
---|---|---|
committer | Jan Provaznik <jprovaznik@gitlab.com> | 2018-11-02 07:56:03 +0000 |
commit | 79911cb4ddc8724cc2270570261e807a8cf7eb60 (patch) | |
tree | d48047ca83f5c6b8f79e9f7047673f63826f6eb3 /config | |
parent | 1c7ef86f411bc6dc4348f24ead12f38b6d702395 (diff) | |
parent | 6eb3fc69f6a1f705b6f366dc14d306e1409ee721 (diff) | |
download | gitlab-ce-79911cb4ddc8724cc2270570261e807a8cf7eb60.tar.gz |
Merge branch 'security-kubeclient-ssrf' into 'master'
[master] Security kubeclient ssrf
See merge request gitlab/gitlabhq!2575
Diffstat (limited to 'config')
-rw-r--r-- | config/initializers/kubeclient.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/config/initializers/kubeclient.rb b/config/initializers/kubeclient.rb index 7f115268b37..2d9f439fdc0 100644 --- a/config/initializers/kubeclient.rb +++ b/config/initializers/kubeclient.rb @@ -13,4 +13,25 @@ class Kubeclient::Client ns_prefix = build_namespace_prefix(namespace) rest_client["#{ns_prefix}#{entity_name_plural}/#{name}:#{port}/proxy"].url end + + # Monkey patch to set `max_redirects: 0`, so that kubeclient + # does not follow redirects and expose internal services. + # See https://gitlab.com/gitlab-org/gitlab-ce/issues/53158 + def create_rest_client(path = nil) + path ||= @api_endpoint.path + options = { + ssl_ca_file: @ssl_options[:ca_file], + ssl_cert_store: @ssl_options[:cert_store], + verify_ssl: @ssl_options[:verify_ssl], + ssl_client_cert: @ssl_options[:client_cert], + ssl_client_key: @ssl_options[:client_key], + proxy: @http_proxy_uri, + user: @auth_options[:username], + password: @auth_options[:password], + open_timeout: @timeouts[:open], + read_timeout: @timeouts[:read], + max_redirects: 0 + } + RestClient::Resource.new(@api_endpoint.merge(path).to_s, options) + end end |