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

Cross-cluster API key query not working when replication is also defined #108147

Closed
renekalff opened this issue May 1, 2024 · 2 comments
Closed
Labels
>bug :Security/Security Security issues without another label Team:Security Meta label for security team

Comments

@renekalff
Copy link

renekalff commented May 1, 2024

Elasticsearch Version

8.12.1

Installed Plugins

No response

Java Version

bundled

OS Version

ECK

Problem Description

When a Cross-Cluster API key is created in the Kibana interface the default access template is to allow everything for both search and replication. When a query is added to the search definition to limit the search scope to specific documents access to all documents is still granted by the "replication" definition when a cross cluster search is performed.

Steps to Reproduce

  1. Create a cross cluster api key in the remote cluster with the following definition:
{
  "search": [
    {
      "names": [
        "*"
      ],
      "query": "{\"term\":{\"myfield\":{\"value\":\"this_should_never_match\"}}}",
      "allow_restricted_indices": false
    }
  ],
  "replication": [
    {
      "names": [
        "*"
      ],
      "allow_restricted_indices": false
    }
  ]
}
  1. Setup cross cluster search using the API key
  2. Query the remote cluster from the local cluster. You get results that do not match the query.
  3. Update the API key access to:
{
  "search": [
    {
      "names": [
        "*"
      ],
      "query": "{\"term\":{\"myfield\":{\"value\":\"this_should_never_match\"}}}",
      "allow_restricted_indices": false
    }
  ]
}
  1. Query the remote cluster from the local cluster. You now get only results that match the query.

Logs (if relevant)

No response

@renekalff renekalff added >bug needs:triage Requires assignment of a team area label labels May 1, 2024
@mosche mosche added :Security/Security Security issues without another label and removed needs:triage Requires assignment of a team area label labels May 1, 2024
@elasticsearchmachine elasticsearchmachine added the Team:Security Meta label for security team label May 1, 2024
@elasticsearchmachine
Copy link
Collaborator

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

@jakelandis
Copy link
Contributor

This has been resolved with #108600

8.14 will be the GA release of this functionality and will prohibit defining DLS/FLS queries when both search and replication are defined. Cross Cluster API keys created with this configuration before 8.14 will also be rejected. Unfortunately, rejecting this scenerio is the only plausible way to address this in the short term due to some deeply baked in implementation details.

If you need both search and replication, and need DLS for the search, you will need to use 2 different API keys with different 2 different remote cluster connections (one for search, and the other for replication). The technical overhead of 2 connections to the same cluster is minimal, and hopefully the functional overhead of managing 2 cross cluster API keys is also minimal. Alternatively, if it is the same admin that controls both clusters, then you could also omit the DLS on the cross cluster API key and introduce it instead on the local side via the "remote_indices" to enforce DLS.

Also, thanks @renekalff for the bug report ! If you want to send an email to [email protected] and reference this issue we may be able to provide some credit for this discovery per our security policy: https://github.com/elastic/elasticsearch/security/policy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Security/Security Security issues without another label Team:Security Meta label for security team
Projects
None yet
Development

No branches or pull requests

4 participants