Skip to content

fix!: respect deny rules for access requests#34438

Merged
nklaassen merged 1 commit intomasterfrom
nklaassen/request-rbac
Nov 14, 2023
Merged

fix!: respect deny rules for access requests#34438
nklaassen merged 1 commit intomasterfrom
nklaassen/request-rbac

Conversation

@nklaassen
Copy link
Copy Markdown
Contributor

@nklaassen nklaassen commented Nov 10, 2023

Access Requests follow their own set of RBAC rules. Usually, none of the typical create/read/list/delete verbs are required in any user's roles. Access is handled via custom rules based on the allow.request, deny.request, allow.review_requests, and deny.review_requests fields in the role spec.

The create/read/list/delete verbs commonly used for other resources are usually all or nothing (barring where expressions), but a more nuanced set of rules apply to access requests. E.g. users should always be allowed to see access requests that they created or are allowed to review, without being allowed to see other access requests in the cluster.

This seemed mostly logical once you thought about it long enough, but one detail that has been lacking so far is that explicit deny rules in the user's roles have no effect at all, even though explicit allow rules grant god-mode access to create or view any access requests in the cluster.

Even with the following role, you could still create and view access requests:

kind: role
version: v6
metadata:
  name: example
spec:
  allow:
    request:
      roles: ["*"]
    review_requests:
      roles: ["*"]
  deny:
    rules:
      - resources: ["access_request"]
        verbs: ["create", "read", "list"]

This commit makes any explicit deny rules actually take effect.

Fixes https://github.com/gravitational/teleport-private/issues/298

changelog: Respect explicit deny rules for Access Requests.

Comment thread lib/auth/auth_with_roles.go Outdated
Comment on lines 106 to 107
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This was here to make trace.IsAccessDenied work, but is no longer necessary now that aggregate errors support Is/As since gravitational/trace#77

@rosstimothy rosstimothy requested a review from jentfoo November 10, 2023 01:49
Access Request follow their own set of RBAC rules.
Usually, none of the typical create/read/list/delete verbs are required
in any user's roles.
Access is handled via custom rules based on the allow.request, deny.request,
allow.review_requests, and deny.review_requests role fields.

The create/read/list/delete verbs commonly used for other resources are
usually all or nothing (barring `where` expressions), but a more nuanced
set of rules apply to access requests. E.g. users should always be
allowed to see access requests that they created or are allowed to
review, without being allowed to see other access requests in the
cluster.

This seemed mostly logical once you thought about it long enough, but
one detail that has been lacking so far is that explicit deny rules in
the user's roles have no effect at all, even though explicit allow rules
grant god-mode access to create or view any access requests in the
cluster.

Even with the following role, you could still create and view
access requests:

```yaml
kind: role
version: v6
metadata:
  name: example
spec:
  allow:
    request:
      roles: ["*"]
    review_requests:
      roles: ["*"]
  deny:
    rules:
      - resources: ["access_request"]
        verbs: ["create", "read", "list"]
```

This commit makes any explicit deny rules actually take effect.

Fixes gravitational/customer-sensitive-requests#103

changelog: Respect explicit deny rules for Access Requests.
@nklaassen nklaassen force-pushed the nklaassen/request-rbac branch from d0eaa62 to 8de1376 Compare November 10, 2023 20:02
@nklaassen
Copy link
Copy Markdown
Contributor Author

friendly ping @atburke

@nklaassen nklaassen added this pull request to the merge queue Nov 14, 2023
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 14, 2023
@nklaassen nklaassen added this pull request to the merge queue Nov 14, 2023
Merged via the queue into master with commit ce5de4c Nov 14, 2023
@nklaassen nklaassen deleted the nklaassen/request-rbac branch November 14, 2023 20:35
@public-teleport-github-review-bot
Copy link
Copy Markdown

@nklaassen See the table below for backport results.

Branch Result
branch/v12 Failed
branch/v13 Create PR
branch/v14 Create PR

nklaassen added a commit that referenced this pull request Nov 14, 2023
github-merge-queue Bot pushed a commit that referenced this pull request Nov 16, 2023
* [v12] fix!: respect deny rules for access requests

Backport #34438 to branch/v12

* test fix

* chore: Bump gravitational/trace to v1.3.0 (#30064)

* chore: Bump gravitational/trace to v1.3.0

* Replace `trace.IsEOF` with `errors.Is`

* Fix IsPermanentEmitError

* chore: update gravitational/trace to v1.3.1

---------

Co-authored-by: Alan Parra <alan.parra@goteleport.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants