-
Notifications
You must be signed in to change notification settings - Fork 88
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
Add ability to provide the agent-id in enroll API #4226
Comments
I think we already provide this through the fleet-server/model/openapi.yml Lines 150 to 155 in 0687ea5
It was added with #2655 |
@michel-laterman |
@blakerouse and I had a brief conversation about this. We've decided to add an ID field to enrolment requests that is distinct from the existing This is so that we don't break/get blocked on existing scale tests when delivering this feature; and as a follow up we can see if we can make the scale tests just use the new ID value and deprecate I've also looked a bit more into opamp for how it handles duplicate IDs. In short, this type of workflow (where we may have more than one pod that are "the same agent") isn't supported. When sending a message an agent is able to specify their own Additionally Supporting this workflow is something we'll need to handle once we start supporting opamp. |
@nimarezainia do you think this is something we could piggy back on in order to migrate Agent from a cluster to another using the same ID in the enroll command? |
@jlind23 After our discussion of the security implications I have added a section to the description about the addition agent-token API option for enrollment. Hopefully this implementation would alleviate those implications. @elastic/product-security Could you give the security implications a review? |
Updated description to change from bcrypt to pbkdf2-sha512, so it would be FIPS compliant. |
HI @blakerouse , I am trying to wrap my head around this ( generally a flow diagram or some kind of design doc works wonders for a review 🙏 ), can you validate my understanding ?
Now, we propose that we introduce a replace-token that needs to be sent along with the initial enrollment, stored server side and then must be resent every time an agent wants to reuse an Agent ID. How is the Agent ID calculated or persisted on the pod ? Can we make this impractical to guess instead of introducing a new token to be generated and stored ? There is a high chance I am missing something, so happy to get some more info here or sync in a zoom chat about this or read something more detailed to get up to speed. |
Correct.
An enrollment token is like an authorization to enroll, it can be shared by many Elastic Agent's. Currently at enrollment you are assigned a new Agent ID, that is the issue at hand. We need to define that at enrollment time that we want a specific Agent ID, that will overwrite an existing Agent. It is an issue of persistent storage where we lose the saved credentials to continue using the same Agent ID.
Correct.
We could make the Agent ID hard to guess, but they are shown in the Fleet UI. If you have access to the Fleet UI then you would easily be able to get this ID. It will generate a unique replace-token and store that in a secret in Kubernetes, Kubernetes will be the persistent storage in that case. This unique replace-token is not visible to the user in the Fleet UI and even if you view the At the moment the Elastic Agent doesn't have a way of saving all of its enrollment information as a Kubernetes secret and we don't want to give Elastic Agent any credentials of communication with the Kubernetes API to store this information as that would be worse for security.
I don't think you are missing anything, hopefully my answers above provide more clarity. |
@blakerouse Thank you. I had trouble consolidating these two:
and
but I think I get it know. We can persist secrets but we cannot persist all the information we need for an agent to be enrolled ( policies, etc ) so it has to go through enrollment again after restart. Enrollment token is not tied to a specific agent so we can's store that instead.
Is someone who legitimately has access to the Fleet UI, someone we need to protect against ? Couldn't they disengage an agent ? Or is it more granular that there are viewers who can see agents and their IDs but have no more control over these agents and these policies ? In general, I don't have any qualms with the design that includes the replace-token as long as we generate the token on the agent in a secure manner ( i.e. https://pkg.go.dev/crypto/rand ) and we store it securely server-side. PBKDF2 sounds proper as long as we select a high enough number of iterations and a proper hash function ( SHA512 ticks both security and compliance boxes ) |
Correct.
Correct it is in the URL of viewing the Agent and rendered on the page.
We do protect against customers performing actions on serverless agents in Kibana, like unenroll.
The PR uses |
Describe the enhancement:
Add the ability to specify the agent-id of the enrolling Elastic Agent.
Describe a specific use case for the enhancement or feature:
On serverless, an Elastic Agent is static but the pod doesn't have any persistent storage so it cannot store the enrollment information between restarts of the Elastic Agent. There have also been other reports of this issue from customers where they do not need persistent storage from the integration and requiring the Elastic Agent to have it just for the enrollment information is not possible.
To provide a stable Elastic Agent in the agents list in Kibana, this would allow an Elastic Agent to enroll with the ID they want to have. This would also replace an existing Elastic Agent if one already has the same ID.
The new enrolled Elastic Agent will replace the previous Elastic Agent prevent it from being able to communicate with the Fleet Server any more.
Describe any security issues:
This does open the possibility that if a bad actor had the enrollment token and the ID of the Elastic Agent it would be able to enroll over top of it and prevent the communication of that current Elastic Agent as the other Elastic Agent would be come the newly communicating Elastic Agent.
To prevent this only an additional replace-token would be added to the enrollment API. This would be any unique value that is stored as a pbkdf2-sha512 hash on the Elastic Agent record. If an Elastic Agent is enrolled without this token then it doesn't allow any other Elastic Agent to enroll with the same ID (trying to enroll with the same ID would error). If an Elastic Agent is enrolled with the replace token and its the first enrollment then it would successfully enroll. On a second enrollment to replace the Elastic Agent the exact same replace token must be provided and if it matches (using pbkdf2-sha512 hash) then it would be considered the replacement of the Elastic Agent and allow the enrollment to complete.
The text was updated successfully, but these errors were encountered: