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

Support running Auditbeat and Elastic Agent docker images without root #20996

Closed
jsoriano opened this issue Sep 5, 2020 · 10 comments
Closed
Assignees
Labels
enhancement :Packaging Team:Automation Label for the Observability productivity team Team:Platforms Label for the Integrations - Platforms team v7.10.0

Comments

@jsoriano
Copy link
Member

jsoriano commented Sep 5, 2020

In general it makes more sense to run Auditbeat and Elastic Agent as root. Most of Auditbeat functionality requires high privileges, and Elastic Agent has capabilities to start and supervise other services, including Auditbeat, so it also requires these privileges. Endpoint probably also require high privileges.

For that, docker images use USER root, but this goes against generally accepted good practices, containers run with arbitrary user ids in secured Kubernetes environments, and Red Hat certified images cannot run as root.

So we should stop using USER root, at least in UBI images, that are more intended to certified, secure environments. We have to take into account that the images could still be run as root in privileged environments with runtime options.

Things to do:

  • Remove USER root from Auditbeat and Elastic Agent docker images (at least from the UBI ones).
  • Ensure that they include a minimal configuration that provides some functionality without root privileges. If this is not possible, we will have to reconsider this.
  • Ensure that they can still be run as root, with specific runtime options for that, in privileged environments.

Where to look at:

  • User is set to root for Auditbeat in the magefile.go (here), if we are going to provide different config for default and UBI images, we will have to move this to the packages.yml file as a new config that extends common Beats config, what would allow a cleaner override.
  • User is set to root for Elastic Agent in the packages.yml file (here).

Related PRs and issues:

@jsoriano jsoriano added enhancement :Packaging Team:SIEM Team:Platforms Label for the Integrations - Platforms team Team:Automation Label for the Observability productivity team labels Sep 5, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/integrations-platforms (Team:Platforms)

@elasticmachine
Copy link
Collaborator

Pinging @elastic/ingest-management (Team:Ingest Management)

@elasticmachine
Copy link
Collaborator

Pinging @elastic/siem (Team:SIEM)

@jsoriano jsoriano changed the title Run Auditbeat and Elastic Agent docker images without root Support running Auditbeat and Elastic Agent docker images without root Sep 5, 2020
@ph
Copy link
Contributor

ph commented Sep 8, 2020

@blakerouse Can you do a follow up with @jsoriano on the required changes for the Elastic Agent?

@ph
Copy link
Contributor

ph commented Sep 8, 2020

@jsoriano Do Packetbeat have the same problems?

@jsoriano
Copy link
Member Author

jsoriano commented Sep 9, 2020

@jsoriano Do Packetbeat have the same problems?

Nop, it is not using USER root.

Though it doesn't start unless --privileged is used 🤔

$ docker run -it --rm  docker.elastic.co/beats/packetbeat:7.9.0
/usr/local/bin/docker-entrypoint: line 8: /usr/share/packetbeat/packetbeat: Operation not permitted

We should find a consistent solution for containers requiring privileges.

@jsoriano
Copy link
Member Author

jsoriano commented Sep 9, 2020

I have created a separated issue for Packetbeat as the problem is different: #21032

@blakerouse
Copy link
Contributor

I think from Elastic Agent side, it's not required for it to be ROOT. But I do think we need to ensure we disable Endpoint when not running as ROOT, also we probably need to ensure it doesn't run when in a container anyway.

@jsoriano
Copy link
Member Author

jsoriano commented Sep 9, 2020

I think from Elastic Agent side, it's not required for it to be ROOT. But I do think we need to ensure we disable Endpoint when not running as ROOT, also we probably need to ensure it doesn't run when in a container anyway.

I think it is enough if the container starts with the default configuration, and it fails later depending on some custom configuration or some other condition. It is in principle ok to give more privileges on runtime (with --cap-add, --privileged...).

I will give a try to just removing USER root, and check if privileged features work with the same image after adding privileges.

@jsoriano
Copy link
Member Author

I am closing this after reviewing/fixing these cases:

  • Auditbeat fails with default configuration if run without root user, but also if run without other privileges, so USER root only doesn't help. All this is documented and I remove USER root in Cherry-pick #21175 to 7.x: Some fixes in Cloud Foundry fields #21201.
  • Elastic Agent can start filebeat and metricbeat with the default configuration without the need of USER root. Some services services or features will need additional capabilities to work correctly, but only USER root doesn't help on that, similar to the Auditbeat case. I remove USER root and make some adjustements so it works in Stop running agent container as root by default #21213.
  • Packetbeat requires NET_ADMIN capabilities to work, and this is documented. USER root doesn't help because it is not enough to provide this capability, and is already not used, so nothing to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement :Packaging Team:Automation Label for the Observability productivity team Team:Platforms Label for the Integrations - Platforms team v7.10.0
Projects
None yet
Development

No branches or pull requests

4 participants