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

[v4.y] SECURITY: Kubeclient::Config: return ssl_options[:verify_ssl] correctly #556

Merged
merged 6 commits into from
Mar 23, 2022

Conversation

cben
Copy link
Collaborator

@cben cben commented Mar 23, 2022

Fixing #554 and #555, this branch will be released as 4.9.3.

Split into fix/unit tests/real-cluster integration tests commits for ease of backporting.
(the first fix commit itself is branched directly from ancient #127 that introduced the issue, hence the later merge commits)

cc @grosser @agrare @jperville @lnacshonredhat

- VULNERABILITY FIX: Previously, whenever kubeconfig did not define
  custom CA (normal situation for production clusters with public domain
  and certificate!), `Config` was returning hard-coded `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.

- 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`.

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

(To ease back-porting, this commit is rebased directly on the 6-year-old
PR that introduced Kubeclient::Config - this was broken from day 1!
ManageIQ#127
Tests come in separate commits based on later points.)
…verify_ssl]

- Removed `insecure-skip-tls-verify: true` from most test configs
  (that was one of the reasons the bug went unnoticed, VERIFY_NONE
  was what the unit tests expected.)

- Added new kubeconfig files + `Config` unit tests covering:
  - custom CA, omitted `insecure-skip-tls-verify`
  - custom CA, `insecure-skip-tls-verify: false`
  - custom CA, `insecure-skip-tls-verify: true`
  - no custom CA, omitted `insecure-skip-tls-verify`
  - no custom CA, `insecure-skip-tls-verify: false`
  - no custom CA, `insecure-skip-tls-verify: true`
@cben
Copy link
Collaborator Author

cben commented Mar 23, 2022

umm I forgot to bump lib/kubeclient/version.rb => #558

cben added a commit to cben/kubeclient that referenced this pull request Mar 23, 2022
Tiny followup to ManageIQ#556.
Sorry for noise, had these locally but forgot to push before merging.
If I start backporting, CHANGELOG.md on master branch might not always be updated
with all backports (it SHOULD, but it will require separate merges to master).
So I prefer pointing to the vulnerability issue as the "source of truth".
Also, security impact will be better discussed on the issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant