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

[Security Solution] Adds a version and OS check for Host Isolation #103026

Conversation

kevinlog
Copy link
Contributor

@kevinlog kevinlog commented Jun 23, 2021

Summary

This PR restricts Host Isolation access in the UI based on Agent version and OS.

We need to drop Linux support for the first release. In addition, we should disallow Host Isolation actions if the Agent/Endpoint is under 7.14.0.

I have the functions set up so that we should also be able to restrict based on this via the API

7.14.0 Endpoint with Windows:
image

image

image

Under 7.14.0 Endpoint:
image

image

Checklist

Delete any items that are not applicable to this PR.

@kevinlog kevinlog added v7.14.0 v8.0.0 release_note:feature Makes this part of the condensed release notes Team:Defend Workflows “EDR Workflows” sub-team of Security Solution labels Jun 23, 2021
@kevinlog kevinlog marked this pull request as ready for review June 23, 2021 14:04
@kevinlog kevinlog requested a review from a team as a code owner June 23, 2021 14:04
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-onboarding-and-lifecycle-mgt (Team:Onboarding and Lifecycle Mgt)

@kevinlog
Copy link
Contributor Author

@elasticmachine merge upstream

…restrict-os-and-version-for-host-isolation
@kevinlog kevinlog force-pushed the task/restrict-os-and-version-for-host-isolation branch from 632a5f3 to bf5d968 Compare June 25, 2021 15:41
@@ -102,7 +102,7 @@ export class BaseDataGenerator<GeneratedDoc extends {} = {}> {
}

protected randomVersion(): string {
return [6, ...this.randomNGenerator(10, 2)].map((x) => x.toString()).join('.');
return [7, ...this.randomNGenerator(20, 2)].map((x) => x.toString()).join('.');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Make the version generator possible to be 7.14.0+ to ensure fake docs will pass the version check.

@@ -51,7 +51,7 @@ export const ANCESTRY_LIMIT: number = 2;

const Windows: OSFields[] = [
{
name: 'windows 10.0',
name: 'Windows',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kevinlog
Copy link
Contributor Author

@elasticmachine merge upstream

@@ -62,7 +67,7 @@ export const useEndpointActionItems = (

const isolationActions = [];

if (isIsolated) {
if (isIsolated && isolationSupported) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What are the (rather odd) chances that someone "isolated" an unsupported host via other means and now they can't release it through the UI?

Is this check necessary? if a host can't be isolated, certainly they should never reach the first part of the condition

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case, if Isolation isn't supported, the Endpoint would never be able to actually isolate, even if we sent it an action. The Endpoint would ignore it because it doesn't recognize the action request. This will be true for old Endpoints and for Linux Endpoints in 7.14.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm thinking that regardless if it is supported or not, if we know the host is isolated, then we should allow unisolate. Hopefully this will never happen, but to be safe, I would revert this change here

<EuiSpacer size="l" />
</EuiFlyoutFooter>
)}
{isIsolationAllowed &&
Copy link
Contributor

Choose a reason for hiding this comment

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

I have a concern about hiding the TakeActionDropdown in its entirety. Are we planning to use this dropdown to add more actions later other than isolate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@academo we will add new actions in the future, but currently there is just the one. We would revisit this check when the time comes


import { isVersionSupported, isOsSupported, isIsolationSupported } from './utils';

describe('Host Isolation utils isVersionSupported', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

not necessary to take action:

Jest support table tests which makes these kind of repetitive tests easier to read and write.

https://jestjs.io/docs/api#testeachtablename-fn-timeout

Copy link
Contributor

Choose a reason for hiding this comment

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

Example:

test.each`
  a           | b           | expected
  ${'8.14.9'} | ${'7.13.0'} | ${true}
  ${'8.14.9'} | ${'9.14.0'} | ${false}
`('should validate that version $a is equal($expected) to $b', ({ a, b, expected }) => {
  expect(
    isVersionSupported({
      currentVersion: a,
      minVersionRequired: b,
    })
  ).toEqual(expected);
});

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for the tip, I didn't know that! I've refactored my tests to reflect it.

Copy link
Contributor

@paul-tavares paul-tavares left a comment

Choose a reason for hiding this comment

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

Left some comments. Let me know if you have any questions

minVersionRequired: string;
}) => {
const parsedCurrentVersion = currentVersion.includes('-SNAPSHOT')
? currentVersion.substring(0, currentVersion.length - 9)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe ok for now, but semver can actually have other suffixes like -beta, -alpha, -build, etc. (reference).
My suggestion here is to instead take everything before the dash:

Suggested change
? currentVersion.substring(0, currentVersion.length - 9)
? currentVersion.substring(0, currentVersion.indexOf('-'))

Another alternative - use the semver package that is already available in kibana's node_modules

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -62,7 +67,7 @@ export const useEndpointActionItems = (

const isolationActions = [];

if (isIsolated) {
if (isIsolated && isolationSupported) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm thinking that regardless if it is supported or not, if we know the host is isolated, then we should allow unisolate. Hopefully this will never happen, but to be safe, I would revert this change here

Copy link
Contributor

@paul-tavares paul-tavares left a comment

Choose a reason for hiding this comment

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

🚢
👍

…restrict-os-and-version-for-host-isolation
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
securitySolution 2186 2187 +1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
securitySolution 6.3MB 6.3MB +1.7KB

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@kevinlog kevinlog added the auto-backport Deprecated - use backport:version if exact versions are needed label Jun 29, 2021
@kevinlog kevinlog merged commit 1ff2407 into elastic:master Jun 29, 2021
@kevinlog kevinlog deleted the task/restrict-os-and-version-for-host-isolation branch June 29, 2021 23:46
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.x

This backport PR will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request Jun 30, 2021
…103026) (#103796)

Co-authored-by: Kevin Logan <56395104+kevinlog@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed release_note:feature Makes this part of the condensed release notes Team:Defend Workflows “EDR Workflows” sub-team of Security Solution v7.14.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants