hashicorp / hashicorp/consul

/internal/acl/authorize HTTP endpoint does not behave correctly

Open
#11,098 2 comments 2 reactions 0 assignees View on GitHub
theme/api type/bug
Dominant language
Go
Stars
30.1k
Forks
4.6k
Avg merge
1d 18h
Merged PRs (30d)
39

Description

### Context

`/internal/acl/authorize` is used by the UI to answer the question "does this ACL token have permission to do this _kind_ of thing. However, the current implementation of this endpoint uses an `acl.Authorizer` which can only answer questions about specific resources (given the resource ID). It can't answer the more general question of if the acl token has permission to any instance of that resource.

This issue describes a medium term fix. The short-term fix will be https://github.com/hashicorp/consul/issues/11511.

### Necessary changes

The `/internal/acl/authorize` endpoint must be adjusted to answer:
> does this token have `level` (e.g., read, write) access to **"any"** of this kind of resource

... for the following resources ([all resource types that have "labels"](https://www.consul.io/docs/security/acl/acl-rules#resource-and-rule-reference) **and** [are used by the UI](https://github.com/hashicorp/consul/blob/main/ui/packages/consul-ui/app/services/repository/permission.js#L10)):
- [ ] key/value
- [ ] node
- [ ] service
- [ ] intention
- [ ] session

Additionally, the following related changes should be made to the `/internal/acl/authorize` to ensure consistency with the behavior of other endpoints:

- [ ] Use the token's default namespace if no namespace is provided in the request
- [ ] Consider the token's default partition as well (now that partition support is needed)

#### Undo UI Workaround

- [ ] Undo the temporary workaround in https://github.com/hashicorp/consul/pull/11520 used to close https://github.com/hashicorp/consul/issues/11511.

### Related Problems
This problem has caused the following issues that we know of:
1. #10944 was a UI regression in 1.10.x
2. the bug fixed by #11061 was a regression in 1.10.2 only
3. https://github.com/hashicorp/consul/issues/11204 sounds like it may be related as well

Contributor guide

Open the contributing guide

Research direction

Start at the Go implementation of the `/internal/acl/authorize` endpoint and compare its behavior with the linked ACL rules and UI permission service at `ui/packages/consul-ui/app/services/repository/permission.js`. Verify authorization for any key/value, node, service, intention, and session resource, including default namespace and partition handling. Done means the checklist is addressed and the temporary workaround from PR #11520 is removed.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, authorization, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.