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

Limit permissions of gardener-node-agent instances to required objects #10505

Open
11 of 17 tasks
oliver-goetz opened this issue Sep 11, 2024 · 1 comment
Open
11 of 17 tasks
Assignees
Labels
area/security Security related kind/enhancement Enhancement, improvement, extension

Comments

@oliver-goetz
Copy link
Member

oliver-goetz commented Sep 11, 2024

How to categorize this issue?

/area security
/kind enhancement

What would you like to be added:
At the moment gardener-node-agent on every node share their service account (gardener-node-agent) and so also the same permissions.
This means that gardener-node-agents have to many permissions, because they could update Nodes and Leases which belong to different GNAs and they can read OperatingSystemConfig secrets of all worker groups.
The permissions could be reduced way without the necessity to update the core functionality of GNA.

🎯 Goals

  • Each GNA has its own user
  • Reduce permissions of GNA instances
    • GNA can update its own Node only
    • GNA has access to its own Lease only
    • GNA has access to the OSC secret of its own worker group only
  • The feature should be switched on and off without the necessity to role the shoot nodes.

Implementation:

Usernames for GNA
Each instance of gardener-node-agent is using the name of its machine as username.
It cannot use the name of the node, because it is created by kubelet which is deployed by GNA.
It should not use the hostname, because we encountered cases where the hostname changed while GNA was running.
At the moment GNA does not know the name of its machine yet. That's why this feature needs an adapted machine-controller-manager and all provider specific implementations.

node-agent-authorizer webhook
For more granular permissions we cannot rely on the RBAC based authorization only, but could use a Webhook based approach similar to the the SeedAuthorizer we already implemented. The implementation of this NodeAgentAuthorizer could be simpler as there is no need for a dependency graph in this use case.
The webhook is implemented in gardener-resource-manager because it already serves multiple webhooks for shoots.

Certificate based authentication
Certificates and Certificate Signing Requests (CSR) are used to authenticate each GNA individually at the shoot kube-apiserver. The same concept is already used by gardenlet to authenticate at garden-apiserver.

GNA creates CSRs which are automatically approved under these conditions.

  • a machine with the name of the GNA user must exist
  • when a bootstrap token is used: there must not be a node for this machine
  • when a GNA certificate is used: the requesting user and the common name of the certificate must be equal, so GNA is only allowed to renew its on certificate.

There is already a controller in GRM which approves CSRs for kubelet server certificates. This could be adapted for this use-case.

Tasks:

@gardener-prow gardener-prow bot added area/security Security related kind/enhancement Enhancement, improvement, extension labels Sep 11, 2024
@oliver-goetz
Copy link
Member Author

/assign

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/security Security related kind/enhancement Enhancement, improvement, extension
Projects
None yet
Development

No branches or pull requests

1 participant