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 auto-configuration for packaged installations #75144

Merged
merged 293 commits into from
Oct 15, 2021

Conversation

jkakavas
Copy link
Member

@jkakavas jkakavas commented Jul 8, 2021

This commit ensures that for packaged installations
we will run the auto-configuration code on installation (but not upgrade) time.
This is needed because we expect elasticsearch to be run as a service.
By the time the service runs, the configuration directory is not writable by the
user that runs elasticsearch so we can't persist configuration and key/certificate
material on runtime. Running auto-configuration on installation time
allows us to print information to the user that they have better chance of seeing
(barring unattended installations). We don't have the option to show output to the
user when starting the service with systemctl.

During installation we:

  • Generate TLS material, enable security and TLS and persist on disk
  • Generate a password for the elastic user and store a hash of this
    in the elasticsearch.keystore. This will be picked up by the node
    starting and will be "promoted" to be the cluster wide elastic
    password on first startup. (see Auto-configure the elastic user password #78306 )
  • We notify the user in the output of the package installation about
    whether we succeed and what the password of the elastic user is.

@jkakavas jkakavas added :Delivery/Packaging RPM and deb packaging, tar and zip archives, shell and batch scripts :Security/Security Security issues without another label labels Jul 8, 2021
@jkakavas jkakavas changed the title Packaged auto conf Security auto-configuration for packaged installations Jul 8, 2021
@jkakavas
Copy link
Member Author

jkakavas commented Jul 8, 2021

I've added pointers to what this PR changes, the rest is #74868

jkakavas and others added 5 commits July 13, 2021 17:03
@@ -45,6 +50,19 @@ then
fi
fi

if [[ $AUTO_CONFIG = true ]]; then
# ignore failures in auto-configuration
Copy link
Contributor

Choose a reason for hiding this comment

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

I spoke with @colings86 about this today and we may want to revisit this decision.

Copy link
Member Author

Choose a reason for hiding this comment

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

Which decision is that ?

Copy link
Contributor

Choose a reason for hiding this comment

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

That if we fail to perform auto-configuration (can't write to file) that we might want to fail instead of ignore. Something about "leniency" and being "abhorent", blah blah blah 😉

Copy link
Member Author

Choose a reason for hiding this comment

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

I like aphorisms as the next person but this is not about leniency. We ( and by we I mean mostly @albertzaharovits ) have spent a lot of time thinking about the cases where we should fail and when we should not. This is written in code in #74868 and Albert has the task to write this down to the design doc too. In short, we consider the case where we can't write to the config file because it is set as read-only, as a case where we have an explicit configuration decision by the user ( the file doesn't get to be read only by its own). As such we have elected to not treat this as an error and fail to start the node ( and in doing so introduce a breaking change as we allow this today ) but simply not attempt to auto-configure security for them. Authentication will be enabled but we won't enable and configure TLS. Happy to reconsider or discuss alternative approaches, @colings86 feel free to bring this up for discussion in the project or we can chat anytime

verifySecurityAutoConfigured(es, distribution);
}

private static void verifySecurityAutoConfigured(Installation es, Distribution distribution) throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd really rather not continue to add test coverage as assertions to verifyInstallation(). We should implement this as a new distinct test suite. We also need to add a lot more coverage here for all the other scenarios as this only covers the "happy path". For example:

  • Verify the correct behavior (still under debate) when elasticsearch.yml file is non-writable
  • Verify we don't auto config security if security settings already exist
  • Verify we don't auto config security on an upgrade

There are likely other more specific scenarios that probably are better implemented as unit tests for the CLI tool for which no tests currently yet exist.

Copy link
Member Author

Choose a reason for hiding this comment

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

We also need to add a lot more coverage here for all the other scenarios

Thanks for the feedback, I'll make sure I'll add test coverage before I raise this for review.

Verify the correct behavior (still under debate) when elasticsearch.yml file is non-writable

What is under debate regarding this ?

There are likely other more specific scenarios that probably are better implemented as unit tests for the CLI tool for which no tests currently yet exist.

Makes sense, I think it's better if we keep comments targeted in relevant PRs so that we don't miss anything.

Copy link
Contributor

Choose a reason for hiding this comment

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

What is under debate regarding this ?

Like I mentioned, @colings86 and I briefly talked about possibly erroring on startup if we fail to auto-config security rather than pressing forward. No decisions were made but we might want to reconfirm that this is indeed the behavior we want.

albertzaharovits added a commit that referenced this pull request Oct 14, 2021
This commit introduces TLS auto-configuration for elasticsearch nodes, during
the first startup. A number of heuristics are performed in order to determine if
the node should get TLS auto-configuration which can also be explicitly
disallowed with the use of xpack.security.autoconfiguration.enabled setting.

This affects archive installations and docker. Packaged installations are
handled in #75144 and #75704 .

Co-authored-by: Ioannis Kakavas <[email protected]>
@elasticsearchmachine
Copy link
Collaborator

Hi @jkakavas, I've updated the changelog YAML for you.

@jkakavas jkakavas merged commit e3353c3 into elastic:master Oct 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Delivery/Packaging RPM and deb packaging, tar and zip archives, shell and batch scripts >enhancement :Security/Security Security issues without another label Team:Delivery Meta label for Delivery team Team:Security Meta label for security team v8.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants