-
Notifications
You must be signed in to change notification settings - Fork 154
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
Tamper protected Endpoint integration removal #2747
Tamper protected Endpoint integration removal #2747
Conversation
🌐 Coverage report
|
hmm, the unit test failed in CI and works fine locally
confirmed with the agent team that it's known to be flaky |
@blakerouse is the integration & E2E test framework at a point where Aleks could write a test to verify this with a real instance of Elastic Defend? |
@cmacknz Yes, minus actually having Elastic Defend in the Elastic Agent components. But we support adding a component out of band, so if it was fetched for the tests then yes it could be tested. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really like how this turned out. Think we should get it fully tested with the integration testing framework before merging.
|
||
var ErrNotFound = errors.New("not found") | ||
|
||
func SignedFromPolicy(policy map[string]interface{}) (*Signed, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add comments to each exposed struct and function. In proper format of // {name} {description}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added comments
func SignedFromPolicy(policy map[string]interface{}) (*Signed, error) { | ||
v, ok := policy["signed"] | ||
if !ok { | ||
return nil, fmt.Errorf("policy is not signed: %w", ErrNotFound) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this maybe be a defined error? ErrNotSigned
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from general use case point of view, it's the same meaning, we care if we have data or not, same for the tests.
The fmt.Errorf
adds additional context to ErrNotFound
, which can be logged or propagated up.
It might be more convenient if we could wrap multierror probably like it's possible with Go 1.20
https://tip.golang.org/doc/go1.20#errors
Would have to wait until Endpoint is ready. There was an idea to merge the changes shortly after FF once we manually test it with Endpoint, so we can have the full release window (more time) to test with the real Endpoint and could add E2E right after. Given the scope of the change affects Endpoint/service runtime only. |
This pull request is now in conflicts. Could you fix it? 🙏
|
Closing in favor of combined PR #2781 |
What does this PR do?
Implements the Tamper protected Endpoint integration removal
as described in the first part of https://github.com/elastic/ingest-dev/issues/1882
I discussed this approach with @blakerouse last week. The idea is to not introduce any agent state dependency on a particular order of the policy updates, the agent can still configure itself from any policy revision. The trust is maintained between Kibana and Endpoint through the signed policy payload, that's why the Endpoint would have to know more about the original structure of the policy, because that's what Kibana knows about and that's what it signs.
The surface of the change is limited to to the service runtime teardown implementation, which currently affects only Endpoint.
Here is what's done here:
Change the runtime manager Update signature in order to pass the component.Model instead, thus allowing to pass the optional
Signed
struct as discussed with @blakerouse.Change the Teardown to pass
Signed
Change the teardown sequence for the service runtime, which affects only Endpoint at the moment.
The teardown is now performed in two steps, first the new policy
Signed
object is passed down to Endpoint with the component update.The signed data now has all the inputs included with some minimal set of properties that allows Endpoint
to validate the signature and unprotect itself if the there is no corresponding
endpoint
input in the policy.Here is and example decoded from base64 encoded
signed.data
payload:The agent expects Endpoint to checkin after that or uses the teardown timeout, and proceeds with stopping and uninstalling the service.
This was tested against Kibana changes on @joeypoon branch
https://github.com/joeypoon/kibana/pull/new/feature/sign-unenroll
This will need to be tested and possibly adjusted once Endpoint implements this functionality, will work with @intxgo on validating it end-to-end once the Endpoint is ready.
Why is it important?
Completes the requirements for the tamper protection the 8.10
Checklist
./changelog/fragments
using the changelog toolRelated issues