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

RFE: Optionally Encrypt Certs as Secrets on init use token on join #1200

Closed
timothysc opened this issue Oct 30, 2018 · 14 comments
Closed

RFE: Optionally Encrypt Certs as Secrets on init use token on join #1200

timothysc opened this issue Oct 30, 2018 · 14 comments
Assignees
Labels
area/HA area/security kind/feature Categorizes issue or PR as related to a new feature. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release.
Milestone

Comments

@timothysc
Copy link
Member

timothysc commented Oct 30, 2018

edit(neolit123): google doc link for the proposals:
https://docs.google.com/document/d/1XkByzeehah20CgNY47NUMr2VAz-D_ok-GqRX5YRQH0o/edit?usp=sharing


The general UX for standing up an HA control plane is a bit manual for most consumers. There has been a desire for folks to be able to store control plane certs as secrets but there is a broader security concern that these secrets are not encrypted, or any token could be obtained through the cluster itself.

  • Proposal:
    • ControlPlane 1:
      • kubeadm init --upload-certs
      • ...
      • Encrypts the certs locally (using pick your favorite method) and uploads ~= sealed-secret
      • Output a token/key (file or command line)
      • ....
    • ControlPlane 2:
      • kubeadm join --control-plane --download-certs=key

Certs are stored as secrets but the key is only created on init and used on join. The key is never to be stored on cluster.

/cc @kubernetes/sig-cluster-lifecycle

@timothysc timothysc added kind/feature Categorizes issue or PR as related to a new feature. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. labels Oct 30, 2018
@timothysc
Copy link
Member Author

/assign @fabriziopandini @timothysc
/cc @mattmoyer

@inercia
Copy link

inercia commented Oct 30, 2018

@timothysc When you say "Output a token/key (file or command line)" you mean another token? couldn't we use the same token used for joining the cluster? otherwise we would be moving from a "how to distribute certs in the cluster" problem to a "how to distribute a token" problem... :-/

@fabriziopandini
Copy link
Member

fabriziopandini commented Oct 30, 2018

@timothysc
This is a possible solution but what concerns me is that encrypted secrets are another bit of cluster settings that we are duplicating from its "source of through" and that we should manage acróss upgrades.

what if kubeadm join

  • creates a temporary encryption key
  • runs a job/pod on one existing master that grabs secrets from file system and save to an encryped config map
  • Reads from config map and save certs to the local filesystem
  • delete the encrypted config map

Pros: We are duplicating certs only for a short time during the join workflow and the encryption key will be managed by kubeadm
Cons: We need a container image

edited 22/12 - this cannot be implemented to a RBAC problem. see gdoc

@timothysc
Copy link
Member Author

That's a lot of extra jiggery, but it would work too.

@neolit123
Copy link
Member

/assign

@neolit123
Copy link
Member

neolit123 commented Nov 27, 2018

my proposal here:

  • we add a new flag for kubeadm init called e.g. --serve.
  • once kubeadm init has finished we start listening for connections on a TCP port but with a TTL (e.,g. 10 minutes)
  • nodes calling kubeadm join --experimental-control-plane will probe for that connection at the controlplane endpoint IP.
  • if a connection is established a secure handshake will be performed using the boostrap token bytes as a secret.
  • the joining node will them download certs + admin.conf
    (can happen for more than one joining node)
  • TTL will expire and the first CP node will stop the server.
  • to server again a separate kubeadm command can be added.

pros:

  • one source of truth for the certs, no intermediate copying medium - certs go from one disk to another over TCP.
  • easy to implement.

cons:

  • turns kubeadm into a server / client.
  • needs risk evaluation for MITM attacks, although i'm pretty sure this needs super computers already.

working POC project - try it:
https://github.com/neolit123/kubeadm-getter

i can explain how the security implementation and protocol works.

@inercia
Copy link

inercia commented Nov 28, 2018

In my view, the idea of serving files for a limited period of time would mean that new masters could not be added later on, and that would import important restrictions in the topoloogy in the cluster. I guess that the solution in this case would be that users would have to restart the --server side and then join the new master, but this effectively would be no better than a regular scp.

Besides this, I think that the whole idea of having a fileserver embeded in the seeder is not the best approach. Not only because of the MitM problems you mentioned (that would require the distribution of certifciates to the nodes joining as master) but because of this mechanism for distributing files out-of-band.

I think it would be better to distribute these files as part of the bootstrapping process, in the response from the seeder, I don't know the internals of the bootstrapping process, but maybe when the client gets the reposnse to the CSR... So the client could ask "I want to join, but as a new master" and the seeder could perform a regular bootstrap but attaching in some way the new master certificates. Maybe clients should provide some additional token (so not every node could join as a new master), but the whole certificates distribution would be part of the protocol.

What do you guys think?

@neolit123
Copy link
Member

In my view, the idea of serving files for a limited period of time would mean that new masters could not be added later on, and that would import important restrictions in the topoloogy in the cluster. I guess that the solution in this case would be that users would have to restart the --server side and then join the new master, but this effectively would be no better than a regular scp.

that's a limitation yes.
of course if someone wants to they could leave the file server open indefinitely.

Besides this, I think that the whole idea of having a fileserver embeded in the seeder is not the best approach. Not only because of the MitM problems you mentioned (that would require the distribution of certifciates to the nodes joining as master) but because of this mechanism for distributing files out-of-band.

MITM problems are removed by the encryption of the file transfer. there is no need to distribute public/private keys because the bootstrap token itself is the secret key.

I think it would be better to distribute these files as part of the bootstrapping process, in the response from the seeder, I don't know the internals of the bootstrapping process, but maybe when the client gets the reposnse to the CSR... So the client could ask "I want to join, but as a new master" and the seeder could perform a regular bootstrap but attaching in some way the new master certificates. Maybe clients should provide some additional token (so not every node could join as a new master), but the whole certificates distribution would be part of the protocol.

@fabriziopandini proposed something similar. having the certs as part of the bootstrap token.
i don't know how it works completely too, but i think we might end up abusing it a little if we start embedding certs in the transport.

@neolit123
Copy link
Member

after the discussion of 28.11 office hours, we decided that we should collect proposals in a gdoc for this and eventually do a KEP.
TODO

@luxas luxas added this to the v1.14 milestone Nov 28, 2018
@luxas luxas added area/security priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. labels Nov 28, 2018
@neolit123
Copy link
Member

neolit123 commented Dec 3, 2018

@timothysc timothysc added area/HA priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. and removed help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. labels Jan 7, 2019
@fabriziopandini
Copy link
Member

fabriziopandini commented Jan 16, 2019

drafts of the KEP for this feature https://docs.google.com/document/d/1hSghREAoM8f_usJjGuQS1bWEtCC2wBYFNoBC7FyISwA/edit?usp=sharing
I will quickly iterate on google doc for the first round of feedbacks until friday and the move on a PR

@yagonobre
Copy link
Member

will we allow the user to create a cluster without create the kubeadm-certs secret and the encryption-key?

@neolit123
Copy link
Member

neolit123 commented Jan 18, 2019

will we allow the user to create a cluster without create the kubeadm-certs secret and the encryption-key?

we should, as it is now, and this will allow the user to copy certs manually if they want HA.

@neolit123
Copy link
Member

closing in favor of #1373
please re-open if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/HA area/security kind/feature Categorizes issue or PR as related to a new feature. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release.
Projects
None yet
Development

No branches or pull requests

6 participants