Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SECURITY: Kubeclient::Config: return ssl_options[:verify_ssl] correctly #557

Merged
merged 20 commits into from
Mar 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
b6d9098
Merge pull request #545 from cben/v4.y-test_real_cluster_ssl_verify
cben Mar 14, 2022
7c27fae
test refactor: test_real_cluster.rb
cben Mar 20, 2022
7c331c1
Tests for concatenated CA data (#460)
cben Mar 22, 2022
d1cd26d
Merge pull request #461 from PerfectMemory/openssl-x509-store-add-file
cben Sep 6, 2020
2dd7f64
Changelog for fix for #460
cben Mar 22, 2022
b1824ed
[v4.y] CI: don't abort other builds when one fails error
cben Mar 23, 2022
e05c715
Merge pull request #552 from cben/v4.y-openssl-x509-store-add-file
cben Mar 23, 2022
88483cf
SECURITY: Kubeclient::Config: return ssl_options[:verify_ssl] correctly
cben Mar 16, 2022
f61a4e1
Merge tag 'v4.6.0' into ancient-security-config-ssl_verify
cben Mar 23, 2022
5086eb8
Merge branch 'ancient-security-config-ssl_verify'
cben Mar 23, 2022
c21e2b5
SECURITY: unit tests for Kubeclient::Config handling of ssl_options[:…
cben Mar 20, 2022
aa36e89
SECURITY: integration tests for Config+Client verify_ssl with real cl…
cben Mar 20, 2022
e4cb727
CHANGELOG and README about Config verify_ssl vulnerability
cben Mar 23, 2022
109ea71
Merge pull request #556 from cben/v4.y-security-config-ssl_verify
cben Mar 23, 2022
d7bc03d
Bump kubeclient to 4.9.3
cben Mar 23, 2022
c27893f
Merge pull request #558 from cben/release-4.9.3
cben Mar 23, 2022
6670fab
CHANGELOG and README fixups about #554, #555
cben Mar 23, 2022
2d241e3
Merge pull request #559 from cben/v4.y-security-config-ssl_verify-cha…
cben Mar 23, 2022
d6d1ee8
Merge remote-tracking branch 'origin/v4.y' into security-config-ssl_v…
cben Mar 23, 2022
55709fa
test: silence rubocop about loop that gets aborted from another thread
cben Mar 23, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ on:
- '**'
jobs:
build:
continue-on-error: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is wrong and will result in commits marked as passing when they failed CI

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty certain the overall status is still failed 🔴 (as on all recent PRs where truffleruby fails), its just that individual runs continue till the end.

runs-on: ${{ matrix.os_and_command.os }}
continue-on-error: ${{ contains(matrix.ruby, '-head') }}
strategy:
matrix:
ruby: [ '2.5', '2.6', '2.7', '3.0', '3.1', 'ruby-head', 'truffleruby-head' ]
Expand Down
46 changes: 45 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,54 @@ Notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
Kubeclient release versioning follows [SemVer](https://semver.org/).

## Unreleased
## Unreleased — to become 5.y.z

### Changed
- `Kubeclient::Client.new` now always requires an api version, use for example: `Kubeclient::Client.new(uri, 'v1')`

## 4.9.3 — 2021-03-23

### Fixed

- VULNERABILITY FIX: Previously, whenever kubeconfig did not define custom CA
(normal situation for production clusters with public domain and certificate!),
`Config` was returning ssl_options[:verify_ssl] hard-coded to `VERIFY_NONE` :-(

Assuming you passed those ssl_options to Kubeclient::Client, this means that
instead of checking server's certificate against your system CA store,
it would accept ANY certificate, allowing easy man-in-the middle attacks.

This is especially dangerous with user/password or token credentials
because MITM attacker could simply steal those credentials to the cluster
and do anything you could do on the cluster.

This was broken IN ALL RELEASES MADE BEFORE 2022, ever since
[`Kubeclient::Config` was created](https://github.com/ManageIQ/kubeclient/pull/127/files#diff-32e70f2f6781a9e9c7b83ae5e7eaf5ffd068a05649077fa38f6789e72f3de837R41-R48).

[#554](https://github.com/ManageIQ/kubeclient/issues/554).

- Bug fix: kubeconfig `insecure-skip-tls-verify` field was ignored.
When kubeconfig did define custom CA, `Config` was returning hard-coded `VERIFY_PEER`.

Now we honor it, return `VERIFY_NONE` iff kubeconfig has explicit
`insecure-skip-tls-verify: true`, otherwise `VERIFY_PEER`.

[#555](https://github.com/ManageIQ/kubeclient/issues/555).

- `Config`: fixed parsing of `certificate-authority` file containing concatenation of
several certificates. Previously, server's cert was checked against only first CA cert,
resulting in possible "certificate verify failed" errors.

An important use case is a chain of root & intermediate cert(s) - necessary when cluster's CA
itself is signed by another custom CA.
But also helps when you simply concatenate independent certs. (#461, #552)

- Still broken (#460): inline `certificate-authority-data` is still parsed using `add_cert`
method that handles only one cert.

These don't affect code that supplies `Client` parameters directly,
only code that uses `Config`.

## 4.9.2 — 2021-05-30

### Added
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ The client supports GET, POST, PUT, DELETE on all the entities available in kube
The client currently supports Kubernetes REST api version v1.
To learn more about groups and versions in kubernetes refer to [k8s docs](https://kubernetes.io/docs/api/)

## VULNERABILITY❗

If you use `Kubeclient::Config`, all gem versions released before 2022 could return incorrect `ssl_options[:verify_ssl]`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should say before va.b.c ?
... ideally also change heading to ## VULNERABILITY in <va.b.c so I can quickly ignore the heading

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see #560

endangering your connection and cluster credentials.
See https://github.com/ManageIQ/kubeclient/issues/554 for details and which versions got a fix.

## Installation

Add this line to your application's Gemfile:
Expand Down
9 changes: 6 additions & 3 deletions lib/kubeclient/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,16 @@ def context(context_name = nil)

ssl_options = {}

ssl_options[:verify_ssl] = if cluster['insecure-skip-tls-verify'] == true
OpenSSL::SSL::VERIFY_NONE
else
OpenSSL::SSL::VERIFY_PEER
end

if cluster_ca_data?(cluster)
cert_store = OpenSSL::X509::Store.new
populate_cert_store_from_cluster_ca_data(cluster, cert_store)
ssl_options[:verify_ssl] = OpenSSL::SSL::VERIFY_PEER
ssl_options[:cert_store] = cert_store
else
ssl_options[:verify_ssl] = OpenSSL::SSL::VERIFY_NONE
end

unless client_cert_data.nil?
Expand Down
2 changes: 1 addition & 1 deletion lib/kubeclient/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

# Kubernetes REST-API Client
module Kubeclient
VERSION = '4.9.2'
VERSION = '4.9.3'
end
19 changes: 19 additions & 0 deletions test/config/another-ca1.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
-----BEGIN CERTIFICATE-----
MIIDADCCAeigAwIBAgIUQZjM/5qoAF78qIDyc+rKi4qBdOIwDQYJKoZIhvcNAQEL
BQAwGDEWMBQGA1UEAxMNa3ViZXJuZXRlcy1jYTAeFw0yMjAzMjIxNDQzMDBaFw0z
MjAzMTkxNDQzMDBaMBgxFjAUBgNVBAMTDWt1YmVybmV0ZXMtY2EwggEiMA0GCSqG
SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDGkG7g+UjpDhZ7A4Pm7Hme+RWs5IHz4I2X
IclvtO3LuJ26yzz2S8VaXFFeUqzEPb2G1RxFGvoAVN7qrTw0n5MQJCFLAA4dI7oY
8XLRJ7KgTBBIw1jYpgKb2zyHPIJE6VmslliKUiX+QDovdRU/dsbdup2EucrnGw4+
QNNAc3XMbXgm6lubA6znYZlSpcQ8BKer3tq75q4KUZicIjS6gKQyZjk9a6fcOuCS
ybtlAKp9lYzcwxZkNrx+V1PJMQ1qaJWPnMAVi7Oj5Dm3Jmf1WHBcNEh52Q/0vYlt
4WSaeM5t/Py/m/7c4Ve97f5m2X6EhYyUbzov4qeZOnIJI3MnU1FxAgMBAAGjQjBA
MA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBSl1qyt
jd96WstRE8h9x5qkCvZUvjANBgkqhkiG9w0BAQsFAAOCAQEAJt55qYvBaniAwvgO
tbO79g1FcQGrxpMX45TuoCE/K+MWDjrr6bp+FbLOqT8MwOsbGwwJIRTHGvkEkVso
5AWI5aSNs3hWnltOdz27ZSHeX77WB4daK1tLK6ggZrp3v9iIpbBwWBFdmAqsPvEs
H17K2BgAzdh6xRKPQd0BGTUpJBfk50R2gDMj7FKyIzBN69IOGytBfAXBhHzEGy4+
MvtTEIMUjR//KgCrpNeyDuaWHttR5FdnuRxFO7O3BAfyNSaNmd/IEHQf7DIGgzOy
+xWLyH/HRHj5C70qAqjbnrgBODI99BsA9U7oXTuyPLdIboAcFt2zD5DIYgZET52X
53w4jA==
-----END CERTIFICATE-----
19 changes: 19 additions & 0 deletions test/config/another-ca2.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
-----BEGIN CERTIFICATE-----
MIIDADCCAeigAwIBAgIUHW3OPnmuTquJ0YgbGpmm/blsY2QwDQYJKoZIhvcNAQEL
BQAwGDEWMBQGA1UEAxMNa3ViZXJuZXRlcy1jYTAeFw0yMjAzMjIxNDQ0MDBaFw0z
MjAzMTkxNDQ0MDBaMBgxFjAUBgNVBAMTDWt1YmVybmV0ZXMtY2EwggEiMA0GCSqG
SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDLMEJs5agS0hNQBxPTtsI6dIhIi/pY8liI
sNukbi5KwKf80FYNyRXqE8ufDVyTFzOc+MG96jnHjDaBWjrVN9On0PgUBo4nPyd4
DtyvYx2jMzwToSEIo/Z1aroMx1oGywCgdS4/3FWAbhlSbyXKJmhfh6gX0TxWz+dV
zqNuqQq9EWuRhOMg9vgzjfp3mjiPE10lW8pT0j5JT3PI/eGO+C2Z7z33LJXb6GM2
nXvhGFMGY+7XG65pqJ3L8g1mk+LjPiwyIItw8wPtrnrZ2VXMklMd5Mn+jgCTNe1B
om0nPpPIiTblCr6gcNcVjy5WGN37OKlqrT0JTuSPHcxSUp05LFjDAgMBAAGjQjBA
MA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBQvV/sB
wbR3UwjkLAMN+6P3fZ/3OjANBgkqhkiG9w0BAQsFAAOCAQEACAk4EQwCkw2EBsSR
2SKoa1SjYFkZzIr/0/TB2YcMUvHF+RpvlD5vQ8/RJjeAl1kc6/niZ9TWCemjBLqI
hPoFe49zr49DyQjC2ZfsXVJvFCr6g7o4q4DtQ6ltyBuTJbkn1hI+aB8zgvpofG44
mKj18Y7tPvgXtRua4SaeBq777+22AOvKxPied9p4PTrMN4RKTP6+yIbLflej7dBD
zQDjfmmYsH0T2ZRtBpE1dYrUbU3tkizcMZRJBgreoxoff+r5coibMIm/7gh+YoSb
BCItCaeuGSKQ8CJb8DElcPUd6nKUjmeiQL68ztsG/+CXLiL/TZb914VaaCXvPInw
49jJ7w==
-----END CERTIFICATE-----
20 changes: 20 additions & 0 deletions test/config/concatenated-ca.kubeconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: v1
clusters:
- cluster:
certificate-authority: concatenated-ca.pem
server: https://localhost:6443
name: local
contexts:
- context:
cluster: local
namespace: default
user: user
name: Default
current-context: Default
kind: Config
preferences: {}
users:
- name: user
user:
client-certificate: external-cert.pem
client-key: external-key.rsa
57 changes: 57 additions & 0 deletions test/config/concatenated-ca.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
-----BEGIN CERTIFICATE-----
MIIDADCCAeigAwIBAgIUQZjM/5qoAF78qIDyc+rKi4qBdOIwDQYJKoZIhvcNAQEL
BQAwGDEWMBQGA1UEAxMNa3ViZXJuZXRlcy1jYTAeFw0yMjAzMjIxNDQzMDBaFw0z
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EAxMNa3ViZXJuZXRlcy1jYTAeFw0yMjAzMjIxNDQ0MDBaFw0z
MjAzMTkxNDQ0MDBaMBgxFjAUBgNVBAMTDWt1YmVybmV0ZXMtY2EwggEiMA0GCSqG
SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDLMEJs5agS0hNQBxPTtsI6dIhIi/pY8liI
sNukbi5KwKf80FYNyRXqE8ufDVyTFzOc+MG96jnHjDaBWjrVN9On0PgUBo4nPyd4
DtyvYx2jMzwToSEIo/Z1aroMx1oGywCgdS4/3FWAbhlSbyXKJmhfh6gX0TxWz+dV
zqNuqQq9EWuRhOMg9vgzjfp3mjiPE10lW8pT0j5JT3PI/eGO+C2Z7z33LJXb6GM2
nXvhGFMGY+7XG65pqJ3L8g1mk+LjPiwyIItw8wPtrnrZ2VXMklMd5Mn+jgCTNe1B
om0nPpPIiTblCr6gcNcVjy5WGN37OKlqrT0JTuSPHcxSUp05LFjDAgMBAAGjQjBA
MA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBQvV/sB
wbR3UwjkLAMN+6P3fZ/3OjANBgkqhkiG9w0BAQsFAAOCAQEACAk4EQwCkw2EBsSR
2SKoa1SjYFkZzIr/0/TB2YcMUvHF+RpvlD5vQ8/RJjeAl1kc6/niZ9TWCemjBLqI
hPoFe49zr49DyQjC2ZfsXVJvFCr6g7o4q4DtQ6ltyBuTJbkn1hI+aB8zgvpofG44
mKj18Y7tPvgXtRua4SaeBq777+22AOvKxPied9p4PTrMN4RKTP6+yIbLflej7dBD
zQDjfmmYsH0T2ZRtBpE1dYrUbU3tkizcMZRJBgreoxoff+r5coibMIm/7gh+YoSb
BCItCaeuGSKQ8CJb8DElcPUd6nKUjmeiQL68ztsG/+CXLiL/TZb914VaaCXvPInw
49jJ7w==
-----END CERTIFICATE-----
1 change: 0 additions & 1 deletion test/config/execauth.kubeconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ apiVersion: v1
clusters:
- cluster:
server: https://localhost:6443
insecure-skip-tls-verify: true
name: localhost:6443
contexts:
- context:
Expand Down
21 changes: 21 additions & 0 deletions test/config/external-without-ca.kubeconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: v1
clusters:
- cluster:
# Not defining custom `certificate-authority`.
# Without it, the localhost cert should be rejected.
server: https://localhost:6443
name: local
contexts:
- context:
cluster: local
namespace: default
user: user
name: Default
current-context: Default
kind: Config
preferences: {}
users:
- name: user
user:
client-certificate: external-cert.pem
client-key: external-key.rsa
1 change: 0 additions & 1 deletion test/config/gcpauth.kubeconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ apiVersion: v1
clusters:
- cluster:
server: https://localhost:8443
insecure-skip-tls-verify: true
name: localhost:8443
contexts:
- context:
Expand Down
1 change: 0 additions & 1 deletion test/config/gcpcmdauth.kubeconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ apiVersion: v1
clusters:
- cluster:
server: https://localhost:8443
insecure-skip-tls-verify: true
name: localhost:8443
contexts:
- context:
Expand Down
22 changes: 22 additions & 0 deletions test/config/insecure-custom-ca.kubeconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: v1
clusters:
- cluster:
# This is a silly configuration, skip-tls-verify makes CA data useless, but testing for completeness.
certificate-authority: external-ca.pem
server: https://localhost:6443
insecure-skip-tls-verify: true
name: local
contexts:
- context:
cluster: local
namespace: default
user: user
name: Default
current-context: Default
kind: Config
preferences: {}
users:
- name: user
user:
client-certificate: external-cert.pem
client-key: external-key.rsa
25 changes: 25 additions & 0 deletions test/config/insecure.kubeconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: v1
clusters:
- cluster:
server: https://localhost:6443
insecure-skip-tls-verify: true
name: local
contexts:
- context:
cluster: local
namespace: default
user: user
name: Default
current-context: Default
kind: Config
preferences: {}
users:
- name: user
user:
# Providing ANY credentials in `insecure-skip-tls-verify` mode is unwise due to MITM risk.
# At least client certs are not as catastrophic as bearer tokens.
#
# This combination of insecure + client certs was once broken in kubernetes but
# is meaningful since 2015 (https://github.com/kubernetes/kubernetes/pull/15430).
client-certificate: external-cert.pem
client-key: external-key.rsa
1 change: 0 additions & 1 deletion test/config/nouser.kubeconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ apiVersion: v1
clusters:
- cluster:
server: https://localhost:6443
insecure-skip-tls-verify: true
name: localhost:6443
contexts:
- context:
Expand Down
1 change: 0 additions & 1 deletion test/config/oidcauth.kubeconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ apiVersion: v1
clusters:
- cluster:
server: https://localhost:8443
insecure-skip-tls-verify: true
name: localhost:8443
contexts:
- context:
Expand Down
22 changes: 22 additions & 0 deletions test/config/secure-without-ca.kubeconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: v1
clusters:
- cluster:
# Not defining custom `certificate-authority`.
# Without it, the localhost cert should be rejected.
server: https://localhost:6443
insecure-skip-tls-verify: false # Same as external-without-ca.kubeconfig but with explicit false here.
name: local
contexts:
- context:
cluster: local
namespace: default
user: user
name: Default
current-context: Default
kind: Config
preferences: {}
users:
- name: user
user:
client-certificate: external-cert.pem
client-key: external-key.rsa
21 changes: 21 additions & 0 deletions test/config/secure.kubeconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: v1
clusters:
- cluster:
certificate-authority: external-ca.pem
server: https://localhost:6443
insecure-skip-tls-verify: false # Same as external.kubeconfig but with explicit false here.
name: local
contexts:
- context:
cluster: local
namespace: default
user: user
name: Default
current-context: Default
kind: Config
preferences: {}
users:
- name: user
user:
client-certificate: external-cert.pem
client-key: external-key.rsa
2 changes: 2 additions & 0 deletions test/config/update_certs_k0s.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def sh!(*cmd)
# The rest could easily be extracted from allinone.kubeconfig, but the test is more robust
# if we don't reuse YAML and/or Kubeclient::Config parsing to construct test data.
sh! "#{DOCKER} exec #{CONTAINER} cat /var/lib/k0s/pki/ca.crt > test/config/external-ca.pem"
sh! 'cat test/config/another-ca1.pem test/config/external-ca.pem '\
' test/config/another-ca2.pem > test/config/concatenated-ca.pem'
sh! "#{DOCKER} exec #{CONTAINER} cat /var/lib/k0s/pki/admin.crt > test/config/external-cert.pem"
sh! "#{DOCKER} exec #{CONTAINER} cat /var/lib/k0s/pki/admin.key > test/config/external-key.rsa"

Expand Down
1 change: 0 additions & 1 deletion test/config/userauth.kubeconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ apiVersion: v1
clusters:
- cluster:
server: https://localhost:6443
insecure-skip-tls-verify: true
name: localhost:6443
contexts:
- context:
Expand Down
Loading