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

Allow enrich_user to read/view enrich indices #100707

Merged
merged 2 commits into from
Oct 11, 2023
Merged

Conversation

dnhatn
Copy link
Member

@dnhatn dnhatn commented Oct 11, 2023

Error: [esql] > Unexpected error from Elasticsearch: security_exception - action [indices:data/read/esql/lookup] is unauthorized for user [guest] with effective roles [enrich_user,esql-read-role] on restricted indices [.enrich-group_lookup-1696927917972], this action is granted by the index privileges [read,all]

Currently, the enrich indices (.enrich-*) are restricted system indices managed by the enrich plugin. While the enrich_user should not be allowed to manage or write to these indices, they should be allowed to read and view_index_metadata. This is necessary for ESQL; otherwise, ESQL users would require broader privileges to perform enrich in ESQL.

@dnhatn dnhatn added >bug :Security/Authorization Roles, Privileges, DLS/FLS, RBAC/ABAC v8.11.1 v8.12.0 labels Oct 11, 2023
@elasticsearchmachine
Copy link
Collaborator

Hi @dnhatn, I've created a changelog YAML for you.

@dnhatn dnhatn requested a review from jakelandis October 11, 2023 17:15
@dnhatn dnhatn marked this pull request as ready for review October 11, 2023 17:15
@dnhatn dnhatn added Team:Data Management Meta label for data/management team Team:Security Meta label for security team labels Oct 11, 2023
@elasticsearchmachine elasticsearchmachine removed the Team:Data Management Meta label for data/management team label Oct 11, 2023
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-security (Team:Security)

Copy link
Contributor

@jakelandis jakelandis left a comment

Choose a reason for hiding this comment

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

LGTM

@dnhatn
Copy link
Member Author

dnhatn commented Oct 11, 2023

@jakelandis Thank you so much for the quick review ❤️

@dnhatn dnhatn merged commit b95149c into elastic:main Oct 11, 2023
@dnhatn dnhatn deleted the enrich-user branch October 11, 2023 18:28
dnhatn added a commit to dnhatn/elasticsearch that referenced this pull request Oct 11, 2023
> Unexpected error from Elasticsearch: security_exception - action [indices:data/read/esql/lookup] is unauthorized for user [guest] with effective roles [enrich_user,esql-read-role] on restricted indices [.enrich-group_lookup-1696927917972], this action is granted by the index privileges [read,all]

Currently, the enrich indices (.enrich-*) are restricted system indices 
managed by the enrich plugin. While the `enrich_user` should not be
allowed to manage or write to these indices, they should be allowed to
read and view_index_metadata. This is necessary for ESQL; otherwise,
ESQL users would require broader privileges to perform enrich in ESQL.
@elasticsearchmachine
Copy link
Collaborator

💚 Backport successful

Status Branch Result
8.11

elasticsearchmachine pushed a commit that referenced this pull request Oct 11, 2023
* Allow enrich_user to read/view enrich indices (#100707)

> Unexpected error from Elasticsearch: security_exception - action [indices:data/read/esql/lookup] is unauthorized for user [guest] with effective roles [enrich_user,esql-read-role] on restricted indices [.enrich-group_lookup-1696927917972], this action is granted by the index privileges [read,all]

Currently, the enrich indices (.enrich-*) are restricted system indices 
managed by the enrich plugin. While the `enrich_user` should not be
allowed to manage or write to these indices, they should be allowed to
read and view_index_metadata. This is necessary for ESQL; otherwise,
ESQL users would require broader privileges to perform enrich in ESQL.

* compile
dnhatn added a commit that referenced this pull request Oct 18, 2023
Today, we have a hierarchy of tasks in ESQL designed to leverage the 
task framework for reporting status and cancellation.

```mermaid
flowchart
 RESTLayer -->|  EsqlQueryRequest indices:data/read/esql  | ComputeService
 ComputeService -->| DriverRequest indices:data/read/esql/compute | Driver
 ComputeService -->| DataNodeRequest indices:data/read/esql/data | DataNode
 DataNode -->| DriverRequest indices:data/read/esql/compute | Driver
 Driver -->| LookupRequest indices:data/read/esql/lookup | EnrichLookupService
```

The primary issue here is that `DriverRequest` is neither 
`IndicesRequest` nor `CompositeIndicesRequest`. Consequently, the Driver
is executed within the context of the system user, leading to access
indices with the system user.

To address this issue, this PR makes `DriverRequest` a 
`CompositeIndicesRequest` and ensures that the Driver executes within
the user's context. With this fix we can now properly capture the
response headers when a Driver is yielded and rescheduled.

Relates #100707
Relates #99646

Relates #99926
Closes #100164
dnhatn added a commit to dnhatn/elasticsearch that referenced this pull request Oct 18, 2023
Today, we have a hierarchy of tasks in ESQL designed to leverage the 
task framework for reporting status and cancellation.

```mermaid
flowchart
 RESTLayer -->|  EsqlQueryRequest indices:data/read/esql  | ComputeService
 ComputeService -->| DriverRequest indices:data/read/esql/compute | Driver
 ComputeService -->| DataNodeRequest indices:data/read/esql/data | DataNode
 DataNode -->| DriverRequest indices:data/read/esql/compute | Driver
 Driver -->| LookupRequest indices:data/read/esql/lookup | EnrichLookupService
```

The primary issue here is that `DriverRequest` is neither 
`IndicesRequest` nor `CompositeIndicesRequest`. Consequently, the Driver
is executed within the context of the system user, leading to access
indices with the system user.

To address this issue, this PR makes `DriverRequest` a 
`CompositeIndicesRequest` and ensures that the Driver executes within
the user's context. With this fix we can now properly capture the
response headers when a Driver is yielded and rescheduled.

Relates elastic#100707
Relates elastic#99646

Relates elastic#99926
Closes elastic#100164
elasticsearchmachine pushed a commit that referenced this pull request Oct 18, 2023
Today, we have a hierarchy of tasks in ESQL designed to leverage the 
task framework for reporting status and cancellation.

```mermaid
flowchart
 RESTLayer -->|  EsqlQueryRequest indices:data/read/esql  | ComputeService
 ComputeService -->| DriverRequest indices:data/read/esql/compute | Driver
 ComputeService -->| DataNodeRequest indices:data/read/esql/data | DataNode
 DataNode -->| DriverRequest indices:data/read/esql/compute | Driver
 Driver -->| LookupRequest indices:data/read/esql/lookup | EnrichLookupService
```

The primary issue here is that `DriverRequest` is neither 
`IndicesRequest` nor `CompositeIndicesRequest`. Consequently, the Driver
is executed within the context of the system user, leading to access
indices with the system user.

To address this issue, this PR makes `DriverRequest` a 
`CompositeIndicesRequest` and ensures that the Driver executes within
the user's context. With this fix we can now properly capture the
response headers when a Driver is yielded and rescheduled.

Relates #100707
Relates #99646

Relates #99926
Closes #100164
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Security/Authorization Roles, Privileges, DLS/FLS, RBAC/ABAC Team:Security Meta label for security team v8.11.1 v8.12.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants