diff options
author | Jan Provaznik <jprovaznik@gitlab.com> | 2018-10-30 11:19:26 +0000 |
---|---|---|
committer | Jan Provaznik <jprovaznik@gitlab.com> | 2018-10-30 12:56:24 +0100 |
commit | 390bcc709390e6ffd7c1da56685feba6ead9a2a7 (patch) | |
tree | 5254653d2854d1c0e9652ade57932485cca8cbc6 | |
parent | adea99b227a428dbda27e8fa2ed36c35672f5b07 (diff) | |
download | gitlab-ce-390bcc709390e6ffd7c1da56685feba6ead9a2a7.tar.gz |
Merge branch 'security-kubeclient-ssrf-11-4' into 'security-11-4'
[11.4] Security kubeclient ssrf
See merge request gitlab/gitlabhq!2573
-rw-r--r-- | changelogs/unreleased/security-kubeclient-ssrf.yml | 5 | ||||
-rw-r--r-- | config/initializers/kubeclient.rb | 21 |
2 files changed, 26 insertions, 0 deletions
diff --git a/changelogs/unreleased/security-kubeclient-ssrf.yml b/changelogs/unreleased/security-kubeclient-ssrf.yml new file mode 100644 index 00000000000..45fc41029fc --- /dev/null +++ b/changelogs/unreleased/security-kubeclient-ssrf.yml @@ -0,0 +1,5 @@ +--- +title: Monkey kubeclient to not follow any redirects. +merge_request: +author: +type: security 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 |