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

[Fleet] Enrollment API keys in Fleet can go out of sync with security state #190708

Open
criamico opened this issue Aug 19, 2024 · 3 comments
Open
Labels
bug Fixes for quality problems that affect the customer experience Team:Fleet Team label for Observability Data Collection Fleet team

Comments

@criamico
Copy link
Contributor

criamico commented Aug 19, 2024

Kibana version:
All versions

Steps to reproduce:

  • Create a new enrollment API key from Fleet (manually or by creating a new Agent policy)
  • From dev tools, verify that the API key is active.
GET kbn:/api/fleet/enrollment_api_keys

{
  "item": {
    "id": "40295421-0da5-4f74-ad1c-bf362ba505db",
    "active": true,
    "api_key_id": "FPjvapEBtiE6A9XKT3yz",
    "api_key": "****",
    "name": "Default (40295421-0da5-4f74-ad1c-bf362ba505db)",
    "policy_id": "5c1f84e6-8f66-4fb3-9b63-c0da0d4fe9a6",
    "created_at": "2024-08-19T13:59:14.553Z"
  }
}
  • Check that the api key is valid through the security api as well:
GET /_security/api_key?id=FPjvapEBtiE6A9XKT3yz
DELETE /_security/api_key
{
  "ids":["FPjvapEBtiE6A9XKT3yz"]
}
  • Check again the state of the api key in Fleet:
GET /_security/api_key?id=FPjvapEBtiE6A9XKT3yz

The api key is still marked as active, even though it was marked as invalidated from security apis.

Context

When we register a new api key, we create it through the security apis (see

then we create a new entry in .fleet-enrollment-api-keys.

On the other side, when the GET /api/fleet/enrollment_api_keys gets called, we only query the fleet index. If the api key got invalidated from outside, fleet doesn't know and keeps reporting the api key as active.

We should find a way to sync the state of the api keys in .fleet-enrollment-api-keys with the actual state registered through security to avoid this type of issues.

@criamico criamico added the Team:Fleet Team label for Observability Data Collection Fleet team label Aug 19, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@criamico criamico added the bug Fixes for quality problems that affect the customer experience label Aug 19, 2024
@kpollich kpollich changed the title [Fleet] Enrollment API keys in FLeet can go out of sync with security state [Fleet] Enrollment API keys in Fleet can go out of sync with security state Aug 19, 2024
@jillguyonnet
Copy link
Contributor

Linking open question regarding Fleet enrollment token deletion flow: #155550 (comment)

@juliaElastic
Copy link
Contributor

juliaElastic commented Sep 2, 2024

We can probably spend some time in tech definition to figure out the best way to deal with this.
I think users deleting an API key manually is not something we have to fix, as it's not a recommended action.

I've seen a similar issue happening when agent policies became out of sync (due to a bug or error), and agents were still trying to use an old API key reference that was invalidated/deleted in ES.
We could potentially have an API endpoint that would reset/sync the API keys or at least report those that don't exist but are referenced as active.
We should probably also document how enrollment tokens are used in Fleet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Team:Fleet Team label for Observability Data Collection Fleet team
Projects
None yet
Development

No branches or pull requests

4 participants