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

hardening openshift-apiserver default policy resources on upgrade clusters #312

Closed
wants to merge 1 commit into from

Conversation

vareti
Copy link

@vareti vareti commented May 8, 2020

@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: vareti
To complete the pull request process, please assign kbsingh
You can assign the PR to them by writing /assign @kbsingh in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@vareti vareti force-pushed the anon-user branch 2 times, most recently from 36fdc00 to 43155ba Compare May 13, 2020 21:00
enhancements/authentication/unauthenticated-subjects.md Outdated Show resolved Hide resolved
enhancements/authentication/unauthenticated-subjects.md Outdated Show resolved Hide resolved
enhancements/authentication/unauthenticated-subjects.md Outdated Show resolved Hide resolved
enhancements/authentication/unauthenticated-subjects.md Outdated Show resolved Hide resolved
enhancements/authentication/unauthenticated-subjects.md Outdated Show resolved Hide resolved
enhancements/authentication/unauthenticated-subjects.md Outdated Show resolved Hide resolved
enhancements/authentication/unauthenticated-subjects.md Outdated Show resolved Hide resolved
enhancements/authentication/unauthenticated-subjects.md Outdated Show resolved Hide resolved

### Risks and Mitigations

Because of the earlier releases of OpenShift allowing access to “/” endpoint, some customer implementations might be expecting this privileged access to anonymous users. Removing unauthenticated subject on an upgrade might break some of these implementations. Informing customers beforehand of this change would help the customer to decide better. Customers can either opt-out of reconciliation or change their implementation to match the new requirements. A customer can opt-out of reconciliation by setting the annotation to "false" before the upgrade.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe list the list of CRBs that the customer might need to change and the CLI invocations required to set the annotation on one or more of those resources? This will aid in development of documentation for the proposed change.

Copy link
Author

Choose a reason for hiding this comment

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

Good idea. Add more content based on your comments. Do you think it is better now?


## Alternatives

An alternate implementation is to add an alert to warn of potentially insecure bootstrap policy with instructions to fix. This would not break existing clusters and ensures that they could fix the problem.
Copy link
Contributor

Choose a reason for hiding this comment

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

You've mentioned some pros of this alternative. Maybe summarize the cons as well?

Copy link
Author

Choose a reason for hiding this comment

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

Added something that I thought is relevant. Please let me know if that is not sufficient.

@vareti vareti changed the title adding a new enhancement for fixing anonymous user access hardening openshift-apiserver default policy resources on upgrade clusters May 14, 2020
@vareti vareti force-pushed the anon-user branch 2 times, most recently from 5c9e947 to 59770c9 Compare May 14, 2020 11:48
@vareti
Copy link
Author

vareti commented May 14, 2020

@marun Thanks for taking the time to do a detailed review. I tried to address your comments. Please take a look.


## Summary

* In earlier releases of OpenShift, the authorization module would allow anonymous users to access discovery endpoint.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: endpoints

Copy link
Contributor

Choose a reason for hiding this comment

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

same below

* This enhancement proposes a way to remove unauthenticated subjects from cluster role bindings after an upgrade from this earlier release.
* It is possible that a customer is relying on anonymous user behavior in an implementation.
* This enhancement also proposes a way to opt-out of this reconciliation mechanism. Thus helping cases where changes are not desirable to customer implementations.
* Later releases of OpenShift removed this access for anonymous users. So, this enhancement would not affect the customers who install a fresh cluster using these later releases.
Copy link
Contributor

Choose a reason for hiding this comment

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

can you link where we changes that? Was either me or Mo, probably in origin repository.


### Goals

> 1. Upgrading an OpenShift cluster removes unauthenticated subjects from cluster role bindings that give access to discovery API.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: remove >

### Goals

> 1. Upgrading an OpenShift cluster removes unauthenticated subjects from cluster role bindings that give access to discovery API.
> 2. Providing user a way to opt-out of this reconciliation.
Copy link
Contributor

Choose a reason for hiding this comment

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

when?

## Proposal

* Background
* A user who does not provide enough details for authentication with the kube-apiserver is considered anonymous and will be part of "system:unauthenticated" group.
Copy link
Contributor

Choose a reason for hiding this comment

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

s/enough details/authentication information (like a client certificate or a bearer token)/

* A user who does not provide enough details for authentication with the kube-apiserver is considered anonymous and will be part of "system:unauthenticated" group.
* Both kube-apiserver and openshift-apiserver create a set of cluster roles and cluster role bindings during bootstrap.
* This [link](https://kubernetes.io/docs/reference/access-authn-authz/rbac/#default-roles-and-role-bindings) has the list of default cluster roles and cluster role bindings in Kubernetes.
* This [link](https://docs.openshift.com/container-platform/4.4/authentication/using-rbac.html#default-roles_using-rbac) has the list of default cluster roles in OpenShift.
Copy link
Contributor

Choose a reason for hiding this comment

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

would rather prefer a link to the source code. Docs might have diverged.

* This [link](https://kubernetes.io/docs/reference/access-authn-authz/rbac/#default-roles-and-role-bindings) has the list of default cluster roles and cluster role bindings in Kubernetes.
* This [link](https://docs.openshift.com/container-platform/4.4/authentication/using-rbac.html#default-roles_using-rbac) has the list of default cluster roles in OpenShift.
* `rbac.authorization.kubernetes.io/autoupdate=true` annotation is also added to default policy resources.
* On start-up both openshift-apiserver and kube-apiserver reconcile their default policy resources as follows
Copy link
Contributor

Choose a reason for hiding this comment

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

make it clear what is the current logic and what you propose

* add annotation to the RBAC resource.
* add missing permissions to cluster roles.
* add missing subjects to cluster role bindings.
* if the annotation is `rbac.authorization.kubernetes.io/autoupdate=false`
Copy link
Contributor

Choose a reason for hiding this comment

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

what for other values?

* An admin to opt-out of reconciliation for a specific resource by setting annotation `rbac.authorization.kubernetes.io/autoupdate=false`.
* Detailed behavior can be found in this [link](https://kubernetes.io/docs/reference/access-authn-authz/rbac/#auto-reconciliation).

* Openshift-apiserver operator implements a new controller to the reconcile following cluster role bindings created by openshift-apiserver.
Copy link
Contributor

Choose a reason for hiding this comment

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

-the

### Risks and Mitigations

* Because of OpenShift 4.1 allowing access to discovery endpoint, some customer implementations might be expecting this privileged access to anonymous users. Removing unauthenticated subject on an upgrade might break some of these implementations.
* Informing customers beforehand of this change would help the customer to decide better. Customers can either opt-out of reconciliation or change their implementation to match the new requirements. A customer can opt-out of reconciliation by setting the annotation `rbac.authorization.kubernetes.io/autoupdate` to `false` before the upgrade.
Copy link
Contributor

Choose a reason for hiding this comment

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

@mfojtik @marun @deads2k want to hear your take on this change and the necessary, explicit opt-out, after we had the trouble with the SCCs breaking customers.

Copy link
Contributor

Choose a reason for hiding this comment

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

@mfojtik @marun @deads2k want to hear your take on this change and the necessary, explicit opt-out, after we had the trouble with the SCCs breaking customers.

If we follow the recommended approach, you'll have to find a way to count anonymous access to these endpoints before trying to tighten it up.

Also, don't have them prevent reconciliation. Instead, suggest that they create their own binding.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree, we need to do to research first, I would like that to be a pre-requirement described in this enhancement and as such include steps how we learn how many clusters in fleet are affected.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, don't have them prevent reconciliation. Instead, suggest that they create their own binding.

I understand that upstream already allows that. But I also hesitate to add this to our resources without a good reason.

@vareti
Copy link
Author

vareti commented Oct 2, 2020

/close

in favor of openshift/openshift-docs#25048

@openshift-ci-robot
Copy link

@vareti: Closed this PR.

In response to this:

/close

in favor of openshift/openshift-docs#25048

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

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.

6 participants